Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Using an introduced method from one apsect in another aspect

Hello everyone

Is it possible to use a method that gets introduced by static crosscutting in one aspect in another aspect?

Lets imagine an aspect Foo that introduces a method "void foo()". Can I now use this method foo() in another aspect that introduces other methds with static crosscutting?

public interface Foo {
}

public aspect FooAspect {
    public void Foo.foo() {
      // do something
    }
}

public aspect BarAspect {
    public void Bar.bar() {
        foo(); // How is it possible to call foo() here?
    }
}

public class MyEntity implements Foo {
}

MyEntity e = new MyEntity();
e.bar();


The background:
We are using Spring Data Neo4j (a.k.a SDN). This framework provides an aspect which introduces some methods and fields in entities that are annotated with @NodeEntity. We now would like to create our own aspects for our entities that in turn use the methods that are introduced by the SDN aspsect.
We'd like to have somthing like:

@NodeEntity
@ModelAEntity
public class FooEntity {
}

@NodeEntity
@ModelAEntity
@ModelBEntity
public class BarEntity {
}

@NodeEntity
@ModelBEntity
@ModelCEntity
public class BazEntity {
}

Where the Model(A|B|C)Entity aspects would introduce new methods that all need access to the methods introduced by @NodeEntity. Can this be achieved somehow?


Best regards,
James

Back to the top