-
1. Re: Custom protocol handler class
dimitris Dec 18, 2007 1:00 PM (in response to eg_jboss)-Djava.protocol.handler.pkgs=com.acme.xxx.protocol
-
2. Re: Custom protocol handler class
eg_jboss Dec 18, 2007 2:12 PM (in response to eg_jboss)Thanks for the reply, but did not work, here is outline of my class to handle custom protocols and I set the system property as -Djava.protocol.handler.pkgs=com.acme.protocol.handler.CustomProtocolUHandler
Can you please suggest what could be wrong?
Thanks again.
package com.acme.protocol.handler;
import java.net.*;
//import java.util.*;
import sun.misc.*;
import com.rsa.ssl.*;
import java.io.File;
public class CustomProtocolHandler implements URLStreamHandlerFactory
{
public URLStreamHandler createURLStreamHandler(String protocol)
{
protocol = protocol.toLowerCase();
//We are also returning our handler for handling of dummy protocols like javascript: or about:blank
if(protocol.startsWith("myhttp"))
{
return m_protocolHandler;
}
else
{
return null;
}
}
public static void main(String[] args )
{
System.out.println("main Method called");
try
{
CustomProtocolHandler customProtocolURLStreamHandler = new CustomProtocolHandler();
java.net.URL.setURLStreamHandlerFactory(customProtocolURLStreamHandler);
}
catch(Exception e)
{
System.err.println("Exception while setting the URLStreamHandlerFactory object"+e );
}
}
}