Designer’s help guide to creating equipment together with AJDT and AspectJ

Designer’s help guide to creating equipment together with AJDT and AspectJ

These pages is meant to aid individuals building knowledge to give or deal with AJDT/AspectJ. Kindly play a role in this page with any relevant records, such as example signal utilizing the AJDT and/or AspectJ APIs.

This page may be out of day. Our very own intent is to update these pages for AJDT 1.6.1, but we’ve not got opportunity because of this yet. Please recognize that several of something with this page might no lengthier feel proper. When you yourself have any queries, kindly submit them to the subscriber list ajdt-dev.

Information

  • 1 getting crosscutting connection information from AJDT
  • 2 Compilation Devices in AJDT
    • 2.1 Acquiring the belongings in an AJCompilationUnit
  • 3 utilising the AspectJ AST parser
  • 4 Known restrictions, insects, and outstanding issues
  • 5 The program resources are required to make use of to drive the AspectJ compiler

Getting crosscutting commitment records from AJDT

In case you are establishing an eclipse plug-in and require access to crosscutting information whenever a task is built, you can register a listener with AJDT. Their 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. Into the org.eclipse.ajdt.core plug-in there is certainly an IAdviceChangedListener user interface with an individual adviceChanged() strategy .

Join this because of the AJBuilder class such as this (inside plug-in’s start() way for example):

At this time (AJDT 1.6) this is certainly labeled as after each and every build of an AspectJ job (in other words. every *potential* information changes). In another launch this may be optimized become best known as when the guidance have actually altered. AJDT/UI uses this method to update the lime arrow graphics decorator.

Crosscutting records are able to become extracted from the AJProjectModelFacade class. Here is an example which includes pseudo code it is possible to adjust:

A number of records concerning this:

  1. The API may have some slight changes in tomorrow. Be sure to send a note towards the ajdt-dev mailing list if any such thing with this page is out of go out.
  2. The AJProjectModelFacade object are a light access in to the AspectJ globe. It is only valid through to the next acquire. So, you shouldn’t store them. Use them and dispose as required.
  3. AJProjectModelFacade objects merely contain data after the basic successful build. You’ll be able to name the possessModel() approach to find out if an AspectJ model exists the job.
  4. Clearly, you will get the partnership in both information. Discover AJRelationshipManager for full directory of relationships, so you can only ask for the connection sort you find attractive.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return Strings that portray AspectJ aspect handles. You need to use listed here AJProjectModelFacade solutions to convert to model aspects:
    • toProgramElement(sequence) — returns IProgramElement. From here you’ll acquire information regarding the pointcut, intertype aspect, or declare element.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — profits IJavaElement. From this point it is possible to hook into JDT tooling.
  6. There is absolutely no needs to join up a recommendations altered listener. You can get use of the crosscutting model whenever you want (providing your panels has already established a fruitful build) with the following code:

Collection Models in AJDT

JDT brings collection devices (instances of ICompilationproduct) for .java data files. AJDT creates compilation units for .aj records, which have been cases of AJCompilationUnit (which implements ICompilationUnit). The course AJCompilationUnitManager (in the org.eclipse.ajdt.core plug-in) has some helpful strategies concerning this, eg:

From an AJCompilationUnit you’ll be able to obtain various architectural information like getAllTypes(). The main type for „.aj“ documents is usually a piece, that’s represented because of the AspectElement lessons, containing aspect-specific means particularly getPointcuts() and getAdvice(). These return further aspect-specific characteristics such as for instance PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we utilize the Eclipse weaving services to weave into JDT. One group of join things which happen to be encouraged are those related to the creation of CompilationUnit things. When the document keeps are *.aj file, AJCompilationUnit is established rather than a typical Java Compilationproduct.

Having the contents of an AJCompilationUnit

Because JDT expects that every provider it works with is true Java rule, JDT does not work really with AspectJ. In order to get surrounding this, AJCompilationUnits manage two buffers that have resource information. The foremost is a java appropriate buffer as well as the second will be the original material buffer. The java suitable buffer is the buffer that’s returned automatically whenever AJCompilationUnit.getContents() is known as. This buffer offers the AspectJ laws along with aspect-specific syntax stripped out. The initial material buffer consists of (just like you would count on) the original articles with the file.

For instance in the event that initial content buffer appears like:

the coffee suitable buffer is

Notice that the source stores associated with the identifiers are identical both in buffers. This makes sure that reference finding and hyperlinking work not surprisingly.

Should you need using the services of the original information of an AspectJ CompilationUnit ajdevice, can be done the annotated following:

What this technique do asks for the AJCU to briefly switch the buffer on the AJ buffer from the coffee buffer. It is best to repeat this in a synchronized block so you you shouldn’t exposure different posts coming by and unintentionally making use of the wrong buffer (AJDT by itself does not make use of a synchronized block with this, it should).

Using the AspectJ AST parser

Standard sample, obtained from insect 88861

Compile the above mentioned and operate they:

Recognized limitations, pests, and outstanding issues

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

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *