Creator’s help guide to design equipment above AJDT and AspectJ

Creator’s help guide to design equipment above AJDT and AspectJ

This site is intended to help people building knowledge to give or use AJDT/AspectJ. Be sure to play a role in this page with any related info, instance example signal by using the AJDT and/or AspectJ APIs.

This page is beyond go out. Our very own objective should modify this site for AJDT 1.6.1, but there is maybe not have times with this yet. Please keep in mind that some of what is with this web page may no lengthier getting proper. When you yourself have any queries, kindly send these to the mailing list ajdt-dev.


  • 1 getting crosscutting partnership records from AJDT
  • 2 Compilation Units in AJDT
    • 2.1 obtaining the belongings in an AJCompilationUnit
  • 3 by using the AspectJ AST parser
  • 4 Known limitations, pests, and exceptional problem
  • 5 The interface tools are required to make use of to operate a vehicle the AspectJ compiler

Obtaining crosscutting union information from AJDT

If you are building an eclipse plug-in and call for the means to access crosscutting details whenever a venture is built, you’ll 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. During the org.eclipse.ajdt.core plug-in there’s an IAdviceChangedListener interface with a single adviceChanged() means.

Sign-up this because of the AJBuilder lessons like this (in your plug-in’s start() method for sample):

At this time (AJDT 1.6) this really is labeled as after every acquire of an AspectJ job (for example. every *potential* suggestions change). In a future production this might be optimized is best called if the recommendations enjoys in fact changed. AJDT/UI uses this process to revise the lime arrow picture decorator.

Crosscutting details may then end up being obtained from the AJProjectModelFacade class. Here is an illustration with some pseudo-code you can adapt:

Several records about any of it:

  1. The API may have some minor changes in the near future. Please deliver a note on the ajdt-dev email list if something with this page is beyond date.
  2. The AJProjectModelFacade object are a light-weight entrances in to the AspectJ community. It is simply good up until the further build. Very, you shouldn’t shop all of them. Utilize them and dispose as needed.
  3. AJProjectModelFacade stuff only have facts after the earliest profitable create. Possible contact the hasModel() solution to see if an AspectJ design is out there your job.
  4. As you can plainly see, you get the relationship in both instructions. See AJRelationshipManager for any full set of interactions, so you can simply require the relationship kinds you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return chain that represent AspectJ element handles. You should use the next AJProjectModelFacade ways to convert to model areas:
    • toProgramElement(sequence) — returns IProgramElement. From here you can easily obtain details about the pointcut, intertype aspect, or declare element.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you can easily catch into JDT tooling.
  6. There is no requirement to join up a pointers changed listener. You will get accessibility the crosscutting product whenever you want (provided your panels has experienced a successful create) utilizing the next signal:

Collection Units in AJDT

JDT creates collection devices (instances of ICompilationUnit) for .java documents. AJDT produces collection products for .aj data, that are cases of AJCompilationUnit (which implements ICompilationdevice). The category AJCompilationUnitManager (within the org.eclipse.ajdt.core plug-in) contains some useful strategies concerning this, for example:

From an AJCompilationUnit you can obtain various architectural ideas such getAllTypes(). The principal type for “.aj” data files is typically an element, that is displayed from the AspectElement lessons, containing aspect-specific strategies such as for instance getPointcuts() and getAdvice(). These return furthermore aspect-specific factors instance PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving solution to weave into JDT. One set of join factors which can be urged are those regarding the development of CompilationUnit objects. If the document has was *.aj document, AJCompilationUnit is done in place of a general how does dabble work coffee CompilationUnit.

Acquiring the belongings in an AJCompilationUnit

Because JDT wants that every source it functions with holds true coffee signal, JDT can not work well with AspectJ. To get surrounding this, AJCompilationUnits maintain two buffers that contain provider information. The very first is a java compatible buffer as well as the second may be the initial content buffer. The java suitable buffer may be the buffer that is came back by default whenever AJCompilationUnit.getContents() is named. This buffer offers the AspectJ signal with all aspect-specific syntax stripped around. The original articles buffer have (while you would count on) the original articles of the file.

As an example if initial contents buffer seems like:

the Java compatible buffer is

Realize that the origin areas of identifiers are identical both in buffers. This ensures that resource researching and hyperlinking works as you expected.

If you require working with the original contents of an AspectJ CompilationUnit ajUnit, can help you the following:

Exactly what this technique really does asks for the AJCU to temporarily switch its buffer towards the AJ buffer from coffee buffer. It is best to do this in a synchronized block so you never chance various other posts coming by and accidentally using the completely wrong buffer (AJDT it self does not need a synchronized block because of this, but it should).

By using the AspectJ AST parser

Practical sample, obtained from insect 88861

Gather the above mentioned and work it:

Understood limits, bugs, and outstanding problems

Restriction: There is presently no AST support for fixing sort bindings: bug 146528

Leave a Reply

Your email address will not be published. Required fields are marked *