Posts

Showing posts from March, 2013

Spring 3 part 6: Spring AOP

Image
This is the 6th part of the Spring 3 Series . AOP Concepts Joinpoint : Joinpoint is the point in an application at which additional logic can be inserted. For example method invocation that is the only Spring support joinpoint type. Advice : Advice is executed at a particular joinpoint in an application. NOTE: no advices for final classes. All the advisors need to implement the Advisor interface. There are two kind of advisors available in the Spring: IntrodcutionAdvisor and PointcutAdvisor. Spring defines 6 difference advices: before(MethodBeforeAdvice),  after returning (AfterReturningAdvice), after(AfterAdvice), around (MethodInterceptor), Throws (ThrowsAdvice), and Introduction (IntroductionInterceptor). Pointcuts : A pointcut is a collection of joinpoints that define when advice should be executed. For example, collection of all method invocations in a particular class. Aspect : An aspect is the combination of advice and pointcuts. This combination immerge the l

Spring 3 Part 5: Factory Beans

Image
This is the 5th part of the Spring 3 Series . This is the solution to create instances which are not possible to crate via “new” operator. It is very important to note that, Spring creates transactional proxies using this method. Most of the time lazy initialization is the tactic of delaying the creation of object. Singleton Pattern is the way to lazy initialization, in turn Factory patterns (both Abstract Factory and Factory Method ) are the way to inject an lazy instance to the Spring. Use the factory method to get an instance Use the lazy initialization to delay instantiation until first time request Store the instance for future delivery when request Inject the instance using Spring Factory Bean Here the class diagram for the example I am going to explain As shown in the class diagram, there are two concrete classes BlackDuck and ReadHeadDuck for the Duck (that is interface). Here the BlackDuck package com.blogspot.ojitha.spring3.part5.example.factory