Creator’s guide to developing gear over AJDT and AspectJ

Creator’s guide to developing gear over AJDT and AspectJ

This site is intended to help any person developing methods to increase or work with AJDT/AspectJ. Be sure to contribute to these pages with any related records, such example rule utilizing the AJDT and/or AspectJ APIs.

This site is beyond date. Our purpose is to upgrade this site for AJDT 1.6.1, but we now have perhaps not had energy with this yet. Please recognize that a number of what’s with this web page might no lengthier feel appropriate. When you yourself have questions, kindly submit them to the mailing list ajdt-dev.

Articles

  • 1 Obtaining crosscutting partnership suggestions from AJDT
  • 2 Collection Products in AJDT
    • 2.1 Acquiring the items in an AJCompilationUnit
  • 3 with the AspectJ AST parser
  • 4 Known limitations, insects, and exceptional issues
  • 5 The program methods are required to make use of to drive the AspectJ compiler

Obtaining crosscutting commitment facts from AJDT

In case you are building an eclipse plug-in and call for usage of crosscutting suggestions whenever a project is built, you can easily enter a listener with AJDT. Your own plug-in should be determined by org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. For the org.eclipse.ajdt.core plug-in there can be an IAdviceChangedListener software with just one adviceChanged() technique.

Join this using AJBuilder lessons such as this (in your plug-in’s start() means for sample):

At this time (AJDT 1.6) that is labeled as after every acquire of an AspectJ job (i.e. every *potential* guidance changes). In the next production this may be enhanced getting best known as in the event that suggestions has really changed. AJDT/UI uses this device to upgrade the orange arrow picture decorator.

Crosscutting records can then become extracted from the AJProjectModelFacade class. Discover an example with some pseudo-code you can easily adjust:

Several records concerning this:

  1. The API may have some small alterations in the future. Be sure to deliver an email on ajdt-dev dating sites in nigeria email list if something on this page is out of day.
  2. The AJProjectModelFacade item are a light-weight entrances into the AspectJ globe. It can be good till the subsequent develop. So, don’t save all of them. Use them and dispose as required.
  3. AJProjectModelFacade stuff merely include information following very first successful create. It is possible to phone the hasModel() way to see if an AspectJ design exists for any venture.
  4. Perhaps you have realized, obtain the partnership both in directions. Discover AJRelationshipManager for full variety of interactions, so you’re able to only request the relationship types you are interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getgoals() return Strings that signify AspectJ component manages. You need these AJProjectModelFacade strategies to convert to model items:
    • toProgramElement(sequence) — profits IProgramElement. From this point it is possible to acquire information about the pointcut, intertype factor, or declare component.
    • programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From here you are able to connect into JDT tooling.
  6. There is no necessity to register a suggestions altered listener. You will get accessibility the crosscutting model anytime (if your panels has experienced an effective create) using the preceding laws:

Collection Products in AJDT

JDT creates collection products (instances of ICompilationdevice) for .java files. AJDT brings collection units for .aj files, which are instances of AJCompilationUnit (which implements ICompilationdevice). The class AJCompilationUnitManager (for the org.eclipse.ajdt.core plug-in) consists of some helpful strategies concerning this, like:

From an AJCompilationUnit you can easily get numerous structural information such as for example getAllTypes(). The main kind for “.aj” documents is normally an element, and is represented because of the AspectElement class, which contains aspect-specific techniques such as for instance getPointcuts() and getAdvice(). These return furthermore aspect-specific factors eg 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 guidelines that are instructed are those related to the production of CompilationUnit items. In the event the file provides are *.aj file, AJCompilationUnit is done as opposed to a regular Java CompilationUnit.

Obtaining the items in an AJCompilationUnit

Because JDT anticipates that all source it works with holds true Java rule, JDT can not work well with AspectJ. In order to get around this, AJCompilationUnits uphold two buffers containing source items. The very first is a java appropriate buffer therefore the second could be the original material buffer. The java compatible buffer will be the buffer definitely came back by default whenever AJCompilationUnit.getContents() is named. This buffer offers the AspectJ signal along with aspect-specific syntax removed aside. The first material buffer consists of (while you would count on) the original articles associated with the document.

Like in the event the earliest content material buffer looks like:

the coffee suitable buffer is

Realize that the origin locations on the identifiers are exactly the same in buffers. This makes sure that research acquiring and hyperlinking work as you expected.

If you call for employing the original contents of an AspectJ CompilationUnit ajproduct, you are able to do the annotated following:

Exactly what this method do wants the AJCU to briefly turn their buffer to your AJ buffer from the coffee buffer. It is advisable to do this in a synchronized block so that you never exposure various other threads coming by and accidentally utilizing the completely wrong buffer (AJDT itself does not need a synchronized block for this, but it should).

Utilizing the AspectJ AST parser

Fundamental sample, taken from bug 88861

Compile the aforementioned and work it:

Known restrictions, bugs, and exceptional problems

Limitation: You will find presently no AST service for solving means bindings: bug 146528

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *