org.apache.avalon.repository.main
Class Bootstrapper

java.lang.Object
  extended byorg.apache.avalon.repository.main.Bootstrapper

public class Bootstrapper
extends Object

Application and component bootstrapper used to instantiate, and or invoke Classes and their methods within newly constructed Repository ClassLoaders.

Version:
$Revision: 1.1 $
Author:
Alex Karasulu, $Author: mcconnell $

Constructor Summary
Bootstrapper(Repository a_repository, Artifact artifact)
          Creates a Bootstrapper for a specific target artifact.
 
Method Summary
 ClassLoader getClassLoader()
          Gets the ClassLoader used by this Bootstrapper.
 String getConstructor(String main)
          Gets the name of the constructor given the fully qualified class name.
 Object invoke(Object a_obj, String a_method, String[] a_argTypes, Object[] a_args)
          Invokes a method on an object.
 Object invoke(String main, String a_method, String[] a_types, Object[] a_args)
          Invokes a static method on a class.
 Class loadClass(String main)
          Loads a class using the ClassLoader created by the Repository.
static void main(String[] a_args)
          Main wrapper.
 void main(String main, String[] a_args)
          Invokes the main application entry point for a class.
 Object newInstance(String main)
          Creates a new instance of a class using the default constructor.
 Object newInstance(String main, String[] a_types, Object[] a_args)
          Creates a new instance of a class using a constructor taking arguments.
 void run(String main)
          Instantiates a runnable using a default constructor and calls its run method.
 String toSignature(String a_method, String[] a_types)
          Constructs a String representing the signature of an method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bootstrapper

public Bootstrapper(Repository a_repository,
                    Artifact artifact)
             throws RepositoryException
Creates a Bootstrapper for a specific target artifact.

Method Detail

getClassLoader

public ClassLoader getClassLoader()
Gets the ClassLoader used by this Bootstrapper.

Returns:
the ClassLoader built by the Repository

main

public void main(String main,
                 String[] a_args)
          throws RepositoryException
Invokes the main application entry point for a class.

Parameters:
a_args - the arguments to pass-thro to the main of the application
Throws:
RepositoryException - on any class loading or invocation failures

run

public void run(String main)
         throws RepositoryException
Instantiates a runnable using a default constructor and calls its run method.

Parameters:
main - the fully qualified class name of the Runnable
Throws:
RepositoryException - on any class loading or invokation failures

invoke

public Object invoke(String main,
                     String a_method,
                     String[] a_types,
                     Object[] a_args)
              throws RepositoryException
Invokes a static method on a class.

Parameters:
main - the fully qualified class name
a_method - the name of the method to invoke
a_types - the fqcn of the parameters
a_args - the arguments to the method
Returns:
the methods return value if one exists, or null if method is void
Throws:
RepositoryException

newInstance

public Object newInstance(String main)
                   throws RepositoryException
Creates a new instance of a class using the default constructor.

Parameters:
main - the fully qualified name of the class to create an inst of
Returns:
the instance created
Throws:
RepositoryException - if the instantiation fails

newInstance

public Object newInstance(String main,
                          String[] a_types,
                          Object[] a_args)
                   throws RepositoryException
Creates a new instance of a class using a constructor taking arguments.

Parameters:
main - the fully qualified name of the class to create an inst of
a_types - the fully qualified names of constructor parameter types
a_args - the arguments to the constructor
Returns:
the newly created instance
Throws:
RepositoryException - if the instantiation fails

getConstructor

public String getConstructor(String main)
Gets the name of the constructor given the fully qualified class name.

Parameters:
main - the fully qualified class name
Returns:
the name of the constructor

invoke

public Object invoke(Object a_obj,
                     String a_method,
                     String[] a_argTypes,
                     Object[] a_args)
              throws RepositoryException
Invokes a method on an object.

Parameters:
a_obj - the object to invoke a method on
a_method - the method to invoke
a_argTypes - the fqcn of the parameters
a_args - the arguments to method
Returns:
a return value if one is returned, otherwise null
Throws:
RepositoryException

loadClass

public Class loadClass(String main)
                throws RepositoryException
Loads a class using the ClassLoader created by the Repository.

Parameters:
main - the fully qualified class name
Returns:
the Class loaded using the Repository built ClassLoader
Throws:
RepositoryException - if the class could not be found

toSignature

public String toSignature(String a_method,
                          String[] a_types)
Constructs a String representing the signature of an method.

Parameters:
a_method - the name of the method
a_types - the fully qualified class names of the method parameters
Returns:
the signature String

main

public static void main(String[] a_args)
Main wrapper.

Parameters:
a_args -


Copyright © Apache Software Foundation. All Rights Reserved.