JBoss 4 with JBoss AOP V1.0
suding1 Dec 21, 2004 10:37 AMHello,
I am trying to use the AOP as follows, but it is not working for me. I would appreciate any advice.
My environment is:
JBoss 4
The Teller WebService example is working fine.
I want to print a notification whenever one of the TellerBean methods is working.
I deployed the AOP.
I added a file named: TestAOP-aop.xml to the
jboss-4.0.0\server\default\deploy\jboss-aop.deployer folder.
Its content is:
<aop> <aspect class="com.test.TestAspect" scope="PER_VM"/> <pointcut expr="execution(public java.lang.String[] com.jboss.ebank.TellerBean->getAccountsOfCustomer(java.lang.String))" name="getAccountsOfCustomer"/> <bind pointcut="getAccountsOfCustomer"> <advice aspect="com.test.TestAspect" name="trace1"/> </bind> <pointcut expr="execution(public com.jboss.ebank.TellerBean->new(..))" name="TellerBeanConst"/> <bind pointcut="TellerBeanConst"> <advice aspect="com.test.TestAspect" name="trace2"/> </bind> </aop>
I put a jar with the Aspect program at the
jboss-4.0.0\server\default\deploy folder. Its content is:
public class TestAspect { //Advice 1: Trace methods invocation public Object trace1(MethodInvocation invocation) throws Throwable { try { System.out.println("TestAspect: trace: START of "+invocation.getMethod()); return invocation.invokeNext(); } finally { System.out.println("TestAspect: trace: END of "+invocation.getMethod()); } } // Advice 2: Trace constructors invocation public Object trace2(ConstructorInvocation invocation) throws Throwable { try { System.out.println("TestAspect: trace: START of "+invocation.getConstructor()); return invocation.invokeNext(); } finally { System.out.println("TestAspect: trace: END of "+invocation.getConstructor()); } } }
I set the jboss-4.0.0\server\default\deploy\jboss-aop.deployer\META-INF\jboss-service.xml file to be:
<server> <mbean code="org.jboss.aop.deployment.AspectManagerService" name="jboss.aop:service=AspectManager"> <attribute name="EnableTransformer">true</attribute> <attribute name="SuppressTransformationErrors">true</attribute> <attribute name="Optimized">true</attribute> <attribute name="Verbose">true</attribute> </mbean> <mbean code="org.jboss.aop.deployment.AspectDeployer" name="jboss.aop:service=AspectDeployer"> </mbean> </server>
Thanks