Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] How to find out if a bundle got successfully woven?

We have a reflection mechanism (AjTypeSystem) for asking questions of aspects, but we dont have a way to ask questions like 'are you woven?'. 

I can see three options:

- add your own message handler.  This can be passed the system messages and you can analyze them to see what happened.

- use a marker interface.  If an aspect declaration like this can be included:
  'declare parents: SomeType extends SomeMarker'
  then you can query at runtime whether SomeType implements SomeMarker.  But I don't know if you have the flexibility to add that declaration in your configuration.

- query some artifact of the weaving process.  Depending on how the aspect is defined, new members may or may not be introduced into the advised target.  You could check for one of these.  The generated names are designed to be robust across repeated weaves so you can rely on them.  I would perhaps do a 'dump' (can be specified in the aop.xml) of the woven classes and see which members in the target look like they are only there due to weaving, then attempt to access them via reflection on startup - if you can then the type is woven.

I guess if we added our own marker annotation with runtime retention (like org.aspectj.lang.runtime.Woven) to affected target classes, that might make your life rather easier, hmmm.


Andy


2009/7/30 Peter Henzler <phe@xxxxxxxx>
Hi

We are using SpringWeaver for loadtime weaving in Spring over Equinox AspectJ for handling transactional demarcation with spring annotations.

Finally we got it working reliable.
But the whole configuration is very fragile.

If a bundle with transactional annotations is missing some imported packages or the start levels are not correctly set the weaving does not take place but the bundle is loaded without errors and fully functional.
But in such a case the transactional annotations don't function and methods marked with the@Transactional  annotation are not handled and not running within a transaction.

Because this must be avoided I would like to test in the bundle activator's start method if the bundle has been processed successfully by the weaver?

There is a system output like

[org.eclipse.equinox.weaving.aspectj] info weaving bundle 'com.xy.vz'

or

[org.eclipse.equinox.weaving.aspectj] info not weaving bundle 'com.xy.vz'

if no weaving took place.

But I can't find a way to query this information at runtime.

Best regards
Peter Henzler


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev


Back to the top