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

An AbstractMethodError is usually a sign of a problem when weaving
(the ITDs used by Spring-Data are rather sophisticated).  If you can
raise a bugzilla I can take a look, a test app would really help too.

cheers
Andy

On 7 January 2012 06:55, Jean-Pierre Bergamin <jpbergamin@xxxxxxxxx> wrote:
> Hello again
>
> "this" has to be casted to NodeBacked so that "persist()" can be called.
> This is plausible, since we are introducing methods to classes that
> implement EnhancedPerson. And EnhancedPerson knows nothing about the
> NodeBacked interface and its methods:
>
> public aspect EnhancedPersonAspect {
> public void EnhancedPerson.saveMe() {
> ((NodeBacked)this).persist();
> }
> }
>
> I now tried to have the EnhancedPerson interface extend NodeBacked so that
> methods that are introduced to EnhancedPerson have direct access to methods
> of NodeBacked.
> When I do that, I get a java.lang.AbstractMethodError:
> java.lang.AbstractMethodError
> at
> org.springframework.data.neo4j.support.mapping.EntityStateHandler.getPersistentState(EntityStateHandler.java:82)
> at
> org.springframework.data.neo4j.support.mapping.Neo4jEntityPersister.getPersistentState(Neo4jEntityPersister.java:218)
>         ...
>
> I can't explain this exception. Is this maybe a bug in AspectJ? Other ideas
> how to achieve what I want?
>
>
> Best regards,
> James
>
>
> 2012/1/3 Jean-Pierre Bergamin <jpbergamin@xxxxxxxxx>
>>
>> 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
>>
>>
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top