org.abstracthorizon.extend.server
Class Bootstrap

java.lang.Object
  extended by org.abstracthorizon.extend.server.Bootstrap

public class Bootstrap
extends Object

Bootstrap class. This class first tries to find home directory of the server:

Then class loader with class path is created with all jar files from lib subdirectory (of the home directory), and lib directory itself is added to the class path.

After that server directory is determined from arguments (TODO) or if none present from &quit;server/default" directory of the home directory.

Last part is to load Server class (using reflection), pass home and server's urls to it (in constructor) and then to invoke it calling create() and start() methods.

Author:
Daniel Sendula

Constructor Summary
Bootstrap()
           
 
Method Summary
static Collection<URL> collectFiles(URL url)
          Collects files from given url.
static Collection<URL> collectFilesFromJar(URL original, JarFile jarFile)
          Collects files from jar file (root of)
static Collection<URL> collectFilesFromPath(File path)
          Collects files from given path
static Collection<URL> collectFilesFromURL(URL url)
          Collects files from give (generic) url
static URLClassLoader createClassLoader(ClassLoader parent, URL lib)
          Creates class loader for given url.
static URL getHomeLocation()
          Gets home location.
static void invokeMethod(Object object, String methodName, boolean mustBePresent)
          Invokes parametherless method with given name.
static void main(String[] args)
          Main method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bootstrap

public Bootstrap()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Main method

Parameters:
args - arguments
Throws:
Exception

getHomeLocation

public static URL getHomeLocation()
                           throws MalformedURLException
Gets home location.

Returns:
home location
Throws:
MalformedURLException

createClassLoader

public static URLClassLoader createClassLoader(ClassLoader parent,
                                               URL lib)
                                        throws IOException
Creates class loader for given url. If url is directory then it is scanned and all jar files from it added to classpath.

Parameters:
parent - parent class loader or null
lib - url class loader to be created for.
Returns:
URLClassLoader instance
Throws:
IOException

collectFiles

public static Collection<URL> collectFiles(URL url)
                                    throws IOException
Collects files from given url.

Parameters:
url - url
Returns:
collection of urls
Throws:
IOException

collectFilesFromPath

public static Collection<URL> collectFilesFromPath(File path)
                                            throws IOException
Collects files from given path

Parameters:
path - directory
Returns:
collection of urls
Throws:
IOException

collectFilesFromJar

public static Collection<URL> collectFilesFromJar(URL original,
                                                  JarFile jarFile)
                                           throws IOException
Collects files from jar file (root of)

Parameters:
original - original url
jarFile - jar file
Returns:
collection of urls
Throws:
IOException

collectFilesFromURL

public static Collection<URL> collectFilesFromURL(URL url)
                                           throws IOException
Collects files from give (generic) url

Parameters:
url - url
Returns:
collection of files
Throws:
IOException

invokeMethod

public static void invokeMethod(Object object,
                                String methodName,
                                boolean mustBePresent)
Invokes parametherless method with given name. If mustBePresent is set to true NoSuchMethodException is propagated wrapped in RuntimeException.

Parameters:
object - instance on which method is going to be executed
methodName - method name
mustBePresent - if set then method must be present or NoSuchMethodError is thrown
Throws:
RuntimeException - if NoSuchMethodException, IllegalArgumentException, IllegalAccessException or InvocationTargetException is thrown.


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.