Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Using AspectJ with Java service provider pattern

In my Java application I'm using a custom xml parser implementation that is
loaded by Java runtime using service provider pattern. E.g. I specify in
jaxp.properties:
javax.xml.parsers.SAXParserFactory=org.my.parser.MyCustomParserFactory.

This allows me to keep existing code below but use a different
implementation at runtime.
XMLReader xr = XMLReaderFactory.newXMLReader();

In my case xr becomes an instance of org.my.parser.MyCustomParser.

In my Aspect I declare MyCustomParser to be of a certain type, which adds an
additional object for tracking to each XMLReader instance.  Like so:

declare parents: org.my.parser.MyCustomParser implements Markable;

This effectively works on any class at runtime except on the objects loaded
by Java using service provider pattern. Has anyone come across this?

AJ 1.8.4 with Java 7.

-Sergey

Back to the top