Presentation is loading. Please wait.

Presentation is loading. Please wait.

SPRING FRAMEWORK Basics of 1July 27, 2008. Spring Framework Basics Introduction to IoC and AOP Spring Core AOP in Detail Bean Lifecycle Extensibility.

Similar presentations

Presentation on theme: "SPRING FRAMEWORK Basics of 1July 27, 2008. Spring Framework Basics Introduction to IoC and AOP Spring Core AOP in Detail Bean Lifecycle Extensibility."— Presentation transcript:

1 SPRING FRAMEWORK Basics of 1July 27, 2008

2 Spring Framework Basics Introduction to IoC and AOP Spring Core AOP in Detail Bean Lifecycle Extensibility Spring - The Beginning… References Questions/Feedback Agenda 2July 27, 2008

3 Spring Framework 01 Basics 3July 27, 2008

4 Spring Framework Spring is a Lightweight, Inversion of Control and Aspect- Oriented Container Framework Lightweight Inversion of Control Aspect Oriented Container Framework Spring? 4July 27, 2008

5 Spring Framework Play role in Enterprise Application Architecture Core Support Web Application Development Support Enterprise Application Development Support Spring Triangle Spring Goals 55July 27, 2008

6 Spring Framework Spring Triangle 6 Dependency Injection Aspect Oriented Programming Enterprise Service Abstractions 6July 27, 2008

7 Spring Framework To make J2EE easier to use and promote EBP Always better to program to interfaces than classes JavaBeans are a great way to configure applications Framework should not force to catch exceptions if one is unlikely to recover from them Testing is essential and framework should make it easier To make integration with existing technologies easier To easily integrate in existing projects Spring Objectives 7July 27, 2008

8 Spring Framework Organizes middle tier objects Eliminates proliferation of singletons Spring is mostly non-intrusive* Applications built on Spring are easy to Unit Test Use of EJB becomes an implementation choice Consistent framework for Data Access whether JDBC or O/R mapping Any part of Spring can be used in isolation. Provides for flexible architecture Benefit to all application layers Spring Advantages 8July 27, 2008

9 Spring Framework Spring Layers 9 Core AOPWeb MVC ORMWeb DAOContext July 27, 2008

10 Spring Framework Service Interface to which we program. Implementation Concrete class implementing the service. Wiring Act of creating associations between application components. Collaborators Services used by a service to perform business operations Inversion of Control AOP Lingua-Franca 10July 27, 2008

11 Spring Framework 02 Introduction to IoC & AOP 11July 27, 2008

