Developer’s self-help guide to building knowledge together with AJDT and AspectJ

Developer’s self-help guide to building knowledge together with AJDT and AspectJ

This page is meant to support any person establishing equipment to give or work with AJDT/AspectJ. Kindly play a role in this site with any related records, such as for example instance laws by using the AJDT and/or AspectJ APIs.

This site is beyond day. The intention is jackd hookup upgrade this page for AJDT 1.6.1, but we now have not had opportunity because of this yet. Be sure to recognize that the what is about this page might no longer end up being appropriate. For those who have any questions, be sure to deliver them to the email list ajdt-dev.


  • 1 getting crosscutting union records from AJDT
  • 2 Collection Models in AJDT
    • 2.1 obtaining the items in an AJCompilationUnit
  • 3 with the AspectJ AST parser
  • 4 Known restrictions, bugs, and outstanding dilemmas
  • 5 The screen knowledge are anticipated to make use of to operate a vehicle the AspectJ compiler

Obtaining crosscutting relationship ideas from AJDT

If you find yourself creating an eclipse plug-in and require access to crosscutting information whenever a job is built, you’ll be able to enroll a listener with AJDT. Your own plug-in should depend on org.eclipse.ajdt.core, org.eclipse.core.resources and org.eclipse.jdt.core, and org.aspectj.weaver. In org.eclipse.ajdt.core plug-in you will find an IAdviceChangedListener program with a single adviceChanged() system.

Enter this with all the AJBuilder lessons like this (inside plug-in’s start() means for sample):

Presently (AJDT 1.6) this might be labeled as after each build of an AspectJ project (for example. every *potential* information modification). In another launch this might be optimized getting only labeled as if the recommendations provides in fact altered. AJDT/UI utilizes this device to modify the orange arrow picture decorator.

Crosscutting records may then feel extracted from the AJProjectModelFacade course. Discover an illustration with a few pseudo code you are able to adapt:

A few notes relating to this:

  1. The API possess some lesser changes in the long term. Please submit a note on the ajdt-dev mailing list if things about web page may be out of date.
  2. The AJProjectModelFacade object is a light-weight entrance to the AspectJ community. It is simply good before the after that develop. Very, don’t shop all of them. Utilize them and dispose as needed.
  3. AJProjectModelFacade items merely consist of facts after the very first profitable develop. It is possible to contact the possessModel() way to see if an AspectJ model is present the venture.
  4. As you can see, you will get the connection in instructions. Read AJRelationshipManager when it comes down to full listing of connections, to merely require the connection kinds you have in mind.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return chain that represent AspectJ component handles. You can use listed here AJProjectModelFacade ways to become model characteristics:
    • toProgramElement(sequence) — profits IProgramElement. From here you are able to receive information regarding the pointcut, intertype component, or declare component.
    • programElementToJavaElement(String) or programElementToJavaElement(IProgramElement) — comes back IJavaElement. From here it is possible to connect into JDT tooling.
  6. There is absolutely no requirement to join up a pointers altered listener. You will get access to the crosscutting unit anytime (providing the project has already established an effective acquire) utilising the next code:

Collection Units in AJDT

JDT creates collection units (instances of ICompilationproduct) for .java records. AJDT brings collection products for .aj data, which are cases of AJCompilationUnit (which implements ICompilationproduct). The course AJCompilationUnitManager (in org.eclipse.ajdt.core plug-in) has some helpful practices relating to this, such:

From an AJCompilationUnit you can acquire various architectural facts for example getAllTypes(). The principal type for “.aj” documents is usually an aspect, basically displayed because of the AspectElement class, which contains aspect-specific strategies eg getPointcuts() and getAdvice(). These return furthermore aspect-specific characteristics instance PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving service to incorporate into JDT. One group of join details which are urged are those connected with the development of CompilationUnit things. If the document provides try *.aj file, AJCompilationUnit is created versus a regular Java collectionUnit.

Having the contents of an AJCompilationUnit

Because JDT needs that all resource it really works with holds true coffee signal, JDT can not work well with AspectJ. To get surrounding this, AJCompilationUnits preserve two buffers which contain resource contents. The very first is a java compatible buffer as well as the 2nd could be the initial contents buffer. The java compatible buffer could be the buffer definitely returned by default when AJCompilationUnit.getContents() is named. This buffer provides the AspectJ signal with aspect-specific syntax stripped . The original information buffer contains (just like you would count on) the original material in the document.

Eg if earliest articles buffer appears to be:

the coffee appropriate buffer is

Notice that the foundation stores regarding the identifiers are exactly the same both in buffers. This helps to ensure that resource acquiring and hyperlinking works not surprisingly.

Should you call for using the original articles of an AspectJ CompilationUnit ajproduct, you certainly can do the following:

What this technique does wants the AJCU to briefly change its buffer towards AJ buffer from the Java buffer. It’s always best to try this in a synchronized block to make sure you you shouldn’t risk other posts coming by and accidentally with the incorrect buffer (AJDT itself does not use a synchronized block with this, but it should).

By using the AspectJ AST parser

Important example, taken from insect 88861

Make the aforementioned and manage it:

Understood limits, bugs, and outstanding problems

Constraint: You will find currently no AST assistance for resolving sort bindings: bug 146528



邮箱地址不会被公开。 必填项已用*标注