I am afraid you posted your Java class twice, but the aspect not at all.
-- 
Alexander Kriegisch
http://scrum-master.de


> Am 07.09.2015 um 18:13 schrieb xeonmailinglist <[email protected]>:
> 
> Hi,
> 
> I am developing my first AspectJ example, and I want to call an Aspect method 
> before and after executing a method in another class. Let me give an example. 
> I have in [1] the main class that invokes the teste1() method. I want to 
> invoke the methods setup() and cleanup() in [2] when invoking teste1(). In 
> [3], I have my spring.xml.
> 
> This is example is not working, and I don’t understand why? Any help to 
> explain what am I doing wrong?
> 
> Thanks,
> 
> [1] My main class.
> 
> 
> package org.psc.spring;
> 
> public class MyMain {
>     public void teste1() {
>         int a = 1;
>         System.out.println("Var. a: " + a);
> 
>     }
>     public static void main(String[] args) {
>         MyMain main = new MyMain();
>         main.teste1();
>     }
> }
> [2] My AspectJ
> 
> 
> package org.psc.spring;
> 
> public class MyMain {
>     public void teste1() {
>         int a = 1;
>         System.out.println("Var. a: " + a);
> 
>     }
>     public static void main(String[] args) {
>         MyMain main = new MyMain();
>         main.teste1();
>     }
> }
> [3] My spring.xml
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xmlns:aop="http://www.springframework.org/schema/aop";
>        xmlns:context="http://www.springframework.org/schema/context";
> 
>        xsi:schemaLocation="
>             http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
>             http://www.springframework.org/schema/aop 
> http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
>             http://www.springframework.org/schema/context 
> http://www.springframework.org/schema/context/spring-context-3.1.xsd
>             http://www.springframework.org/schema/jee 
> http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
>             http://www.springframework.org/schema/oxm 
> http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd
>             http://www.springframework.org/schema/tx 
> http://www.springframework.org/schema/tx/spring-tx-3.1.xsd";>
> 
>     <bean id="myaop" class="org.psc.spring.MyAop"/>
> 
>     <aop:aspectj-autoproxy/>
>     <aop:config>
>         <aop:aspect id="teste1" ref="myaop">
>             <aop:pointcut id="setup" expression="execution(* teste1())"/>
>             <aop:after pointcut-ref="setup" method="setup"/>
>         </aop:aspect>
>     </aop:config>
> </beans>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe from 
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
aspectj-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to