2 Replies Latest reply on Dec 18, 2007 2:12 PM by M Kumar

    Custom protocol handler class

    M Kumar Newbie

      Hi All,
      I have a custom protocol handler class that extends URLStreamFactory. How do I register it with Jboss 4.0.3 on boot/startup.

      Thnks in advance

        • 1. Re: Custom protocol handler class
          Dimitris Andreadis Master

          -Djava.protocol.handler.pkgs=com.acme.xxx.protocol

          • 2. Re: Custom protocol handler class
            M Kumar Newbie

            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 );
            }

            }


            }