Creator’s help guide to developing equipment over AJDT and AspectJ

Creator’s help guide to developing equipment over AJDT and AspectJ

These pages is meant to support individuals developing knowledge to give or utilize AJDT/AspectJ. Please subscribe to this site with any relevant records, particularly instance laws making use of the AJDT and/or AspectJ APIs.

This page may be out of date. The intention would be to revise these pages for AJDT 1.6.1, but we not had time because of this yet. Kindly understand that the what’s about webpage might no lengthier feel correct. For those who have any questions, please submit these to the email list ajdt-dev.

Articles

  • 1 buying crosscutting commitment information from AJDT
  • 2 Collection Units in AJDT
    • 2.1 Getting the contents of an AJCompilationUnit
  • 3 utilising the AspectJ AST parser
  • 4 recognized restrictions, bugs, and outstanding issues
  • 5 The software apparatus are anticipated to use to drive the AspectJ compiler

Getting crosscutting partnership facts from AJDT

If you find yourself building an eclipse plugin and require entry to crosscutting details whenever a venture is built, you can enroll a listener with AJDT. Their plug-in will need to depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. Inside org.eclipse.ajdt.core plug-in you will find an IAdviceChangedListener interface with one adviceChanged() system.

Register this using AJBuilder course like this (inside plug-in’s start() means for instance):

Presently (AJDT 1.6) this will be labeled as after each build of an AspectJ venture (for example. every *potential* guidance change). In a future release this may be enhanced become just known as in the event that recommendations has actually actually altered. AJDT/UI uses this mechanism to modify the lime arrow graphics decorator.

Crosscutting facts may then feel extracted from the AJProjectModelFacade course. Here is an example with many pseudo-code it is possible to adapt:

A number of records about any of it:

  1. The API could have some lesser changes in the near future. Please send a note to the ajdt-dev mailing list if anything about web page may be out of time.
  2. The AJProjectModelFacade item try a light-weight entry inside AspectJ globe. It is only valid through to the next develop. Thus, you should not store all of them. Use them and dispose as needed.
  3. AJProjectModelFacade items just consist of information after the basic winning build. You’ll call the possessModel() method to find out if an AspectJ product prevails when it comes down to venture.
  4. As you can see, you will get the partnership in guidelines. Discover AJRelationshipManager when it comes down to full directory of affairs, in order to simply request the connection kinds you’re interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getobjectives() return Strings that signify AspectJ component handles. You need to use the subsequent AJProjectModelFacade strategies to convert to model aspects:
    • toProgramElement(String) — comes back IProgramElement. From here it is possible to kupóny afroromance acquire information about the pointcut, intertype aspect, or declare element.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — returns IJavaElement. From here it is possible to connect into JDT tooling.
  6. There is no requirement to register a recommendations altered listener. You can get usage of the crosscutting product anytime (providing your panels has had a successful create) utilizing the next rule:

Collection Units in AJDT

JDT produces compilation models (instances of ICompilationUnit) for .java files. AJDT creates compilation devices for .aj data, that are instances of AJCompilationUnit (which implements ICompilationproduct). The class AJCompilationUnitManager (during the org.eclipse.ajdt.core plug-in) consists of some helpful practices concerning this, instance:

From an AJCompilationUnit you’ll acquire different architectural details for example getAllTypes(). The main sort for “.aj” data files is typically an element, which can be symbolized by the AspectElement class, which contains aspect-specific practices instance getPointcuts() and getAdvice(). These return further aspect-specific areas such as for example PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving provider to weave into JDT. One collection of join factors that are guided are those related to the creation of CompilationUnit stuff. If the file have are *.aj file, AJCompilationUnit is established instead of a standard coffee collectionproduct.

Obtaining the belongings in an AJCompilationUnit

Because JDT needs that most resource it works with does work coffee laws, JDT can not work really with AspectJ. To get around this, AJCompilationUnits maintain two buffers that have resource items. The first is a java suitable buffer together with 2nd is the initial content material buffer. The java appropriate buffer will be the buffer that is came back automatically when AJCompilationUnit.getContents() is called. This buffer offers the AspectJ laws with aspect-specific syntax stripped around. The original content material buffer includes (whilst would expect) the initial content of the file.

As an example when the initial material buffer seems like:

the coffee compatible buffer is

Notice that the source locations of the identifiers are the same in buffers. This helps to ensure that guide searching and hyperlinking work needlessly to say.

In the event that you need using the first information of an AspectJ CompilationUnit ajUnit, you can do the annotated following:

Just what this method really does requests for the AJCU to temporarily switch its buffer into the AJ buffer from coffee buffer. It is best to try this in a synchronized block so that you you shouldn’t exposure various other threads coming by and accidentally utilizing the wrong buffer (AJDT by itself does not need a synchronized block for this, but it should).

Utilizing the AspectJ AST parser

Fundamental sample, taken from insect 88861

Gather these and manage they:

Recognized limitations, pests, and outstanding dilemmas

Constraint: there clearly was presently no AST service for resolving means bindings: insect 146528

Post a comment