Archive for the ‘aop’ Category
Tuesday, May 29th, 2007
Spring-AOP is implemented by creating proxies decorating the target bean. One typical gotcha from using these proxies, for instance, in declarative transaction management, is the proxy can’t intercept a call made from one method to another on the same target object (typically a service bean), even though both methods are supposed to be wrapped by the proxy. more…
Posted in aop, java, spring | 2 Comments »
Sunday, May 7th, 2006
Spring 2.0 supports injecting beans into an arbitrary POJO, which isn’t necessarily instantiated by a Spring bean factory. This powerful feature is mostly used in injecting into domain objects whose life cycle is usually managed by ORM tools such as Hibernate. But we don’t have to stop here, e.g., JSP tags can also be injected the same way. Here’s how: more…
Posted in aop, java, spring | 6 Comments »
Monday, February 6th, 2006
Spring 2.0 has an exciting new feature that, with AspectJ’s powerful AOP support, allows arbitrary domain objects to be injected with dependencies at the time of creation, even when the domain object is not created by Spring. This feature helps developers avoiding the “Anemic Domain Model” because now domain objects can have references to services or even DAO’s, instead of just some other domain objects. more…
Posted in aop, hibernate, java, spring | 2 Comments »
Tuesday, June 7th, 2005
There is an ongoing discussion on the Spring forums around DAO Reference Inside an Entity Domain Object?. Putting aside the debate on whether the idea is sensible from a design perspective, a practical issue in implementing this approach is that, in a sophisticated application, domain objects, unlike those stateless business service objects or DAOs, are usually instantiated by the data access layer, e.g., an ORM tool such as Hibernate. Therefore it’s usually hard to inject dependencies into these domain objects through Spring. In this forum post, Rod Johnson and other guys described a way to inject into domain objects by handling Hibernate object lifecycle events, but as of Spring 1.2, the actually implementation is still in the Sandbox. In this blog entry, I will describe another AOP-based approach that “virtually” injects a DAO reference (or any other Spring bean in general) into a domain object. more…
Posted in aop, java, spring | No Comments »
Monday, June 6th, 2005
Jonas Bonér devised a clever way to spring-manage aspects in his blog Spring and AspectWerkz – A Happy Marriage. The only drawback in his approach is that the bean factory managing the aspects must be called a certain name, and be created by the SpringAspectContainer, which limits the usability because in many cases (e.g. in a Spring MVC powered Web application) contexts might have to be instantiated somewhere else. So as the first application of the AppContextCollector I described in Global References To ApplicationContext(s) Unintrusively, SpringBeanAspectContainer provides an alternative, unintrusive way to manage aspects in Spring. more…
Posted in aop, java, spring | No Comments »
Sunday, April 24th, 2005
This below is done with aspectwerkz 2.0 in Tomcat 5.5.7.
I have a web app, which I offline-wove with the aspectwerkzc ant task. When I deploy the web app to tomcat (in exploded format), the same aop.xml is copied to WEB-INF/aop.xml. Then when I try to run the web app, none of the aspects would kick in. But if I go to the deployed web app directory, create an empty directory WEB-INF/classes (note that the aop.xml is still under WEB-INF), restart the server, and try to access the web app again, everything works fine.
After a few email exchange with Alexandru Popescu from the Aspectwerkz team, it appears that “WEB-INF/aop.xml would only work in tomcat.” So I moved the file to WEB-INF/classes/META-INF/aop.xml. Now everything works fine.
Posted in aop, java | No Comments »