Designer’s guide to constructing gear in addition to AJDT and AspectJ

These pages is meant to help any individual developing methods to extend or make use of AJDT/AspectJ. Be sure to subscribe to these pages with any relevant suggestions, such as sample laws utilizing the AJDT and/or AspectJ APIs.

This site is out of time. All of our purpose should upgrade this site for AJDT 1.6.1, but we’ve got not got opportunity because of this yet. Kindly realize that a number of understanding about webpage may no longer be proper. For those who have any queries, be sure to submit them to the subscriber list ajdt-dev.

Articles

  • 1 getting crosscutting partnership ideas from AJDT
  • 2 Compilation Devices in AJDT
    • 2.1 obtaining the belongings in an AJCompilationUnit
  • 3 with the AspectJ AST parser
  • 4 Known limits, bugs, and outstanding dilemmas
  • 5 The interface hardware are anticipated to utilize to drive the AspectJ compiler

Acquiring crosscutting relationship info from AJDT

If you’re developing an eclipse plug-in and need usage of crosscutting records whenever a task is built, you’ll be able to register a listener with AJDT. Your own 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. From inside the org.eclipse.ajdt.core plug-in there was an IAdviceChangedListener screen with just one adviceChanged() way.

Join this aided by the AJBuilder course such as this (in your plug-in’s start() method for instance):

Presently (AJDT 1.6) this really is known as after each acquire of an AspectJ venture (for example. every *potential* guidance change). In a future launch this might be optimized as just known as in the event the advice possess in fact changed. AJDT/UI utilizes this system to update the orange arrow image decorator.

Crosscutting information are able to feel extracted from the AJProjectModelFacade lessons. Listed here is a good example which includes pseudo-code you’ll be able to adapt:

A number of notes relating to this:

  1. The API have some lesser alterations in the long term. Please submit a note toward ajdt-dev subscriber list if any such thing on this page may be out of go out.
  2. The AJProjectModelFacade object was a light-weight entrance to the AspectJ industry. It can be good before subsequent build. Very, cannot keep them. Use them and dispose as needed.
  3. AJProjectModelFacade things just have data after the basic effective acquire. You are able to contact the hasModel() way to see if an AspectJ design is out there for all the job.
  4. Perhaps you have realized, you get the connection in instructions. Read AJRelationshipManager for all the complete directory of interactions, in order to only request the partnership sort you’re interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getgoals() return chain that signify AspectJ aspect handles. You should use the following AJProjectModelFacade ways to convert to model elements:
    • toProgramElement(sequence) — comes back IProgramElement. From this point you’ll be able to receive details about the pointcut, intertype aspect, or declare factor.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — returns IJavaElement. From this point you’ll hook into JDT tooling.
  6. There’s absolutely no needs to register a recommendations changed listener. You can acquire access to the crosscutting unit whenever you want (provided the project has received a successful acquire) making use of the next signal:

Compilation Units in AJDT

JDT produces compilation products (instances of ICompilationUnit) for .java files. AJDT produces compilation products for .aj records, which have been cases of AJCompilationUnit (which implements ICompilationdevice). The course AJCompilationUnitManager (inside org.eclipse.ajdt.core plug-in) have some useful means concerning this, particularly:

From an AJCompilationUnit you’ll be able to get various architectural sugar daddy com records like getAllTypes(). The principal sort for “.aj” data is typically a piece, and that’s displayed from the AspectElement class, which contains aspect-specific methods particularly getPointcuts() and getAdvice(). These return further aspect-specific areas such as for instance PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving service to weave into JDT. One set of join points which happen to be urged are those associated with the development of CompilationUnit stuff. In the event that document has actually was *.aj file, AJCompilationUnit is generated in place of a regular Java collectionproduct.

Having the contents of an AJCompilationUnit

Because JDT needs that most source it functions with is true coffee signal, JDT doesn’t work really with AspectJ. To get surrounding this, AJCompilationUnits maintain two buffers that contain provider articles. The very first is a java compatible buffer and the second may be the original information buffer. The java suitable buffer will be the buffer that is returned by default whenever AJCompilationUnit.getContents() is known as. This buffer provides the AspectJ rule along with aspect-specific syntax removed on. The initial information buffer have (just like you would anticipate) the original content associated with the document.

For instance if earliest content buffer seems like:

the coffee compatible buffer is

Realize that the foundation stores from the identifiers are the same both in buffers. This means that reference receiving and hyperlinking functions as expected.

Should you require employing the initial content material of an AspectJ CompilationUnit ajUnit, you can certainly do the following:

What this process do wants the AJCU to briefly turn the buffer to your AJ buffer through the Java buffer. It is best to do this in a synchronized block so that you will do not exposure more posts coming by and accidentally using the incorrect buffer (AJDT itself doesn’t utilize a synchronized block because of this, nevertheless should).

Using the AspectJ AST parser

Practical sample, taken from bug 88861

Make these and operated they:

Understood restrictions, insects, and outstanding problem

Limitation: there is certainly currently no AST service for resolving sort bindings: bug 146528


Leave a Reply

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

ACN: 613 134 375 ABN: 58 613 134 375 Privacy Policy | Code of Conduct