12 Spring Framework public class ProductServicesImpl implements ProductServices { public List getAllProducts(String loanTerm) throws Exception { PricingServiceImpl service = new PricingServiceImpl(); return service.getAllProducts(loanTerm); } public class ProductServicesTest extends TestCase { public void testGetAllProducts() { ProductServices service = new ProductServicesImpl(); try { List products = service.getAllProducts(“30”); assertNotNull(products); } catch (Exception e) { assertTrue(false); } IoC Example 12 ProductServiceImpl PricingServiceImpl new PricingServiceImpl() JNDI Lookup July 27, 2008

13 Spring Framework public class ProductServicesImpl implements ProductServices { private PricingService service; public List getAllProducts(String loanTerm, PricingService service) throws Exception { return service.getAllProducts(loanTerm); } public List getAllProducts(String loanTerm) throws Exception { return service.getAllProducts(loanTerm); } public void setPricingService(PricingService service) { this.service = service; } IoC Example - revisited 13 ProductServiceImpl PricingServiceImpl By setter injection By constructor injection July 27, 2008

14 Spring Framework It is the acquisition of dependent objects that is being inverted. Hence, can be termed as “Dependency Injection” Applying IoC, objects are given their dependent objects at creation time (at runtime) by some external entity that coordinates with each object in the system. Inversion of Control 14July 27, 2008

15 Spring Framework Complements OOP Decomposition of aspects/concerns Modularization of concerns that would otherwise cut across multiple objects Reduces duplicate code Usages Logging Persistence Transaction Management Debugging Performance Metrics Aspect Oriented Programming 15July 27, 2008

16 Spring Framework Cross Cutting Concerns 16July 27, 2008

17 Spring Framework Non-AOP representation Cross Cutting Concerns 17July 27, 2008

18 AOP representation Logging Transaction Management Security Spring Framework Cross Cutting Concerns 18 AutoRate Update Job Generate Loan Products Loan Prequalification Reporting July 27, 2008

19 Spring Framework Spring @ Work 19 Configured Ready-to-use System Spring Container Configuration Metadata Business Objects / POJOs produces July 27, 2008

20 Spring Framework Download the JAR files from, Copy them to the dependency folder. If you start afresh, you might need logging Add a to the ROOT of class folder Add the following to the file to direct all logging to console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n log4j.rootLogger=INFO, stdout (or ERROR) Start coding Build your own preferred way using Ant, Maven, … Spring Installation 20July 27, 2008

21 Spring Framework package spring; public interface HelloWorldService { public void sayHello(); } package spring; public class HelloWorldImpl implements HelloWorldService { private String message; private HelloWorldImpl() { } public HelloWorldImpl(String message) { this.message = message; } public void sayHello() { System.out.println(“Hello “ + message); } public void setMessage(String message) { this.message = message; } 21 Traditional Hello World! July 27, 2008

22 Spring Framework Welcome to Spring! * DTD version for the schema is also available and can be declared as under, Configuring (hello.xml) 22July 27, 2008

23 Spring Framework package spring; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import; public class HelloWorld { public static void main(String[] args) throws Exception { ClassPathResource resource = new ClassPathResource(“hello.xml”); BeanFactory factory = new XmlBeanFactory(resource); HelloWorldService helloWorldService = (HelloWorldService) factory.getBean("helloWorldService"); helloWorldService.sayHello(); } The Actual Implementation – 23July 27, 2008

24 Spring Framework A service bean using the EJB way, private OrderService orderService; public void doRequest(HttpServletRequest request) { Order order = createOrder(request); OrderService service = getOrderService(); service.createOrder(order); } private OrderService getOrderService() throws CreateException { if (orderService == null) { Context initial = new InitialContext(); Context ctx = (Context) initial.lookup(“java:comp/env”); Object ref = ctx.lookup(“ejb/OrderServiceHome”); OrderServiceHome home = (OrderServiceHome) PortableRemoteObject.narrow(ref, OrderService.class); orderService = home.create(); } return orderService; } IoC in an Enterprise Application 24July 27, 2008

25 Spring Framework Magic the dependency injection way, private OrderService orderService; public void doRequest(HttpServletRequest request) { Order order = createOrder(request); orderService.createOrder(order); } public void setOrderService(OrderService service) { orderService = service; } IoC in an Enterprise Application 25July 27, 2008

26 Spring Framework 03 The Core 26July 27, 2008

27 Spring Framework may be POJO/EJB/WebService Spring’s world revolves all around Beans Generated using two different containers, Bean Factory Provides basic support for dependency injection Application Context Built over BeanFactory to provide support for i18N, events, and file resources. Wiring done using bean definitions Specified as Configuration Metadata Spring Beans 27July 27, 2008

28 Spring Framework Implementation of Factory design pattern. Creates associations between objects, doles out fully configured, ready to use objects. Manages all the beans in the container. Bean Factory 28 July 27, 2008

29 Spring Framework Using Bean Factories In version 2.0 Resource resource = new FileSystemResource(“beans.xml”); BeanFactory factory = new XmlBeanFactory(resource); In version 1.0 FileInputStream stream = new FileInputStream(“beans.xml”); BeanFactory factory = new XmlBeanFactory(stream); Instantiating Container 29 July 27, 2008

30 Spring Framework In-box wrappers available for, UrlResource ClassPathResource FileSystemResource ServletContextResource InputStreamResource ByteArrayResource Also, provides for loading of resources such as images, css, js etc. in a web application. Resource Interface 30 July 27, 2008

31 Spring Framework Resource Interface, public interface Resource extends InputStreamSource Methods, boolean exists() boolean isOpen() InputStream getInputStream() String getDescription() often returns fully qualified file name or the actual URL URL getURL() File getFile() String getFilename() Resource createRelative(String relativePath) Resource Interface 31 July 27, 2008

32 Spring Framework Aggregates information about the application that can be used by all components. Various implementations are, ClassPathXmlApplicationContext FileSystemXmlApplicationContext XmlWebApplicationContext Instantiating, ApplicationContext context = new FileSystemXmlApplicationContext(“c:\spring\beans.xml”); Application Context 32 July 27, 2008

33 Spring Framework Loading multiple contexts String[] ctxs = new String[] { “ctx1.xml”, “ctx2.xml” }; Loading hiererichal contexts ApplicationContext parent = new ClassPathXmlApplicationContext (“ctx1.xml”); ApplicationContext child = new FileSystemXmlApplicationContext(“ctx2.xml”, parent); Application Context – Multiple Context’s 33 July 27, 2008

34 Spring Framework Configuration can be done using, XML configuration files Java property files Programmatically using API Annotations Spring JavaConfig* Configuration Metadata 34 July 27, 2008

35 Spring Framework Bean definition contains the following attributes, id/name class scope: singleton/prototype/custom constructor arguments properties auto wiring mode dependency checking mode lazy-initialization mode initialization method destruction method and much more… Defining Bean 35July 27, 2008

36 Spring Framework A basic bean definition, Sample Bean Definition 36 July 27, 2008

37 Spring Framework The arcane way of XML, prop1 value1 Short-hand notation Defining Bean – short-circuit 37 July 27, 2008

38 Spring Framework Importing other resources inside another resource Separating Concerns 38July 27, 2008

39 Spring Framework In bean definition itself Using one name in the id attribute All other names using the “name” attribute separated by comma, semi-colon, white space Using the element Bean Aliases 39July 27, 2008

40 Spring Framework By default, all Spring beans are singletons Prototyped beans are useful when properties need to be set using Spring wiring In Spring 1.0, Bean Scopes 40 July 27, 2008

41 Spring Framework Scopes available, singleton prototype request session global session custom scope (since Spring 2.0+) Bean Scopes 41 July 27, 2008

42 Spring Framework Constructor Injection Hello World! Strong dependency contract No superfluous setter’s Dependent properties immutable Setter Injection Hello World! Prevents lengthy constructors Several ways to construct an object Multiple dependencies of same type Constructors pose a problem in case of inheritance 42 Constructor v/s Setter Injection July 27, 2008

43 Spring Framework Example public class Foo(Bar bar, Car car) { //… } Example public class Example(int years, String name) { //… } Constructor Argument Resolution 43July 27, 2008

44 Spring Framework Example Remember Can not reuse the inner-bean instance Useful when we want to escape AOP proxying. Inner Beans 44July 27, 2008

45 Spring Framework Four types of auto-wiring byName Find a bean whose name is same as the name of the property being wired. byType Find a single bean whose type matches the type of the property being wired. If more than one bean is found, UnsatisfiedDependencyException will be thrown. constructor Match one or more beans in the container with the parameters of one of the constructors of the bean being wired. autodetect Autowire by constructor first, then byType. Auto Wiring 45 July 27, 2008

46 Spring Framework By Name By Type Auto Wiring - Examples 46 July 27, 2008

47 Spring Framework Mixing auto and explicit wiring By-default wiring Can pose problems while refactoring if, Bean cannot be found Bean is not the one, the service actually wants Auto Wiring - Advanced 47 July 27, 2008

48 Spring Framework Four types of dependency checks, none Properties that have no value are not set. simple Performed for primitive types and collections, except collaborators. object Performed only for collaborators. all Performed for primitives, collections and colloborators. Dependency Check 48 July 27, 2008

49 Spring Framework Specifying By default lazy initialization …. // various bean definitions Lazy Initialization 49 July 27, 2008

50 Spring Framework Example public class Example { public void setup() { //init method } public void tearDown() { //destruction } //… } Custom init & destroy 50July 27, 2008

51 Spring Framework Using a static factory method Using an instance factory method Factory Beans 51July 27, 2008

52 Spring Framework Wiring lists, a list element Collections – java.util.List 52July 27, 2008

53 Spring Framework Wiring sets, a list element Collections – java.util.Set 53 July 27, 2008

54 Spring Framework Wiring maps, just some string some key Collections – java.util.Map 54 July 27, 2008

55 Spring Framework Wiring properties, sandeep Headstrong * The values of a map key, map value or a set key, can again be any of the following, bean | ref | idref | list | set | map | props | value | null Collections – java.util.Properties 55 July 27, 2008

56 Spring Framework Supported in Spring 2.0+ sandeep Headstrong Collections – Merging 56 July 27, 2008

57 Spring Framework Wiring null values Null Values 57July 27, 2008

58 Spring Framework Promotes reuse of bean instances, In parent-child context, Referencing Beans 58 July 27, 2008

59 Spring Framework Forces check at deployment time convert to, idref 59 July 27, 2008

60 Spring Framework Normal Spring metadata Converting to properties defined in a properties file, database.url=jdbc:hsqldb:myDatabase database.driver=org.hsqldb.jdbcDriver database.user=appUser database.password=appPass i18N & Spring 60July 27, 2008

61 Spring Framework Load the property file configurer i18N & Spring 61July 27, 2008

62 Spring Framework Penetration of OOP ;) Inherit properties, Overriding properties, Bean Inheritance 62 July 27, 2008

63 Spring Framework Created by implementing certain interfaces, and can be used to become involved in bean life-cycle load configuration from external property files alter Spring’s dependency injection to automatically convert String values to desired objects load text messages, say internationalized messages listen to and respond to events make beans aware of their identity inside Spring container Special Beans 63July 27, 2008

64 Spring Framework Events handled by ApplicationContext ContextClosedEvent ContextRefreshedEvent RequestHandledEvent To respond, beans must implement the ApplicationListener interface public class RefreshListener implements ApplicationListener { public void onApplicationEvent(ApplicationEvent event) { //… } Events 64July 27, 2008

65 Spring Framework Define an event public class MyEvent extends ApplicationEvent { private String str; public MyEvent(Object source, String anyParam) { super(source); this.str = anyParam; } public String getStr() { return this.str; } Raise the event ApplicationContext context = …; String param = //anything that we need to pass to the event; context.publishEvent(new MyEvent(this, param)); Raising custom Events 65July 27, 2008

66 Spring Framework Implement the interface, org.springframework.beans.factory.config.Scope Object get(String name, ObjectFactory objectFactory) Object remove(String name) void registerDestructionCallback(String name, Runnable destructionCallback) String getConversationId() Custom Scope 66 July 27, 2008

67 Spring Framework Usage, Custom Scope - gluing 67 July 27, 2008

68 Spring Framework 04 AOP in Detail 68July 27, 2008

69 Spring Framework Aspect Modularization of a concern/cross-cutting functionality Join Point Point during the execution of a program where an aspect is plugged in Advice Action taken at a particular Join Point Point Cut Set of Join Points specifying when an advice should be woven Introduction Adding new methods or fields to an existing class Target Class that is being advised Proxy Object created after applying advice Weaving Process of applying aspects to target object to create new proxy objects Can take place at several points during a class lifetime Compile Time: Requires special compiler. Classload Time RunTime AOP lingua-franca 69July 27, 2008

70 Spring Framework Spring advice is written in Java* It advises objects only at runtime If our class implements the required interface, proxies are generated using java.lang.reflect.Proxy class. Favored for results in more loosely coupled application. If it does not, it uses CGLIB to generate subclass proxies Implements AOP Alliance interfaces Resuable code with other compatible AOP frameworks Supports only method joinpoints Frameworks such as AspectJ, JBoss support field joinpoints too Spring & AOP 70July 27, 2008

71 Spring Framework Types of advice offered by Spring Before Called before the target method is invoked After (returning) Called after the invocation of the target method which returns normally. (After) Throws Called when target method throws an exception After (finally) * Called when target method is invoked, no matter how it returns. Around Intercepts calls to the target method Introduction Used to build composite objects Advice 71July 27, 2008

72 Spring Framework Implement the MethodBeforeAdvice public interface MethodBeforeAdvice { void before(Method method, Object[] args, Object target) throws Throwable } public class WelcomeAdvice implements MethodBeforeAdvice { public void before(Method method, Object[] args, Object target) throws Throwable { Customer cust = (Customer) args[0]; System.out.println(“Hello “ + cust.getName() ); } welcomeAdvice BeforeAdvice 72July 27, 2008

73 Spring Framework Implement the AfterReturningAdvice public interface AfterReturningAdvice { void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable } public class ThankYouAdvice implements AfterReturningAdvice { void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { System.out.println(“Thanks.“); } thankYouAdvice AfterAdvice 73July 27, 2008

74 Spring Framework Implement the ThrowsAdvice interface public interface ThrowsAdvice { void afterThrowing(Throwable throwable); void afterThrowing(Method method, Object[] args, Object target, Throwable throwable); } * Must implement atleast one method of the two signatures ThrowsAdvice 74July 27, 2008

75 Spring Framework Implement the MethodInterceptor interface Controls whether the actual target method is actually invoked Gives control over the return value public interface MethodInterceptor { public Object invoke(MethodInvocation invocation); } public class MyInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation invocation) { //do something before the method invocation Object returnValue = invocation.proceed(); //do something after the method invocation return someReturnValue; } AroundAdvice 75July 27, 2008

76 Spring Framework Implement the IntroductionInterceptor interface build composite objects, adding new methods/attributes to the advised class public class AuditableMixin implements IntroductionInterceptor, Auditable { public boolean implementsInterface(Class intf) { return intf.isAssignableFrom(Auditable.class); } public Object invoke(MethodInvocation m) throws Throwable { if (implementsInterface(m.getMethod().getDeclaringClass())) { return m.getMethod().invoke(this, m.getArguments()); } else { return m.proceed(); } private Date lastModifiedDate; public Date getLastModifiedDate() {.. } public void setLastModifiedDate(Date lastModifiedDate) { … } } Introductions 76July 27, 2008

77 Spring Framework Implement the PointCut interface public interface Pointcut { ClassFilter getClassFilter(); MethodMatcher getMethodMatcher(); } public interface ClassFilter { boolean matches(Class clazz); } public interface MethodMatcher { boolean matches(Method m, Class targetClass); boolean matches(Method m, Class targetClass, Object[] args); boolean isRuntime(); } PointCut 77July 27, 2008

78 Spring Framework NameMatchMethodPointcut RegexpMethodPointCut: Matches a Perl5 regex to a fully qualified method name.*\.get.*.*\.set.* PointCut Implementation 78July 27, 2008

79 Spring Framework Aspect’s as a combination of an Advice and a Pointcut. Each built in Advice has an Advisor Example Spring Advisors 79July 27, 2008

80 Spring Framework Enables Spring container to generate proxies for us Implemented using, BeanNameAutoProxyCreator: Apply aspect uniformly over a set of beans DefaultAdvisorAutoProxyCreator: Apply advisors uniformly over a set of beans Auto Proxy 80July 27, 2008

81 Spring Framework BeanNameAutoProxyCreator *Service *DAO Auto Proxy Examples 81July 27, 2008

82 Spring Framework DefaultAdvisorAutoProxyCreator Auto Proxy Examples 82July 27, 2008

83 Spring Framework 05 Bean Lifecycle 83July 27, 2008

84 Spring Framework In Bean Factory Container 84July 27, 2008

85 Spring Framework In Application Context 85July 27, 2008

86 Spring Framework Not applicable for web applications – hooks are already in place for Spring’s web-based ApplicationContext public static void main(String[] args) { AbstractApplicationContext ctx = new … // add a shutdown hook ctx.registerShutdownHook(); } Graceful Shutdown 86 July 27, 2008

87 Spring Framework Self Aware Beans – that handle the Spring container themselves, and may control the container’s behavior Three ways to make beans aware, BeanNameAware BeanFactoryAware ApplicationContextAware Knowing Who You Are 87 July 27, 2008

88 Spring Framework BeanNameAware public interface BeanNameAware { void setBeanName(String name); } BeanFactoryAware public interface BeanFactoryAware { void setBeanFactory(BeanFactory factory); } ApplicationContextAware public interface ApplicationContextAware { void setApplicationContext(ApplicationContext context); } Creating Self Aware Beans 88 July 27, 2008

89 Spring Framework 06 Extensibility 89 July 27, 2008

90 Spring Framework Mechanism for schema-based extensions to the base Spring XML format for definining and configuring beans Authoring an XML Schema Coding a custom NamespaceHandler implementation Coding one or more BeanDefinitionParser implementations Gluing the above into Spring Extensibility? 90 July 27, 2008

91 Spring Framework Element for SimpleDateFormat objects. analogous to, Extensibility Example 91 July 27, 2008

92 Spring Framework Authoring Schema 92 July 27, 2008

93 Spring Framework Helps parse all elements in the new namespace NamespaceHandler init() called before the handler is used BeanDefinition parse(Element, ParserContext) called when Spring encounters a top-level element BeanDefinitionHolder decorate(Node, BeanDefinitionHolder, ParserContext) called when Spring encounters an attribute or nested element of a different namespace Namespace Handler 93 July 27, 2008

94 Spring Framework NamespaceHandlerSupport package spring.xml; import org.springframework.beans.factory.xml.NamespaceHandlerSupport; public class MyNamespaceHandler extends NamespaceHandlerSupport { public void init() { registerBeanDefinitionParser("dateformat", new SimpleDateFormatBeanDefinitionParser()); } NamespaceHandler 94 July 27, 2008

95 Spring Framework public class SimpleDateFormatBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { protected Class getBeanClass(Element element) { return SimpleDateFormat.class; } protected void doParse(Element element, BeanDefinitionBuilder bean) { // this will never be null since the schema explicitly requires that a value be supplied String pattern = element.getAttribute("pattern"); bean.addConstructorArg(pattern); // this however is an optional property String lenient = element.getAttribute("lenient"); if (StringUtils.hasText(lenient)) { bean.addPropertyValue("lenient", Boolean.valueOf(lenient)); } Bean Definition Parser 95 July 27, 2008

96 Spring Framework Place the following property files in the META-INF directory in root spring.handlers mapping of XML schema URI to namespace handler classes http\:// =org.springframework.samples.xml.MyNamespaceHandler spring.schemas mapping of XML schema location to classpath resources http\:// =org/springframework/samples/xml/myns.xsd Register Handler/Parser 96 July 27, 2008

97 Spring Framework Usage 97 July 27, 2008

98 Spring The Beginning… 98 July 27, 2008

99 Spring Universe SpringSource Application Platform 99 Enterprise Bundle Repository Spring Dynamic Kernel Mode Real time server Updates Side-by-side Resource Versioning Run old & new applications Smaller server footpriint Inject Bundles at runtime Applications JARs Tomcat Spring Personalities Eclipse Equinox (OSGi) Logging SubsystemTracing SubsystemException Detection/Reporting 99July 27, 2008

100 Spring Universe Spring WebFlow Provides infrastructure for building and running RIA, builds over Spring MVC Spring Web Services Helps create document-driven Webservices, facilitates contract-first SOAP service deployment. Spring Security (aka Acegi) Security Solution for web applications – supports JSR 250 (EJB3), ACL, SiteMinder, CAS3, Portlets, Webflow, OpenID, Windows NTLM and more. Spring Dynamic Modules for OSGi Services Platform Helps build Spring applications that can run in an OSGi platform with better separation of modules. Spring Batch Framework for development of robust batch applications using POJOs. Other Spring Projects 100 July 27, 2008

101 Spring Universe Spring Integration An extension of Spring model to support Enterprise Integration Patterns. Spring LDAP Library for Java based LDAP operations based on Spring’s Template pattern. Spring IDE GUI for working with Spring configuration files over Eclipse. Spring Modules A collection of modules, add-ons and integration tools for Spring, like Ant, Flux, HiveMind, Lucene, O/R Broker, OSWorkflow, Tapestry, EHCache, OSCache, GigaSpaces, db4o, Drools, Jess, Groovy, Velocity, Jackrabbit, Jeceira and many many more… Spring Java Config Provides pure-Java, type-safe option for configuring Spring Contexts. Other Spring Projects 101 July 27, 2008

102 Spring Universe Spring BeanDoc Tool for documenting and graphing Spring bean factories and context files. Spring RCP Platform to construct rich Swing applications. Analogous to Eclipse RCP. Grid Gain* A grid-computing platform in Java which is a natural extension of development methodologies including annotations, Spring dependency injection, and AOP-based grid-enabling. Other Spring Projects 102 July 27, 2008

103 Other Framework’s Avalon Supports Service Locator & Interface Injection, but is intrusive. Google Guice All configuration is in Java, reduces a lot of boiler plate, and can be up to 50x faster than Spring. HiveMind Is more of a component based registry provider. PicoContainer & NanoContainer Very lightweight (~50kb) but supports only Singletons. EJB 3 (such as JBoss Seam) Is a standard and comes as a whole package. Naked Objects May be used in conjunction. Dependency Injection 103 July 27, 2008

104 Other Framework’s AspectJ Compile team weaving, supports field joinpoints. Spring 2.0+ complements AspectJ. Aspects not in Java JBoss AOP Comes with pre-packaged aspects such as caching, asynchronous communication, security, remoting… AspectWerkz Similar to AspectJ with Aspects written in Java. Object Teams A new entrant to AOP world, visits the concepts of Teams/Modules on a set of role objects. Dynaop Quite old, doesn’t offers much, but, is damn fast (up to 5x faster than Spring) For better comparison, visit AOP 104 July 27, 2008

105 Spring Framework References & Feedback 105July 27, 2008

106 Spring Framework Websites Books Spring In Action by Craig Walls and Ryan Breidenbach Spring j2ee Application Framework by Spring Development Team J2EE Without EJB by Rod Johnson and Juergen Holler Spring Live by Matt Raible References 106July 27, 2008

107 Spring Framework For any queries or suggestions, Post it on, Drop me a mail at, Questions/Feedback 107July 27, 2008

108 SANDEEP GUPTA Hope this helps. 108July 27, 2008 © 2008, under Creative Commons 3.0 Attribution License

Download ppt "SPRING FRAMEWORK Basics of 1July 27, 2008. Spring Framework Basics Introduction to IoC and AOP Spring Core AOP in Detail Bean Lifecycle Extensibility."

Similar presentations

Ads by Google