Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.system.server
Class ServerLoader

    java.lang.Object
      org.jboss.system.server.ServerLoader

public class ServerLoader
extends Object

A helper class to load a JBoss server instance.

Basic usage is something like this:

        // setup the basic server config properties
        Properties props = new Properties(System.getProperties());
        props.put(ServerConfig.SERVER_LIBRARY_URL, "http://myserver.com/myjboss/lib/");
        // set some more properties

        // create a new loader to do the dirty work
        ServerLoader loader = new ServerLoader(props);

        // add the jaxp & jmx library to use
        loader.addLibrary("crimson.jar");
        loader.addLibrary("jboss-jmx-core.jar");

        // load and initialize the server instance
        ClassLoader parent = Thread.currentThread().getContextClassLoader();
        Server server = loader.load(parent);
        server.init(props);

        // start up the server
        server.start();

        // go make some coffee, drink a beer or play GTA3
        // ...

        // shutdown and go to sleep
        server.shutdown();

Version:
  `$Revision: 1.16 $`
Author:
  Jason Dillon, Adrian Brock, Scott.Stark@jboss.org

Field Summary
`static String` | `DEFAULT_BOOT_LIBRARY_LIST` The default list of boot libraries.
`static String` | `DEFAULT_SERVER_TYPE` The default server type.
`protected List` | `extraClasspath` A list of extra URLs to add to the classpath when loading the server.
`protected URL` | `libraryURL` The URL where libraries are read from.
`protected Properties` | `props` Configuration properties.

Constructor Summary
`ServerLoader(Properties props)` Construct a `ServerLoader`.

Method Summary
`void` | `addEndorsedJars()` Add the jars from the lib/endorsed dir if it exists.
`void` | `addLibraries(String filenames)` Add a list of comma seperated library file names.
`void` | `addLibrary(String filename)` Add an extra library to the end of list of libraries which will be loaded from the library URL when loading the Server class.
`void` | `addURL(URL url)` Add an extra URL to the classpath used to load the server.
`protected Server` | `createServer(String typename, ClassLoader classLoader)` Construct a new instance of Server, loading all required classes from the given ClossLoader.
`protected URL[]` | `getBootClasspath()` Retruns an array of URLs which will be used to load the core system and construct a new Server object instance.
`protected URL` | `getURL(String name)` Get a URL from configuration or system properties.
`Server` | `load(ClassLoader parent)` Load a `Server` instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_BOOT_LIBRARY_LIST

    public static final String DEFAULT_BOOT_LIBRARY_LIST

  The default list of boot libraries. Does not include the JAXP or JMX impl, users of this class should add the proper libraries.

  See Also:
    Constant Field Values

### DEFAULT_SERVER_TYPE

    public static final String DEFAULT_SERVER_TYPE

  The default server type.

  See Also:
    Constant Field Values

### props

    protected Properties props

  Configuration properties.

### libraryURL

    protected URL libraryURL

  The URL where libraries are read from.

### extraClasspath

    protected List extraClasspath

  A list of extra URLs to add to the classpath when loading the server.

Constructor Detail

### ServerLoader

    public ServerLoader(Properties props)
                 throws Exception

  Construct a `ServerLoader`.

Parameters:
  `props` - Configuration properties.
Throws:
  `Exception` - Invalid configuration

Method Detail

### addLibrary

    public void addLibrary(String filename)
                    throws MalformedURLException

  Add an extra library to the end of list of libraries which will be loaded from the library URL when loading the Server class.

  Parameters:
    `filename` - A filename (no directory parts)
  Throws:
    `MalformedURLException` - Could not generate URL from library URL + filename

### addLibraries

    public void addLibraries(String filenames)
                      throws MalformedURLException

  Add a list of comma seperated library file names.

  Parameters:
    `filenames` - A list of comma seperated filenames (with no directory parts)
  Throws:
    `MalformedURLException` - Could not generate URL from library URL + filename

### addURL

    public void addURL(URL url)

  Add an extra URL to the classpath used to load the server.

  Parameters:
    `url` - A URL to add to the classpath.

### addEndorsedJars

    public void addEndorsedJars()
                         throws MalformedURLException

  Add the jars from the lib/endorsed dir if it exists. Note, the path must exist locally for this to work.

  Throws:
    `MalformedURLException` - Could not generate URL from library URL + filename

### getURL

    protected URL getURL(String name)
                  throws MalformedURLException

  Get a URL from configuration or system properties.

  Throws:
    `MalformedURLException`

### getBootClasspath

    protected URL[] getBootClasspath()
                              throws MalformedURLException

  Retruns an array of URLs which will be used to load the core system and construct a new Server object instance.

  Throws:
    `MalformedURLException`

### load

    public Server load(ClassLoader parent)
                throws Exception

  Load a `Server` instance.

  Returns:
    An uninitialized (and unstarted) Server instance.
  Throws:
    `Exception` - Failed to load or create Server instance.

### createServer

    protected Server createServer(String typename,
                                  ClassLoader classLoader)
                           throws Exception

  Construct a new instance of Server, loading all required classes from the given ClossLoader.

  Throws:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 JBoss Group, LLC. All Rights Reserved.