net.sourceforge.fluxion.pussycat.util
Class JarClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by net.sourceforge.fluxion.pussycat.util.JarClassLoader

public class JarClassLoader
extends java.net.URLClassLoader

A class loader for loading jar files, both local and remote.

Author:
Rob Davey

Constructor Summary
JarClassLoader(java.lang.String s)
          Creates a new JarClassLoader for the specified string which is then converted to a URL.
JarClassLoader(java.net.URL url)
          Creates a new JarClassLoader for the specified url.
 
Method Summary
 void getAllMethods(java.lang.String name)
          Gets the allMethods attribute of the JarClassLoader object
 java.lang.String getMainClassName()
          Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.
 java.lang.Object instantiate(java.lang.String name)
          Description of the Method
 void invokeClass(java.lang.String name, java.lang.String[] args)
          Invokes the application in this jar file given the name of the main class and an array of arguments.
 void invokeClass(java.lang.String name, java.lang.String method, java.lang.String[] args)
          Description of the Method
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarClassLoader

public JarClassLoader(java.net.URL url)
Creates a new JarClassLoader for the specified url.

Parameters:
url - the url of the jar file

JarClassLoader

public JarClassLoader(java.lang.String s)
               throws java.net.MalformedURLException
Creates a new JarClassLoader for the specified string which is then converted to a URL. Windows workaround.

Parameters:
s - Description of the Parameter
Throws:
java.net.MalformedURLException - Description of the Exception
Method Detail

getMainClassName

public java.lang.String getMainClassName()
                                  throws java.io.IOException
Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.

Returns:
The mainClassName value
Throws:
java.io.IOException - Description of the Exception

invokeClass

public void invokeClass(java.lang.String name,
                        java.lang.String[] args)
                 throws java.lang.ClassNotFoundException,
                        java.lang.NoSuchMethodException,
                        java.lang.reflect.InvocationTargetException
Invokes the application in this jar file given the name of the main class and an array of arguments.

The class must define a static method "main" which takes an array of String arguments and is of return type "void".

Parameters:
name - the name of the main class
args - the arguments for the application
Throws:
java.lang.ClassNotFoundException - if the specified class could not be found
java.lang.NoSuchMethodException - if the specified class does not contain a "main" method
java.lang.reflect.InvocationTargetException - if the application raised an exception

invokeClass

public void invokeClass(java.lang.String name,
                        java.lang.String method,
                        java.lang.String[] args)
                 throws java.lang.ClassNotFoundException,
                        java.lang.NoSuchMethodException,
                        java.lang.reflect.InvocationTargetException
Description of the Method

Parameters:
name - Description of the Parameter
method - Description of the Parameter
args - Description of the Parameter
Throws:
java.lang.ClassNotFoundException - Description of the Exception
java.lang.NoSuchMethodException - Description of the Exception
java.lang.reflect.InvocationTargetException - Description of the Exception

instantiate

public java.lang.Object instantiate(java.lang.String name)
                             throws java.lang.ClassNotFoundException,
                                    java.lang.InstantiationException,
                                    java.lang.IllegalAccessException
Description of the Method

Parameters:
name - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.lang.ClassNotFoundException - Description of the Exception
java.lang.InstantiationException - Description of the Exception
java.lang.IllegalAccessException - Description of the Exception

getAllMethods

public void getAllMethods(java.lang.String name)
                   throws java.lang.ClassNotFoundException,
                          java.lang.SecurityException
Gets the allMethods attribute of the JarClassLoader object

Parameters:
name - Description of the Parameter
Throws:
java.lang.ClassNotFoundException - Description of the Exception
java.lang.SecurityException - Description of the Exception


Copyright © 2010. All Rights Reserved.