public class ServerLoader extends Object
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
// Obtain any addition server metadata
Map metadata = ...;
// create a new loader to do the dirty work
ServerLoader loader = new ServerLoader(props);
// load and initialize the server instance
ClassLoader parent = Thread.currentThread().getContextClassLoader();
Server server = loader.load(parent);
server.init(props, metadata);
// start up the server
server.start();
// go make some coffee, drink a beer or play GTA3
// ...
// shutdown and go to sleep
server.shutdown();
| Modifier and Type | Field and Description |
|---|---|
static String[] |
DEFAULT_BOOT_LIBRARY_LIST
Deprecated.
|
static String |
DEFAULT_SERVER_TYPE
The default server type.
|
protected List<URL> |
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 and Description |
|---|
ServerLoader(Properties props)
Construct a ServerLoader.
|
| Modifier and Type | Method and Description |
|---|---|
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 loader)
Construct a new instance of Server, loading all required classes from
the given ClassLoader.
|
protected URL[] |
getBootClasspath()
Returns 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. |
@Deprecated public static final String[] DEFAULT_BOOT_LIBRARY_LIST
public static final String DEFAULT_SERVER_TYPE
protected Properties props
protected URL libraryURL
public ServerLoader(Properties props) throws Exception
props - Configuration properties.Exception - Invalid configurationpublic void addLibrary(String filename) throws MalformedURLException
filename - A filename (no directory parts)MalformedURLException - Could not generate URL from library URL + filenamepublic void addLibraries(String filenames) throws MalformedURLException
filenames - A list of comma seperated filenames (with no directory parts)MalformedURLException - Could not generate URL from library URL + filenamepublic void addURL(URL url)
url - A URL to add to the classpath.public void addEndorsedJars()
throws MalformedURLException
MalformedURLException - Could not generate URL from library URL + filenameprotected URL getURL(String name) throws MalformedURLException
name - the system propertyMalformedURLException - for a bad urlprotected URL[] getBootClasspath() throws MalformedURLException, URISyntaxException
MalformedURLException - for a bad urlURISyntaxExceptionpublic Server load(ClassLoader parent) throws Exception
Server instance.parent - the parent classloaderException - Failed to load or create Server instance.protected Server createServer(String typename, ClassLoader loader) throws Exception
typename - - the fqcn of the Server implementationloader - - the ClassLoader to load typename withException - for any errorCopyright © 2012 JBoss by Red Hat. All Rights Reserved.