Designer’s help guide to developing equipment above AJDT and AspectJ

These pages is meant to support people establishing knowledge to increase or use AJDT/AspectJ. Please contribute to these pages with any relevant suggestions, such as example signal with the AJDT and/or AspectJ APIs.

This site is out of time. The objective is always to upgrade these pages for AJDT 1.6.1, but we now have not have energy because of this yet. Kindly realize that a few of understanding about page might no much longer be appropriate. For those who have any questions, kindly submit these to the mailing list ajdt-dev.


  • 1 buying crosscutting commitment ideas from AJDT
  • 2 Compilation Units in AJDT
    • 2.1 having the items in an AJCompilationUnit
  • 3 Using the AspectJ AST parser
  • 4 recognized restrictions, bugs, and exceptional dilemmas
  • 5 The program apparatus are anticipated to make use of to operate a vehicle the AspectJ compiler

Obtaining crosscutting union info from AJDT

If you’re establishing an eclipse plug-in and need use of crosscutting info whenever a task is created, you’ll be able to sign up a listener with AJDT. The plug-in should be determined by org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Inside org.eclipse.ajdt.core plug-in there clearly was an IAdviceChangedListener screen with one adviceChanged() strategy.

Register this using the AJBuilder lessons like this (within plug-in’s start() way of example):

Presently (AJDT 1.6) this can be labeled as after each develop of an AspectJ task (for example. every *potential* suggestions modification). In the next production this might be optimized to-be only called if the suggestions has really changed. AJDT/UI makes use of this device to upgrade the tangerine arrow image decorator.

Crosscutting suggestions can then getting extracted from the AJProjectModelFacade class. Here is an example with a few pseudo-code possible adjust:

A number of notes relating to this:

  1. The API may have some minor changes in the long term. Please submit a message towards ajdt-dev email list if any such thing with this web page is beyond big date.
  2. The AJProjectModelFacade item try a lightweight entrances in to the AspectJ world. It is simply legitimate till the further develop. Very, you should not put them. Use them and dispose as needed.
  3. AJProjectModelFacade things merely include information following earliest effective create. Possible contact the hasModel() way to find out if an AspectJ unit is out there for all the project.
  4. Clearly, you get the partnership in information. Read AJRelationshipManager when it comes to complete directory of interactions, to simply ask for the relationship types you have in mind.
  5. IRelationship.getSourceHandle() and IRelationship.getobjectives() return chain that represent AspectJ aspect manages. You can make use of this amazing AJProjectModelFacade solutions to convert to model areas:
    • toProgramElement(String) — returns IProgramElement. From this point possible acquire information on the pointcut, intertype aspect, or declare factor.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — returns IJavaElement. From this point it is possible to connect into JDT tooling.
  6. There’s no criteria to register an information changed listener. You may get access to the crosscutting unit anytime (as long as your panels has had a successful create) making use of the next signal:

Compilation Dating Ranking net sugar baby USA Models in AJDT

JDT produces compilation devices (cases of ICompilationUnit) for .java documents. AJDT produces compilation devices for .aj documents, which have been cases of AJCompilationUnit (which implements ICompilationproduct). The class AJCompilationUnitManager (from inside the org.eclipse.ajdt.core plug-in) consists of some useful methods concerning this, such as for example:

From an AJCompilationUnit you are able to get different architectural suggestions such as for instance getAllTypes(). The principal sort for „.aj“ files is typically a piece, that is represented because of the AspectElement class, containing aspect-specific means for example getPointcuts() and getAdvice(). These return further aspect-specific elements instance PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we utilize the Eclipse weaving services to weave into JDT. One collection of join points that are directed are the ones related to the production of CompilationUnit items. In the event that file provides is *.aj file, AJCompilationUnit is generated versus a typical coffee collectionUnit.

Obtaining the belongings in an AJCompilationUnit

Because JDT wants that every resource it works with does work coffee laws, JDT can not work better with AspectJ. In order to get for this, AJCompilationUnits manage two buffers which contain provider materials. The very first is a java appropriate buffer plus the second may be the initial content material buffer. The coffee compatible buffer could be the buffer that will be returned automatically whenever AJCompilationUnit.getContents() is known as. This buffer provides the AspectJ rule with all aspect-specific syntax removed away. The original articles buffer includes (while you would anticipate) the first information associated with file.

Like in the event the initial content buffer seems like:

the coffee appropriate buffer is

Notice that the foundation locations associated with the identifiers are exactly the same both in buffers. This means that resource acquiring and hyperlinking work as you expected.

In the event that you need cooperating with the first content material of an AspectJ CompilationUnit ajproduct, can help you the immediate following:

What this technique really does wants the AJCU to briefly change the buffer on the AJ buffer through the Java buffer. It is best to try this in a synchronized block so you you should not risk some other threads coming by and accidentally making use of the incorrect buffer (AJDT it self doesn’t use a synchronized block because of this, nonetheless it should).

Utilizing the AspectJ AST parser

Simple instance, taken from insect 88861

Compile the above and work it:

Recognized restrictions, pests, and outstanding problems

Restriction: There is currently no AST service for resolving kind bindings: insect 146528