homeURL = file.toURI().toURL().toString();
props.setProperty(ServerConfig.HOME_URL, homeURL);
}
// Load the server instance
ServerLoader loader = new ServerLoader(props);
/* If there is a patch dir specified make it the first element of the
loader bootstrap classpath. If its a file url pointing to a dir, then
add the dir and its contents.
*/
if (bootURL != null)
{
if (bootURL.getProtocol().equals("file"))
{
File dir = new File(bootURL.getFile());
if (dir.exists())
{
// Add the local file patch directory
loader.addURL(dir.toURL());
// Add the contents of the directory too
File[] jars = dir.listFiles(new JarFilter());
for (int j = 0; jars != null && j < jars.length; j++)
{
loader.addURL(jars[j].getCanonicalFile().toURL());
}
}
}
else
{
loader.addURL(bootURL);
}
}
// Add any extra libraries
for (int i = 0; i < bootLibraries.size(); i++)
{
loader.addLibrary(bootLibraries.get(i));
}
// Add the jars from the endorsed dir
loader.addEndorsedJars();
// jmx UnifiedLoaderRepository needs a concurrent class...
loader.addLibrary(concurrentLib);
// Add any extra libraries after the boot libs
for (int i = 0; i < extraLibraries.size(); i++)
{
loader.addLibrary(extraLibraries.get(i));
}
// Add any extra classapth URLs
for (int i = 0; i < extraClasspath.size(); i++)
{
loader.addURL(extraClasspath.get(i));
}
// Load the server
ClassLoader parentCL = Thread.currentThread().getContextClassLoader();
server = loader.load(parentCL);
// Initialize the server
server.init(props);
// Start 'er up mate!