Package javassist

Class URLClassPath

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String directory  
      protected java.lang.String hostname  
      protected java.lang.String packageName  
      protected int port  
    • Constructor Summary

      Constructors 
      Constructor Description
      URLClassPath​(java.lang.String host, int port, java.lang.String directory, java.lang.String packageName)
      Creates a search path specified with URL (http).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this class path.
      static byte[] fetchClass​(java.lang.String host, int port, java.lang.String directory, java.lang.String classname)
      Reads a class file on an http server.
      private static java.net.URLConnection fetchClass0​(java.lang.String host, int port, java.lang.String filename)  
      java.net.URL find​(java.lang.String classname)
      Returns the URL.
      java.io.InputStream openClassfile​(java.lang.String classname)
      Opens a class file with http.
      private java.net.URLConnection openClassfile0​(java.lang.String classname)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • hostname

        protected java.lang.String hostname
      • port

        protected int port
      • directory

        protected java.lang.String directory
      • packageName

        protected java.lang.String packageName
    • Constructor Detail

      • URLClassPath

        public URLClassPath​(java.lang.String host,
                            int port,
                            java.lang.String directory,
                            java.lang.String packageName)
        Creates a search path specified with URL (http).

        This search path is used only if a requested class name starts with the name specified by packageName. If packageName is "org.javassist." and a requested class is "org.javassist.test.Main", then the given URL is used for loading that class. The URLClassPath obtains a class file from:

        http://www.javassist.org:80/java/classes/org/javassist/test/Main.class
         

        Here, we assume that host is "www.javassist.org", port is 80, and directory is "/java/classes/".

        If packageName is null, the URL is used for loading any class.

        Parameters:
        host - host name
        port - port number
        directory - directory name ending with "/". It can be "/" (root directory). It must start with "/".
        packageName - package name. It must end with "." (dot).
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • openClassfile

        public java.io.InputStream openClassfile​(java.lang.String classname)
        Opens a class file with http.
        Specified by:
        openClassfile in interface ClassPath
        Parameters:
        classname - a fully-qualified class name
        Returns:
        null if the class file could not be found.
        See Also:
        Translator
      • openClassfile0

        private java.net.URLConnection openClassfile0​(java.lang.String classname)
                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • find

        public java.net.URL find​(java.lang.String classname)
        Returns the URL.
        Specified by:
        find in interface ClassPath
        Parameters:
        classname - a fully-qualified class name.
        Returns:
        null if the class file could not be obtained.
      • close

        public void close()
        Closes this class path.
        Specified by:
        close in interface ClassPath
      • fetchClass

        public static byte[] fetchClass​(java.lang.String host,
                                        int port,
                                        java.lang.String directory,
                                        java.lang.String classname)
                                 throws java.io.IOException
        Reads a class file on an http server.
        Parameters:
        host - host name
        port - port number
        directory - directory name ending with "/". It can be "/" (root directory). It must start with "/".
        classname - fully-qualified class name
        Throws:
        java.io.IOException
      • fetchClass0

        private static java.net.URLConnection fetchClass0​(java.lang.String host,
                                                          int port,
                                                          java.lang.String filename)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException