Designer’s guide to building knowledge over AJDT and AspectJ

Designer’s guide to building knowledge over AJDT and AspectJ

This site is intended to assist anybody building knowledge to extend or use AJDT/AspectJ. Please play a role in these pages with any appropriate facts, such sample signal utilizing the AJDT and/or AspectJ APIs.

This site may be out of date. Our intention will be update this page for AJDT 1.6.1, but we’ve maybe not had energy with this yet. Kindly keep in mind that a few of what is with this web page might no lengthier getting proper. When you have any queries, kindly send them to the email list ajdt-dev.

Information

  • 1 buying crosscutting commitment info from AJDT
  • 2 Compilation Models in AJDT
    • 2.1 having the belongings in an AJCompilationUnit
  • 3 Using the AspectJ AST parser
  • 4 Known limits, bugs, and outstanding issues
  • 5 The screen tools are anticipated to utilize to drive the AspectJ compiler

Obtaining crosscutting commitment info from AJDT

In case you are developing an eclipse plug-in and require accessibility crosscutting information whenever a task is made, it is possible to enroll a listener with AJDT. Your plug-in will need to be determined by org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Within the org.eclipse.ajdt.core plug-in there’s an IAdviceChangedListener software with a single adviceChanged() method.

Enter this making use of the AJBuilder class such as this (within plug-in’s start() way for example):

Presently (AJDT 1.6) it is labeled as after each and every acquire of an AspectJ project (i.e. every *potential* advice modification). In a future launch this might be optimized is merely known as when the pointers features actually altered. AJDT/UI uses this apparatus to revise the orange arrow picture decorator.

Crosscutting information are able to be obtained from the AJProjectModelFacade course. Discover an illustration which includes pseudo code you’ll adjust:

A few records concerning this:

  1. The API possess some minor alterations in tomorrow. Kindly submit an email into the ajdt-dev email list if everything with this web page may be out of go out.
  2. The AJProjectModelFacade object try a light-weight entrances in to the AspectJ globe. It is only legitimate up until the next acquire. So, you shouldn’t shop them. Utilize them and dispose as required.
  3. AJProjectModelFacade things merely consist of data following earliest winning develop. You’ll be able to phone the possessModel() method to find out if an AspectJ design exists for your task.
  4. Clearly, you obtain the partnership in directions. See AJRelationshipManager for any complete set of interactions, so you can merely inquire about the connection types you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getgoals() return chain that represent AspectJ factor handles. You are able to listed here AJProjectModelFacade strategies to convert to model aspects:
    • toProgramElement(sequence) — comes back IProgramElement. From here you can get information on the pointcut, intertype aspect, or declare factor.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — comes back IJavaElement. From this point possible catch into JDT tooling.
  6. There is no prerequisite to register an information changed listener. You can aquire accessibility the crosscutting design whenever you want (so long as the project has had a fruitful acquire) utilizing the preceding laws:

Collection Units in AJDT

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

From an AJCompilationUnit you are able to get different architectural information such getAllTypes(). The principal sort for “.aj” records is typically a piece, that will be symbolized of the AspectElement course, containing aspect-specific practices including getPointcuts() and getAdvice(). These return further aspect-specific factors such PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we use the Eclipse weaving services to weave into JDT. One set of join factors that are urged are the ones related to the development of CompilationUnit stuff. In the event that file keeps was *.aj file, AJCompilationUnit is made in the place of a typical Java Compilationdevice.

Obtaining the items in an AJCompilationUnit

Because JDT anticipates that every provider it works with does work Java laws, JDT does not work really with AspectJ. In order to get with this, AJCompilationUnits manage two buffers which contain provider items. The very first is a java compatible buffer plus the 2nd could be the original content buffer. The java compatible buffer may be the buffer that’s returned automatically whenever AJCompilationUnit.getContents() is called. This buffer provides the AspectJ rule with aspect-specific syntax removed down. The first content material buffer consists of (just like you would count on) the initial contents of the document.

Including in the event that earliest information buffer appears to be:

the Java appropriate buffer becomes

Realize that the origin places from the identifiers are identical in buffers. This means that research searching and hyperlinking work not surprisingly.

Should you decide need using the first material of an AspectJ CompilationUnit ajdevice, you could do the annotated following:

Just what this technique does requests the AJCU to temporarily switch their buffer into the AJ buffer through the Java buffer. hitwe app It’s always best to repeat this in a synchronized block so you do not exposure more posts coming by and accidentally utilizing the wrong buffer (AJDT by itself doesn’t incorporate a synchronized block because of this, however it should).

By using the AspectJ AST parser

Simple example, obtained from bug 88861

Gather the above and operate they:

Known limitations, pests, and outstanding issues

Constraint: there’s presently no AST service for resolving type bindings: bug 146528