JBoss Community

The reuse&&JBoss AOP

created by loupi loupi in JBoss AOP - View the full discussion

Hello,

First, i really need someone to answer me, because I have many questions, but in this forum only a few people answer

 

Question N=°1 how JBoss AOP defines an abstract aspect? and how it makes the reuse?(example in AspectJ we find Abstarct aspect)

 

Question N=°2 how can we access to variable with the mixin mechanism?because I followed your example

 

MixIN example

package Fooo;

public class Foo {

      public int fooField;

      public Foo () {

        fooField = 0;

      }

 

      public String fooMethod (int i) {

        return Integer.toString (fooField + i);

      }

    }

package Fooo;

public interface FooMixinInt {

      public String fooMethod2 (int i);

    }

package Fooo;

public class FooMixin implements FooMixinInt {

 

      public String fooMethod2 (int i) {

       return Integer.toString (fooField - i);

 

      }

    }

package Fooo;

public class Main {

 

    public static void main(String[] args) {

        // TODO Auto-generated method stub

        Foo foo = new Foo ();

        FooMixinInt fooint = (FooMixinInt) foo;

        String s = fooint.fooMethod2 (-2);

 

    }

 

}

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<aop>
    <introduction class="Fooo.Foo">
        <mixin>
            <interfaces>Fooo.FooMixinInt</interfaces>
            <class>Fooo.FooMixin</class>
            <construction>new Fooo.FooMixin()</construction>
        </mixin>
    </introduction>  
</aop>

 

and I often find this error:

 

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    fooField cannot be resolved

 

    at Fooo.FooMixin.fooMethod2(FooMixin.java:6)

    at Fooo.Foo.Fooo$Foo$fooMethod2$aop(Foo.java)

    at Fooo.Foo$FooAdvisor.fooMethod24106554489332185313(Foo$FooAdvisor.java)

    at Fooo.Foo.fooMethod2(Foo.java)

    at Fooo.Main.main(Main.java:12)

 

 

Thank you :)

Reply to this message by going to Community

Start a new discussion in JBoss AOP at Community