Designer’s help guide to developing apparatus together with AJDT and AspectJ

This site is meant to support anybody creating hardware to give or utilize AJDT/AspectJ. Be sure to contribute to this page with any pertinent ideas, such example code making use of the AJDT and/or AspectJ APIs.

These pages is beyond go out. All of our intent is to revise this site for AJDT 1.6.1, but we’ve perhaps not got energy with this yet. Kindly keep in mind that the what exactly is on this subject webpage might no much longer feel proper. For those who have any queries, be sure to submit these to the subscriber list ajdt-dev.


  • 1 Obtaining crosscutting partnership details from AJDT
  • 2 Compilation Devices in AJDT
    • 2.1 Acquiring the contents of an AJCompilationUnit
  • 3 Using the AspectJ AST parser
  • 4 recognized restrictions, bugs, and exceptional dilemmas
  • 5 The software equipment are expected to use to operate a vehicle the AspectJ compiler

Obtaining crosscutting union information from AJDT

If you’re creating an eclipse plugin and call for the means to access crosscutting info whenever a task is built, you can easily enter a listener with AJDT. Your plug-in will have to be determined by 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 there is an IAdviceChangedListener user interface with one adviceChanged() way.

Register this utilizing the AJBuilder course along these lines (in your plug-in’s start() way for sample):

Currently (AJDT 1.6) this is called after each create of an AspectJ task (for example. every *potential* information modification). In another release this may be optimized to-be just also known as if the guidance features in fact altered. AJDT/UI makes use of this device to update the tangerine arrow graphics decorator.

Crosscutting facts can then end up being extracted from the AJProjectModelFacade course. Here is an illustration which includes pseudo-code you are able to adapt:

A number of records about this:

  1. The API have some small changes in the long run. Be sure to send an email to the ajdt-dev subscriber list if such a thing with this webpage is beyond time.
  2. The AJProjectModelFacade object is actually a light-weight entrance in to the AspectJ business. It can be legitimate before further develop. Thus, do not keep them. Make use of them and dispose as required.
  3. AJProjectModelFacade items only incorporate data following the earliest winning build. It is possible to contact the hasModel() way to see if an AspectJ model is out there for project.
  4. As you can plainly see, you receive the connection in both information. See AJRelationshipManager for your full a number of relations, so you can just ask for the connection sort you’re interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return Strings that express AspectJ factor handles. You need to use listed here AJProjectModelFacade methods to become model aspects:
    • toProgramElement(sequence) — comes back IProgramElement. From here possible receive information regarding the pointcut, intertype component, or declare element.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — returns IJavaElement. From here you’ll be able to catch into JDT tooling.
  6. There is no requirement to register a recommendations changed listener. You could get use of the crosscutting product anytime (assuming that the project has already established a successful develop) making use of the preceding signal:

Compilation Models in AJDT

JDT produces collection units (cases of ICompilationUnit) for .java records. AJDT produces compilation devices for .aj records, which have been cases of AJCompilationUnit (which implements ICompilationUnit). The course AJCompilationUnitManager (in org.eclipse.ajdt.core plug-in) has some beneficial methods concerning this, like:

From an AJCompilationUnit you are able to receive different architectural ideas such as for example getAllTypes(). The principal sort for „.aj” documents is normally an element, which can be symbolized by AspectElement class, containing aspect-specific means including getPointcuts() and getAdvice(). These return further aspect-specific details such as for instance PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving provider to incorporate into JDT. One pair of join things being encouraged are those about the creation of CompilationUnit things. If document has are *.aj document, AJCompilationUnit is established instead of a standard Java Compilationproduct.

Acquiring the contents of an AJCompilationUnit

Because JDT needs that every origin it functions with does work Java code, JDT can not work really with AspectJ. To get with this, AJCompilationUnits maintain two buffers that contain provider articles. The very first is a java compatible buffer together with 2nd will be the earliest information buffer. The coffee suitable buffer will be the buffer that will be returned by default when AJCompilationUnit.getContents() is known as. This buffer offers the AspectJ rule along with aspect-specific syntax stripped down. The original articles buffer have (because would anticipate) the first information in the file.

For instance if earliest material buffer appears to be:

the Java compatible buffer becomes

Observe that the origin areas in the identifiers are the same in buffers. This means that resource getting and hyperlinking works as you expected.

Should you require dealing with the original material of an AspectJ CompilationUnit ajdevice, can be done the immediate following:

What this method does requests the AJCU to temporarily turn their buffer into the AJ buffer from coffee buffer. It is advisable to do that in a synchronized block to make sure you never chance other threads dating sites for asian coming by and inadvertently by using the completely wrong buffer (AJDT by itself does not utilize a synchronized block for this, it should).

Utilizing the AspectJ AST parser

Important example, extracted from bug 88861

Gather the above mentioned and work they:

Identified limits, bugs, and exceptional problem

Limitation: there clearly was presently no AST assistance for solving means bindings: insect 146528