Designer’s help guide to developing technology over AJDT and AspectJ

Designer’s help guide to developing technology over AJDT and AspectJ

These pages is meant to aid anyone creating apparatus to extend or utilize AJDT/AspectJ. Be sure to play a role in these pages with any relevant information, eg sample code making use of the AJDT and/or AspectJ APIs.

These pages is out of day. Our very own intent is update this site for AJDT 1.6.1, but we’ve got not have time for this yet. Please understand that the something with this page might no lengthier getting proper. For those who have questions, please submit them to the mailing list ajdt-dev.

Contents

  • 1 getting crosscutting union ideas from AJDT
  • 2 Compilation Devices in AJDT
    • 2.1 obtaining the contents of an AJCompilationUnit
  • 3 with the AspectJ AST parser
  • 4 recognized limits, insects, and exceptional problem
  • 5 The software equipment are anticipated to make use of to drive the AspectJ compiler

Getting crosscutting partnership information from AJDT

In case you are building an eclipse plugin and require access to crosscutting ideas whenever a project is built, you’ll 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. From inside the org.eclipse.ajdt.core plug-in there is an IAdviceChangedListener software with a single adviceChanged() system.

Sign-up this utilizing the AJBuilder course similar to this (in your plug-in’s start() means for sample):

At this time (AJDT 1.6) this is called after every create of an AspectJ job (for example. every *potential* recommendations changes). In another release this may be enhanced is just called if the suggestions possess in fact changed. AJDT/UI utilizes this apparatus to update the orange arrow image decorator.

Crosscutting facts are able to feel obtained from the AJProjectModelFacade class. Discover a good example with many pseudo code you’ll adjust:

A few records relating to this:

  1. The API could have some slight changes in tomorrow. Please send a note towards the ajdt-dev mailing list if everything with this page may be out of date.
  2. The AJProjectModelFacade object is a light entrances inside AspectJ globe. It is only good till the then create. Very, never shop them. Use them and dispose as needed.
  3. AJProjectModelFacade items merely incorporate information following very first effective build. You can contact the possessModel() approach to find out if an AspectJ model exists for the venture.
  4. As you can see, you receive the relationship in both directions. Discover AJRelationshipManager for the complete selection of affairs, to merely require the relationship type you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return Strings that signify AspectJ element manages. You are able to listed here AJProjectModelFacade techniques to become model details:
    • toProgramElement(String) — profits IProgramElement. From here you’ll be able to dating sites for older men get information regarding the pointcut, intertype factor, or declare element.
    • programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From this point you are able to hook into JDT tooling.
  6. There’s absolutely no prerequisite to join up an advice changed listener. You may get the means to access the crosscutting design whenever you want (assuming that your panels has already established a fruitful create) utilising the preceding signal:

Compilation Devices in AJDT

JDT creates compilation units (instances of ICompilationdevice) for .java documents. AJDT produces collection products for .aj documents, which have been cases of AJCompilationUnit (which implements ICompilationUnit). The class AJCompilationUnitManager (when you look at the org.eclipse.ajdt.core plug-in) consists of some of use methods concerning this, like:

From an AJCompilationUnit you are able to obtain various architectural information including getAllTypes(). The principal sort for “.aj” records is usually an aspect, basically symbolized because of the AspectElement class, containing aspect-specific means such getPointcuts() and getAdvice(). These return further aspect-specific items eg PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we utilize the Eclipse weaving solution to weave into JDT. One collection of join guidelines which happen to be recommended are those related to the creation of CompilationUnit stuff. In the event that document have was *.aj file, AJCompilationUnit is done rather than a typical coffee collectionproduct.

Obtaining the contents of an AJCompilationUnit

Because JDT expects that resource it truly does work with does work coffee rule, JDT can not work really with AspectJ. In order to get surrounding this, AJCompilationUnits keep two buffers that have resource items. The very first is a java suitable buffer additionally the 2nd will be the original material buffer. The coffee appropriate buffer is the buffer this is certainly returned automagically whenever AJCompilationUnit.getContents() is called. This buffer contains the AspectJ laws along with aspect-specific syntax removed completely. The initial material buffer has (whenever would expect) the initial material with the document.

Like when the original contents buffer seems like:

the coffee appropriate buffer becomes

Notice that the foundation locations of the identifiers are exactly the same in buffers. This makes sure that reference getting and hyperlinking functions not surprisingly.

In the event that you require cooperating with the first content of an AspectJ CompilationUnit ajproduct, you certainly can do the annotated following:

What this technique really does requests for the AJCU to temporarily switch its buffer towards the AJ buffer through the coffee buffer. It’s always best to do this in a synchronized block so that you do not risk different posts coming by and inadvertently utilising the incorrect buffer (AJDT it self doesn’t need a synchronized block for this, but it should).

Utilizing the AspectJ AST parser

Practical example, taken from insect 88861

Compile these and run they:

Identified restrictions, pests, and exceptional dilemmas

Constraint: there clearly was at this time no AST help for solving sort bindings: insect 146528

Leave a Reply

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