You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Thusitha Thilina Dayaratne <th...@wso2.com> on 2015/04/06 10:45:57 UTC
Better way to register a URLStreamHandlerService for JNDI from Tomcat 8
Hi,
At the moment, I'm registering a URLStreamHandleerService for JNDI in OSGi
BundleContext as follows.
private static final String JNDI_PROTOCOL = "jndi";
....
Hashtable<String, String[]> properties = new Hashtable<String, String[]>();
properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] {
JNDI_PROTOCOL });
bundleContext.registerService(URLStreamHandlerService.class.getName(),
new JNDIURLStreamHandlerService(), properties);
...
class JNDIURLStreamHandlerService extends AbstractURLStreamHandlerService {
URLStreamHandler urlStreamHandler =
TomcatURLStreamHandlerFactory.getInstance().createURLStreamHandler(JNDI_PROTOCOL);
@Override public URLConnection openConnection(URL url) throws IOException {
return new URL(url, "", urlStreamHandler).openConnection();
}
}
Is there a better approach to do this with Tomcat 8.0.20?
Thanks
Best Regards
Thusitha
--
Thusitha Dayaratne
Software Engineer
WSO2 Inc. - lean . enterprise . middleware | wso2.com
Mobile +94712756809
Blog alokayasoya.blogspot.com
About http://about.me/thusithathilina