Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] asm - advice relations

Yes, it is possible for you to get this information.  But not from extending
the hierarchy builder or AST visitor stuff, because advice mappings are not
known until the weaver runs.  These mappings get created by the
org.aspectj.weaver.AsmRelationshipProvider class, which depends on having
nodes to map back-and-forth between (these come from the hierarchy builder).

So it sounds like what you want to do is to ignore all that stuff, and just
to use your own AsmRelationshipProvider.  You can do that by subclassing the
standard one, and then setting your subclass to be the provider.  You can do
that simply by calling:

    AsmRelationshipProvider.setDefault(new MyInfoProvider());

An example of how this works is in: AsmRelationshipMapExtensionTest

But note that you are entering the world of shadows!  Quite
literally--you'll have to figure out how Shadows, Checkers, and Mungers
work.  The code in AsmRelationshipProvider should be a good starting point.

Mik

> -----Original Message-----
> From: aspectj-dev-bounces@xxxxxxxxxxx [mailto:aspectj-dev-
> bounces@xxxxxxxxxxx] On Behalf Of e3oginos X
> Sent: Thursday, June 30, 2005 3:34 PM
> To: aspectj-dev@xxxxxxxxxxx
> Subject: RE: [aspectj-dev] asm - advice relations
> 
> thanks for the reply
> I am already aware of the
> AsmManager.getDefault().getRelationshipMap().get(node);
> way, but because i intentionally never call any of the super methods or
> constructors from my extended AsmHierarchyBuilder, the RelationshipMap has
> nothing in it.  The reason i do not want to call the super methods and
> therefore build the default model, is because they are not of any use in
> the
> tool i am building and will only delay the process.
> Is there a way i can get which methods are advices by a particular aspect,
> preferably from the visit(MethodDeclaration) method ? (similar to how,
> which
> pointcut are used by a particular advices references are generated in the
> default AsmHierarchyBuilder)
> Or if not any other way, that i can get this without having to build the
> default model?
> 
> thanks
> 
> >From: "Mik Kersten" <beatmik@xxxxxxx>
> >Reply-To: AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>
> >To: "'AspectJ developer discussions'" <aspectj-dev@xxxxxxxxxxx>
> >Subject: RE: [aspectj-dev] asm  - advice relations
> >Date: Thu, 30 Jun 2005 10:25:38 -0700
> >
> >Try this:
> >- check out docs/sandbox/api-clients as a project
> >- run org.aspectj.samples/AsmRelationshipMapUsageTest
> >
> >You should see a bunch of "method.. advised by.." messages printed to the
> >console.  Now modify the test to run with your AsmHierarchyBuilder and
> see
> >if you still get the console output.  If you don't, you're using the
> >hierarchy builder in a way that prevents the AsmRelationshipProvider from
> >setting up the relationship map properly.  To address that your hierarchy
> >builder should ensure that it doesn't override the corresponding behavior
> >on
> >the AsmHierarchyBuilder super type.
> >
> >Mik
> >
> > > -----Original Message-----
> > > From: aspectj-dev-bounces@xxxxxxxxxxx [mailto:aspectj-dev-
> > > bounces@xxxxxxxxxxx] On Behalf Of e3oginos X
> > > Sent: Thursday, June 30, 2005 7:15 AM
> > > To: aspectj-dev@xxxxxxxxxxx
> > > Subject: [aspectj-dev] asm - advice relations
> > >
> > > hi
> > > i am implementing a project which registers its own
> AsmHierarchyBuilder,
> > > and builds its own model of the aspectj project without ever using the
> > > default AsmHierarchyBuilder.
> > > Everything works ok, but i cant seem to find a way to get the
> >relationship
> > > of which methods an aspect advices (like 'advices' in the
> >RelationshipMap)
> > > and which  aspect a method is adviced by (like 'is adviced by' in the
> > > RelationshipMap)
> > > i've seen how the 'uses pointcut' relationship is build from the
> default
> > > AsmHierarchyBuilder, but i cant seem to locate where the 'adviced by'
> > > relationship is generated in the ajdt source code.
> > >
> > > can someone tell me how i can get the 'adviced by/advices' relations
> > > without ever  using the RelationshipMap (since i am not using the
> >default
> > > asmhierarchybuilder) or point me to the source code that generates
> this
> > > relations?
> > >
> > > thanks
> > >
> > > _________________________________________________________________
> > > Express yourself instantly with MSN Messenger! Download today it's
> FREE!
> > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > >
> > > _______________________________________________
> > > aspectj-dev mailing list
> > > aspectj-dev@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> >
> >_______________________________________________
> >aspectj-dev mailing list
> >aspectj-dev@xxxxxxxxxxx
> >https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top