You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Jeremias Maerki <je...@outline.ch> on 2001/10/24 14:11:39 UTC
Using custom URL protocol handlers in Phoenix
Hi
For my server app I have a custom URL protocol handler that needs to be
registered. Normally this is done by setting the
-Djava.protocol.handler.pkgs parameter of the VM. But since my handler
needs several jars (such as application specific jars and other api jars)
I need to copy them into phoenix's lib directory to get it to work
(classloaders and all...). And I don't want to do that, of course.
So I wonder if the following is a good approach: Extend Phoenix to have
a special URL protocol facility where applications can register and
deregister their protocol handlers. Phoenix registers a special
URLProtocolHandlerFactory using URL.setURLProtocolHandlerFactory.
I don't know in detail, yet, how I would implement it. Maybe if this is
a good idea, someone can give me a hint on how exactly to do it. Or
maybe there is a better way of doing it.
Cheers,
Jeremias Märki
mailto:jeremias.maerki@outline.ch
OUTLINE AG
Postfach 3954 - Rhynauerstr. 15 - CH-6002 Luzern
Fon +41 (41) 317 2020 - Fax +41 (41) 317 2029
Internet http://www.outline.ch
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
Re: Using custom URL protocol handlers in Phoenix
Posted by Mircea Toma <mi...@home.com>.
Hi,
>Hi
>
>For my server app I have a custom URL protocol handler that needs >to be
>registered. Normally this is done by setting the
>-Djava.protocol.handler.pkgs parameter of the VM. But since my >handler
>needs several jars (such as application specific jars and other api >jars)
>I need to copy them into phoenix's lib directory to get it to work
>(classloaders and all...). And I don't want to do that, of course.
Did you try to package your custom URLStreamHandler into a jar file and add
it to the .sar under /SAR-INF/lib (or /lib for the old format)? Then
registering the package name in -Djava.protocol.handler.pkgs should work
(see
http://developer.java.sun.com/developer/onlineTraining/protocolhandlers/ ).
Mircea
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
Re: Using custom URL protocol handlers in Phoenix
Posted by Peter Donald <do...@apache.org>.
On Wed, 24 Oct 2001 22:11, Jeremias Maerki wrote:
> Hi
>
> For my server app I have a custom URL protocol handler that needs to be
> registered. Normally this is done by setting the
> -Djava.protocol.handler.pkgs parameter of the VM. But since my handler
> needs several jars (such as application specific jars and other api jars)
> I need to copy them into phoenix's lib directory to get it to work
> (classloaders and all...). And I don't want to do that, of course.
yep - theres a few ugly things like that. The same also occurs with JNDI
aswell ;(
> So I wonder if the following is a good approach: Extend Phoenix to have
> a special URL protocol facility where applications can register and
> deregister their protocol handlers. Phoenix registers a special
> URLProtocolHandlerFactory using URL.setURLProtocolHandlerFactory.
>
> I don't know in detail, yet, how I would implement it. Maybe if this is
> a good idea, someone can give me a hint on how exactly to do it. Or
> maybe there is a better way of doing it.
Actually thats almost exactly how I handled the JNDI case. In this case it
would look something like
public class DefaultURLStreamHandlerFactory
implements URLStreamHandlerFactory
{
private URLStreamHandlerFactory[] m_factorys;
public void addFactory( URLStreamHandlerFactory m_factory ) { ... }
public URLStreamHandler createURLStreamHandler( String protocol )
{
for( int i = 0; i < m_factorys.length; i++ )
{
final URLStreamHandler handler =
m_factorys[i].createURLStreamHandler(protocol);
if( null != handler ) return handler;
}
return null;
}
}
I am not sure what is the best way at the moment. In the short term I would
still chuck the jars in phoenix/lib if at all possible but the above could
possibly be a long term solution depending on where we go.
Alternatively is it possible to get the code that uses new URLs to directly
use your handler factory (ie pass it into classloader or something?).
--
Cheers,
Pete
-----------------------------------------------------------
If your life passes before your eyes when you die,
does that include the part where your life passes before
your eyes?
-----------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org