Our News

Creator’s guide to design hardware along with AJDT and AspectJ

Creator’s guide to design hardware along with AJDT and AspectJ

This site is intended to aid anybody creating equipment to give or assist AJDT/AspectJ. Be sure to donate to this site with any pertinent information, eg example signal with the AJDT and/or AspectJ APIs.

These pages is beyond time. All of our goal is to upgrade these pages for AJDT 1.6.1, but we’ve maybe not got energy for this yet. Be sure to recognize that some of what’s on this web page may no longer become appropriate. If you have any questions, kindly deliver these to the subscriber list ajdt-dev.

Items

  • 1 Obtaining crosscutting partnership information from AJDT
  • 2 Compilation Devices in AJDT
    • 2.1 Acquiring the contents of an AJCompilationUnit
  • 3 utilising the AspectJ AST parser
  • 4 Known restrictions, pests, and outstanding problem
  • 5 The user interface equipment are anticipated to make use of to drive the AspectJ compiler

Getting crosscutting union suggestions from AJDT

If you should be establishing an eclipse plug-in and call for use of crosscutting info whenever a venture is made, you can sign up a listener with AJDT. The 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 there’s an IAdviceChangedListener software with just one adviceChanged() technique.

Join this making use of the AJBuilder class like this (in your plug-in’s start() way for example):

Presently (AJDT 1.6) this can be also known as after every acquire of an AspectJ task (i.e. every *potential* pointers modification). In the next production this may be optimized getting just labeled as when the pointers possess actually altered. AJDT/UI utilizes this process to revise the lime arrow picture decorator.

Crosscutting records are able to feel extracted from the AJProjectModelFacade lessons. Discover an example which includes pseudo-code you can easily adjust:

Several notes concerning this:

  1. The API might have some slight alterations in the future. Kindly deliver a note on ajdt-dev mailing list if anything about page may be out of time.
  2. The AJProjectModelFacade object is a light-weight entrances in to the AspectJ world. It is simply appropriate until the after that create. So, you shouldn’t keep all of them. Utilize them and dispose as required.
  3. AJProjectModelFacade objects just incorporate facts after the basic profitable create. You can call the possessModel() approach to find out if an AspectJ unit is out there for the venture.
  4. Perhaps you have realized, you can get the relationship in guidelines. See AJRelationshipManager when it comes down to complete variety of relationships, to help you merely request the partnership types you have in mind.
  5. IRelationship.getSourceHandle() and IRelationship.getTargets() return chain that express AspectJ component handles. You can make use of the next AJProjectModelFacade ways to convert to model areas:
    • toProgramElement(String) — comes back IProgramElement. From here you are able to acquire information on the pointcut, intertype element, or declare component.
    • programElementToJavaElement(sequence) or programElementToJavaElement(IProgramElement) — returns IJavaElement. From this point you are able to connect into JDT tooling.
  6. There is absolutely no prerequisite to join up a recommendations altered listener. You can acquire access to the crosscutting design at any time (assuming that the project has received a successful build) making use of the next rule:

Compilation Products in AJDT

JDT creates collection units (instances of ICompilationproduct) for .java data. AJDT creates collection models for .aj files, which are cases of AJCompilationUnit (which implements ICompilationdevice). The course AJCompilationUnitManager (from inside the org.eclipse.ajdt.core plug-in) includes some of good use methods relating to this, particularly:

From an AJCompilationUnit you’ll be able to obtain different architectural records such as for example getAllTypes(). The main sort for “.aj” data files is usually a piece, and that is represented of the AspectElement lessons, containing aspect-specific strategies such as getPointcuts() and getAdvice(). These return further aspect-specific items like PointcutElement and AdviceElement.

Since AJDT 1.6.2 for Eclispe 3.4, we make use of the Eclipse weaving solution to incorporate into JDT. One set of join points which happen to be guided are the ones linked to the production of CompilationUnit items. When the document enjoys is *.aj document, AJCompilationUnit is created in place of a general coffee collectionproduct.

Acquiring the contents of an AJCompilationUnit

Because JDT anticipates that every resource it truly does work with is true Java laws, JDT can not work really with AspectJ. In order to get with this, alua AJCompilationUnits keep two buffers containing provider information. The first is a java appropriate buffer and also the second may be the initial contents buffer. The java suitable buffer could be the buffer this is certainly returned automatically when AJCompilationUnit.getContents() is named. This buffer provides the AspectJ rule with all aspect-specific syntax stripped out. The original content buffer have (when you would expect) the first information from the document.

Eg if initial articles buffer seems like:

the coffee appropriate buffer is

Observe that the source stores of this identifiers are identical in both buffers. This ensures that resource researching and hyperlinking functions needlessly to say.

In the event that you need working together with the original content of an AspectJ CompilationUnit ajproduct, can help you the following:

Just what this technique does requests for the AJCU to briefly switch the buffer toward AJ buffer from the Java buffer. It is best to repeat this in a synchronized block so that you will you shouldn’t risk more posts coming by and unintentionally utilising the completely wrong buffer (AJDT it self does not need a synchronized block with this, however it should).

Utilising the AspectJ AST parser

Practical example, taken from bug 88861

Make the aforementioned and operate they:

Understood restrictions, pests, and outstanding problem

Limitation: there can be presently no AST service for resolving means bindings: insect 146528

  • Share: