Hi All,
All of the examples I have seen online show Spring advising objects which have been created through the Spring XML. Example:
Here we are advising specifically the "personTarget" class only.Code:<bean id="personTarget" class="com.mycompany.PersonImpl"> <property name="name"><value>Tony</value></property> <property name="age"><value>51</value></property> </bean> <bean id="person" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>com.mycompany.Person</value></property> <property name="target"><ref local="personTarget"/></property> <property name="interceptorNames"> <list> <value>myAdvisor</value> <value>debugInterceptor</value> </list> </property> </bean>
My question - can you easily advise objects which have been instantiated through Java, not Spring. Eg:
... and then a Spring definition which advises this code? I may not be making myself clear, but we have a large codebase and only a tiny fraction uses Spring IoC, but we want to advise on all of it.Code:public class PersonTarget { public void someMethod(){...} } ... PersonTarget person = new PersonTarget(); person.someMethod();
Thanks


Reply With Quote