Modularizing URLStreamHandlerFactory
Alan Bateman
Alan.Bateman at oracle.com
Sat Jun 16 08:56:14 PDT 2012
On 15/06/2012 22:17, Jesse Glick wrote:
> Something to consider - in a big application it is not uncommon to
> have multiple URL handlers implemented in various places. Yet the JRE
> only lets you set a single URLStreamHandlerFactory for the whole JVM.
> So for the application to be modular, you need to write a proxy
> factory which accepts modular registrations, but that impedes
> interoperability since you must define a proprietary interface for this.
>
> It would be nicer for a modular JRE to allow URL handler factories to
> be registered as services. OSGi and the NetBeans module system both do
> something like this.
>
> Similar arguments could perhaps be made for other pluggable singletons
> in the current Java platform API (UncaughtExceptionHandler,
> FileNameMap, ProxySelector, HostnameVerifier, SSLSocketFactory, ...)
> but URLStreamHandlerFactory is the one which I know matters.
I also agree with should look re-visit some of these areas for
opportunities to use services. I'm less sure about dynamic services,
which I think you might be suggesting too.
A bit of history on URLStreamHandlerFactory is that there was an attempt
to allow URL protocol handlers be registered back in the JDK1.4 time
frame. If I recall correctly it had to be backed out due to security
concerns. There are also a few land mines in this area, the main one
being that URLs are used early in the VM startup, something that can
lead to recursive initialization issues if someone attempts to override
the core protocol handlers.
-Alan.
More information about the jigsaw-dev
mailing list