Creator’s guide to developing hardware above AJDT and AspectJ

These pages is intended to support people developing resources to give or make use ilove of AJDT/AspectJ. Be sure to play a role in these pages with any appropriate details, such as for example instance rule utilising the AJDT and/or AspectJ APIs.

These pages is beyond day. Our very own intent would be to update this site for AJDT 1.6.1, but we’ve got not got times for this yet. Be sure to realize that a number of what exactly is on this subject webpage may no longer be appropriate. When you have any queries, please submit them to the email list ajdt-dev.

Articles

  • 1 buying crosscutting partnership records from AJDT
  • 2 Collection Models in AJDT
    • 2.1 obtaining items in an AJCompilationUnit
  • 3 utilizing the AspectJ AST parser
  • 4 Known limits, pests, and outstanding problem
  • 5 The interface equipment are required to make use of to get the AspectJ compiler

Getting crosscutting partnership suggestions from AJDT

If you are building an eclipse plugin and call for entry to crosscutting information whenever a venture is made, it is possible to enroll a listener with AJDT. Your plug-in should be determined by org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. During the org.eclipse.ajdt.core plug-in there’s an IAdviceChangedListener interface with an individual adviceChanged() strategy.

Enroll this aided by the AJBuilder lessons in this way (in your plug-in’s start() means for sample):

Presently (AJDT 1.6) this will be known as after each and every create of an AspectJ project (for example. every *potential* suggestions modification). In another production this can be enhanced are just called if the information features really altered. AJDT/UI makes use of this process to update the lime arrow graphics decorator.

Crosscutting details can then end up being extracted from the AJProjectModelFacade course. Discover a good example which includes pseudo code you are able to adapt:

A number of records concerning this:

  1. The API have some small changes in the long term. Please deliver an email into ajdt-dev email list if something on this subject page is beyond day.
  2. The AJProjectModelFacade object try a lightweight entry to the AspectJ business. It is simply legitimate until the after that develop. Therefore, don’t put all of them. Make use of them and dispose as required.
  3. AJProjectModelFacade things best consist of facts after the earliest winning create. You can contact the possessModel() way to see if an AspectJ model prevails for all the job.
  4. Perhaps you have realized, you can get the partnership in directions. See AJRelationshipManager when it comes to full listing of interactions, to only request the relationship types you’re interested in.
  5. IRelationship.getSourceHandle() and IRelationship.getgoals() return Strings that represent AspectJ element manages. You should use this amazing AJProjectModelFacade solutions to become model factors:
    • toProgramElement(sequence) — profits IProgramElement. From this point you can receive information about the pointcut, intertype factor, or declare element.
    • programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From this point possible catch into JDT tooling.
  6. There’s absolutely no criteria to join up an advice changed listener. You can aquire the means to access the crosscutting design whenever you want (provided the project has received a fruitful build) utilizing the next signal:

Collection Models in AJDT

JDT creates collection units (cases of ICompilationUnit) for .java files. AJDT brings compilation models for .aj data, which have been instances of AJCompilationUnit (which implements ICompilationdevice). The category AJCompilationUnitManager (into the org.eclipse.ajdt.core plug-in) has some useful means relating to this, eg:

From an AJCompilationUnit possible acquire different structural details such as for example getAllTypes(). The main sort for «.aj» records is typically an element, that will be symbolized because of the AspectElement lessons, containing aspect-specific practices such as getPointcuts() and getAdvice(). These return further aspect-specific characteristics such as PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we use the Eclipse weaving services to weave into JDT. One collection of join details which happen to be informed are the ones pertaining to the development of CompilationUnit things. In the event the document have is actually *.aj document, AJCompilationUnit is generated in place of a regular coffee Compilationdevice.

Getting the items in an AJCompilationUnit

Because JDT anticipates that every source it functions with does work coffee laws, JDT can not work well with AspectJ. To get surrounding this, AJCompilationUnits uphold two buffers containing supply information. The first is a java suitable buffer while the second may be the original contents buffer. The coffee appropriate buffer will be the buffer definitely came back automatically whenever AJCompilationUnit.getContents() is known as. This buffer provides the AspectJ rule with aspect-specific syntax removed completely. The first information buffer consists of (when you would expect) the initial material for the document.

Including in the event that initial information buffer seems like:

the Java compatible buffer is

Observe that the origin places of this identifiers are the same both in buffers. This ensures that reference researching and hyperlinking functions as you expected.

Should you decide require working with the original contents of an AspectJ CompilationUnit ajUnit, you can do the immediate following:

Just what this method do requests for the AJCU to temporarily turn its buffer to the AJ buffer through the Java buffer. It is best to try this in a synchronized block so you do not risk additional posts coming by and accidentally making use of the incorrect buffer (AJDT itself doesn’t utilize a synchronized block with this, but it should).

Utilising the AspectJ AST parser

Simple instance, extracted from insect 88861

Gather the above mentioned and manage they:

Recognized limitations, pests, and exceptional issues

Constraint: There is currently no AST assistance for fixing sort bindings: insect 146528


Artículos Relacionados