Skip to main content

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

Hello everyone

I had no luck with this. I set up a small project to try it out: https://github.com/ractive/sdn-aspect
I'd like to have the aspect "EnhancedPersonAspect" [1] use the method "persist()" that is introduced by the Neo4jNodeBacking [2] aspect from the Spring Data Neo4j lib, but the persist() method is not found. Any hints how to call the persist() method in the  EnhancedPersonAspect?

[1] https://github.com/ractive/sdn-aspect/blob/master/src/main/java/com/example/aspect/domain/aspects/EnhancedPersonAspect.aj
[2] https://github.com/SpringSource/spring-data-neo4j/blob/master/spring-data-neo4j-aspects/src/main/java/org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj

Any ideas?


Best regards,
James


2011/12/22 Andy Clement <andrew.clement@xxxxxxxxx>
Hi,

That should work fine.  You either have to compile everything together
(using ajc) or two stage compile, first the aspects that introduce the
method you want to access from the other aspect (e.g. foo) then the
aspects that use it.

Let me know if you have trouble with it.

cheers,
Andy

On 22 December 2011 04:18, Jean-Pierre Bergamin <jpbergamin@xxxxxxxxx> wrote:
> 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
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top