I have a special URLStreamHandlerFactory and want to set to an
existing jdk application.
How to do it without change java code?
Thank you.
Oliver Wong - 24 May 2006 18:47 GMT
>I have a special URLStreamHandlerFactory and want to set to an
> existing jdk application.
>
> How to do it without change java code?
Given that URLStreamHandlerFactory is an interface and thus contains no
behavioural code, this sounds like a really bad idea.
But if you really wanted to do this, I suppose you could go into your
JRE directory and mess around with the JAR/ZIP files to replace th existing
stuff there with your new class file.
- Oliver
Thomas Hawtin - 24 May 2006 18:50 GMT
> I have a special URLStreamHandlerFactory and want to set to an
> existing jdk application.
>
> How to do it without change java code?
The two obvious choices are:
Use a Java Agent to call URL.setURLStreamHandlerFactory, but not
actually do any instrumentation. I've got an example of doing something
similar with EventQueue.push.
http://jroller.com/page/tackline?entry=detecting_invokeandwait_abuse
The alternative is to set -Djava.protocol.handler.pkgs=mypackage, then
instead of using URLStreamHandlerFactory provide URLStreamHandler
classes with no-arg constructors and names of the form
mypackage.protocol.Handler. See the source code to URL...
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/