Link to home
Start Free TrialLog in
Avatar of deleyd
deleydFlag for United States of America

asked on

wedge my.jar between calling program and real .jar file program uses?

I want to set an attribute, on a class, which is in a .jar file, but the .jar file is signed, so I can't modify the .jar file.

And I can't (without great difficulty) modify the code that calls the class in this .jar file.

However, I can specify which .jar file the calling code uses, so I'm wondering if there's a way I can wedge in my own .jar file, which then acts as an intermediary and calls the real .jar file, and sets that one Boolean attribute to true for that one class I'm interested in.

CALLING PROGRAM → my.jar → Saxon-HE-9.8.0-5.jar

The way it's currently set up:

CALLING PROGRAM → Saxon-HE-9.8.0-5.jar

and CALLING PROGRAM makes the following call:
TransformerFactory transformerFactory = TransformerFactory.newInstance();

Open in new window

At this point if I could edit the calling program code, I would just add the following line:
transformerFactory.setAttribute("http://saxon.sf.net/feature/ignoreSAXSourceParser", true);

Open in new window

But I don't have that luxury.

If I diverted the calling program to use my.jar instead of the real Saxon-HE-9.8.0-5.jar, is there an easy way to do that and make just one small modification?

CALLING PROGRAM → my.jar → Saxon-HE-9.8.0-5.jar

Or am I now stuck with having to implement the entire Saxon interface in my.jar, which may or may not be huge.
 
(I seem to recall some Design Pattern about this.)

My idea would be to override TransformerFactory.newInstance(); and slide in my one line of code to set that one attribute.


Is this even possible if I pursue this course? Or, is there another easier way?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deleyd

ASKER

As I look at it again today, I see I was wrong about the setup. I actually DO have control over what TransformerFactory is called. That's just one method I can write.

Hmm, except I already tried that yesterday.

Oh yes! But I couldn't add it to the Saxon-HE09.8.0-5.jar file. But I don't have to!

There's my answer! I'll just put it somewhere else!

Alright thank you for the help. We'll see if I can get this to work. :)