Ich hab mich gestern mal bisschen mit AspectJ beschäftigt und irgendwie schein ich noch nicht so ganz dahinter zu kommen.
Mal ein einfaches Beispiel. Nehmen wir an, ich hab folgenden Controller
und den Abschnitt in meinem Aspect
dann klappt das soweit.
Jetzt implementier ich mal das Interface im TestControllerImpl
Bei der Einstellung Standard-Einstellung proxy-target-class="false" kommt
und das mapping auf "test.do" klappt nichtmehr. Bei der proxy-target-class="true" ändert sich der output in
und das ganze scheint zu klappen. Was mache ich falsch, dass das bei der Standardeinstellung nicht klappt.
Mal ein einfaches Beispiel. Nehmen wir an, ich hab folgenden Controller
Code:
@Controller
public class TestControllerImpl {
@RequestMapping(value="/test.do")
@TestAnnotation
public String test(TestForm form, HttpServletRequest request) {
return "test";
}
}
und den Abschnitt in meinem Aspect
Code:
@Before(value = "testAnnotation() && args(form, request)")
public void beforeValidation(Object form, HttpServletRequest request) {
doSomething(form, request);
}
@Pointcut("@annotation(annotation.TestAnnotation)")
public void testAnnotation() {}
dann klappt das soweit.
Jetzt implementier ich mal das Interface im TestControllerImpl
Code:
public interface TestController {
public String test(TestForm form, HttpServletRequest request);
}
Bei der Einstellung Standard-Einstellung proxy-target-class="false" kommt
Code:
DEBUG - Creating shared instance of singleton bean 'testControllerImpl'
DEBUG - Creating instance of bean 'testControllerImpl'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Eagerly caching bean 'testControllerImpl' to allow for resolving potential circular references
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Creating implicit proxy for bean 'testControllerImpl' with 0 common interceptors and 2 specific interceptors
DEBUG - Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [de.pixelcasino.frontend.controller.TestControllerImpl@1890909]
DEBUG - Finished creating instance of bean 'testControllerImpl'
Code:
DEBUG - Creating shared instance of singleton bean 'testControllerImpl'
DEBUG - Creating instance of bean 'testControllerImpl'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Eagerly caching bean 'testControllerImpl' to allow for resolving potential circular references
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#0'
DEBUG - Returning cached instance of singleton bean 'org.springframework.flex.core.EndpointServiceMessagePointcutAdvisor#1'
DEBUG - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
DEBUG - Creating implicit proxy for bean 'testControllerImpl' with 0 common interceptors and 2 specific interceptors
DEBUG - Creating CGLIB2 proxy: target source is SingletonTargetSource for target object [de.pixelcasino.frontend.controller.TestControllerImpl@1d1f4fe]
DEBUG - Unable to apply any optimisations to advised method: public java.lang.String de.pixelcasino.frontend.controller.TestControllerImpl.test(javax.servlet.http.HttpSession,javax.servlet.http.HttpServletRequest)
DEBUG - Found finalize() method - using NO_OVERRIDE
DEBUG - Found 'hashCode' method: public native int java.lang.Object.hashCode()
DEBUG - Unable to apply any optimisations to advised method: protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException
DEBUG - Found 'equals' method: public boolean java.lang.Object.equals(java.lang.Object)
DEBUG - Unable to apply any optimisations to advised method: public java.lang.String java.lang.Object.toString()
DEBUG - Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.aopalliance.aop.Advice)
DEBUG - Method is declared on Advised interface: public abstract int org.springframework.aop.framework.Advised.indexOf(org.springframework.aop.Advisor)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isFrozen()
DEBUG - Method is declared on Advised interface: public abstract org.springframework.aop.TargetSource org.springframework.aop.framework.Advised.getTargetSource()
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvisor(int,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setTargetSource(org.springframework.aop.TargetSource)
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setPreFiltered(boolean)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isProxyTargetClass()
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.setExposeProxy(boolean)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isExposeProxy()
DEBUG - Method is declared on Advised interface: public abstract org.springframework.aop.Advisor[] org.springframework.aop.framework.Advised.getAdvisors()
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(int,org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.addAdvice(org.aopalliance.aop.Advice) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isPreFiltered()
DEBUG - Method is declared on Advised interface: public abstract java.lang.Class[] org.springframework.aop.framework.Advised.getProxiedInterfaces()
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.isInterfaceProxied(java.lang.Class)
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvisor(org.springframework.aop.Advisor)
DEBUG - Method is declared on Advised interface: public abstract void org.springframework.aop.framework.Advised.removeAdvisor(int) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.replaceAdvisor(org.springframework.aop.Advisor,org.springframework.aop.Advisor) throws org.springframework.aop.framework.AopConfigException
DEBUG - Method is declared on Advised interface: public abstract boolean org.springframework.aop.framework.Advised.removeAdvice(org.aopalliance.aop.Advice)
DEBUG - Method is declared on Advised interface: public abstract java.lang.String org.springframework.aop.framework.Advised.toProxyConfigString()
DEBUG - Method is declared on Advised interface: public abstract java.lang.Class org.springframework.aop.TargetClassAware.getTargetClass()
DEBUG - Finished creating instance of bean 'testControllerImpl'
Zuletzt bearbeitet: