Designer’s guide to design methods above AJDT and AspectJ

Designer’s guide to design methods above AJDT and AspectJ

This site is intended to support anybody developing knowledge to increase or assist AJDT/AspectJ. Kindly subscribe to these pages with any appropriate details, eg example signal utilizing the AJDT and/or AspectJ APIs.

This page may be out of go out. Our intention would be to modify this site for AJDT 1.6.1, but there is maybe not had times for this yet. Kindly realize that a few of something with this web page might no longer become proper. When you yourself have any queries, please send them to the mailing list ajdt-dev.

Information

  • 1 getting crosscutting commitment information from AJDT
  • 2 Compilation Units in AJDT
    • 2.1 obtaining the belongings in an AJCompilationUnit
  • 3 with the AspectJ AST parser
  • 4 Known limits, bugs, and exceptional issues
  • 5 The interface equipment are anticipated to make use of to drive the AspectJ compiler

Getting crosscutting commitment facts from AJDT

In case you are building an eclipse plug-in and require the means to access crosscutting suggestions whenever a venture is created, possible register a listener with AJDT. Your plug-in will need to depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Inside the org.eclipse.ajdt.core plug-in you will find an IAdviceChangedListener screen with just one adviceChanged() system.

Register this making use of AJBuilder lessons like this (inside plug-in’s start() method for instance):

Presently (AJDT 1.6) it is labeled as after each and every acquire of an AspectJ project (in other words. every *potential* guidance change). In a future release this may be optimized as merely called when the suggestions keeps actually altered. AJDT/UI makes use of this apparatus to revise the tangerine arrow picture decorator.

Crosscutting facts can then end up being extracted from the AJProjectModelFacade class. Here’s an illustration which includes pseudo code it is possible to adjust:

A few notes about any of it:

  1. The API might have some lesser changes in the future. Please submit an email to your ajdt-dev email list if things about this webpage is beyond date.
  2. The AJProjectModelFacade item try a light-weight entrances into the AspectJ globe. It is simply appropriate up until the subsequent acquire. So, cannot store all of them. Utilize them and dispose as needed.
  3. AJProjectModelFacade things merely consist of facts following basic effective create. Possible phone the hasModel() way to find out if an AspectJ design is available for venture.
  4. As you can tell, obtain the connection in information. Read AJRelationshipManager for complete list of connections, to help you just request the partnership sort you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return chain that express AspectJ aspect handles. You can make use of listed here AJProjectModelFacade ways to convert to model elements:
    • toProgramElement(sequence) — returns IProgramElement. From here you can receive information about the pointcut, intertype factor, or declare aspect.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you’ll be able to catch into JDT tooling.
  6. There is absolutely no prerequisite to register an information changed listener. You can get use of the crosscutting design whenever you want (assuming that the project has experienced a fruitful build) utilizing the following signal:

Compilation Models in AJDT

JDT produces collection products (instances of ICompilationdevice) for .java files. AJDT creates compilation devices for .aj documents, which have been cases of AJCompilationUnit (which implements ICompilationproduct). The course AJCompilationUnitManager (within the org.eclipse.ajdt.core plug-in) includes some helpful methods relating to this, instance:

From an AJCompilationUnit you are able to obtain numerous architectural ideas such as for instance getAllTypes(). The primary sort for “.aj” files is typically an element, which can be displayed of the AspectElement lessons, containing aspect-specific practices including getPointcuts() and getAdvice(). These return furthermore aspect-specific areas eg PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we utilize the Eclipse weaving provider to weave into JDT. One collection of join points being directed are those linked to the creation of CompilationUnit objects. In the event the file provides try *.aj file, AJCompilationUnit is created as opposed to a regular coffee CompilationUnit.

Having the belongings in an AJCompilationUnit

Because JDT wants that every provider it works with holds true coffee laws, JDT does not work better with AspectJ. To get for this, AJCompilationUnits keep two buffers that contain provider articles. The very first is a java compatible buffer together with 2nd free chat dating sites could be the initial content buffer. The java suitable buffer is the buffer that’s came back automagically when AJCompilationUnit.getContents() is named. This buffer offers the AspectJ rule with all aspect-specific syntax stripped aside. The original material buffer have (just like you would anticipate) the original material regarding the document.

Like in the event the original content buffer seems like:

the coffee suitable buffer becomes

Observe that the origin areas of identifiers are identical in both buffers. This ensures that reference getting and hyperlinking works as expected.

In the event that you require working together with the original material of an AspectJ CompilationUnit ajdevice, can be done the annotated following:

Exactly what this process does wants the AJCU to briefly turn their buffer into AJ buffer from Java buffer. It is advisable to repeat this in a synchronized block so that you will do not risk other posts coming by and accidentally utilising the incorrect buffer (AJDT it self does not utilize a synchronized block for this, however it should).

Making use of the AspectJ AST parser

Important instance, obtained from bug 88861

Make the aforementioned and manage they:

Known limits, pests, and exceptional dilemmas

Constraint: There is presently no AST help for resolving sort bindings: bug 146528