Commit 448cbdf9 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Refactored server starter.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@113 b35dd754-fafc-0310-a699-88a17e54d16e
parent 71cfe1e4
......@@ -157,7 +157,7 @@
<fileset dir="${src.i18n.dir}" includes="*.properties" />
<zipgroupfileset dir="${lib.merge.dir}" includes="*.jar"/>
<manifest>
<attribute name="Main-Class" value="org.jivesoftware.messenger.starter.XMPPServerStarter" />
<attribute name="Main-Class" value="org.jivesoftware.messenger.starter.ServerStarter" />
<attribute name="Built-By" value="Jive Software (www.jivesoftware.org)"/>
</manifest>
</jar>
......
......@@ -147,7 +147,7 @@ public abstract class BootstrapContainer implements Container, ServiceLookupProv
private boolean setupMode = true;
private static final String STARTER_CLASSNAME =
"org.jivesoftware.messenger.container.starter.ServerStarter";
"org.jivesoftware.messenger.starter.ServerStarter";
private static final String WRAPPER_CLASSNAME =
"org.tanukisoftware.wrapper.WrapperManager";
......
......@@ -8,7 +8,7 @@
* This software is the proprietary information of CoolServlets, Inc.
* Use is subject to license terms.
*/
package org.jivesoftware.messenger.container.starter;
package org.jivesoftware.messenger.starter;
import java.io.File;
import java.io.FilenameFilter;
......
......@@ -8,60 +8,51 @@
* This software is the proprietary information of CoolServlets, Inc.
* Use is subject to license terms.
*/
package org.jivesoftware.messenger.container.starter;
package org.jivesoftware.messenger.starter;
import org.jivesoftware.messenger.container.starter.JiveClassLoader;
import java.io.File;
/**
* A bootstrap class that configures classloaders to ensure easy,
* dynamic server startup.
* <p/>
* <p>Extend this class and implement a main method that calls the start()
* method on this class in order to start the server.</p>
* <p/>
* <p>This class should be for standalone
* mode only. Jive servers launched through a J2EE container
* (servlet/EJB) will use those environment's classloading facilities
* to ensure proper startup.
* <p/>
* Tasks:
* </p>
* <ul>
* <li>Add all jars in the lib directory to the classpath.</li>
* <li>Add the config directory to the classpath for loadResource()</li>
* <li>Start the server</li>
* Starts the core XMPP server. A ootstrap class that configures classloaders
* to ensure easy, dynamic server startup.
*
* This class should be for standalone mode only. Jive Messenger servers launched
* through a J2EE container (servlet/EJB) will use those environment's
* classloading facilities to ensure proper startup.<p>
*
* Tasks:<ul>
* <li>Add all jars in the lib directory to the classpath.</li>
* <li>Add the config directory to the classpath for loadResource()</li>
* <li>Start the server</li>
* </ul>
*
* @author Iain Shigeoka
*/
abstract public class ServerStarter {
public class ServerStarter {
/**
* <p>Obtain the name of the class for the bootstrap container.
* The class name should be the fully qualified name that can be
* loaded by a classloader using loadClass() and the implementation
* should be on the default application lib classpath.</p>
*
* @return The class name of the bootstrap container to use
*/
abstract protected String getBootContainerClassName();
public static void main(String [] args) {
new ServerStarter().start();
}
/**
* <p>Starts the server by loading and instantiating the bootstrap
* Starts the server by loading and instantiating the bootstrap
* container. Once the start method is called, the server is
* started and the server starter should not be used again.</p>
* started and the server starter should not be used again.
*/
protected void start() {
private void start() {
// setup the classpath using JiveClassLoader
try {
// Load up the bootstrap container
final ClassLoader parent = findParentClassLoader();
// TODO: Possibly load this lib dir as a java property?
File libDir = new File("../lib");
ClassLoader loader = new JiveClassLoader(parent, libDir);
Thread.currentThread().setContextClassLoader(loader);
Class containerClass = loader.loadClass(getBootContainerClassName());
Class containerClass = loader.loadClass(
"org.jivesoftware.messenger.XMPPBootContainer");
containerClass.newInstance();
}
catch (Exception e) {
......@@ -84,4 +75,4 @@ abstract public class ServerStarter {
}
return parent;
}
}
}
\ No newline at end of file
/**
* $RCSfile$
* $Revision$
* $Date$
*
* Copyright (C) 1999-2003 CoolServlets, Inc. All rights reserved.
*
* This software is the proprietary information of CoolServlets, Inc.
* Use is subject to license terms.
*/
package org.jivesoftware.messenger.starter;
import org.jivesoftware.messenger.container.starter.ServerStarter;
/**
* <p>A server starter for Jive Messenger running in standalone
* mode. The starter is primarily responsible for inspecting the
* commandline args (currently ignored) and starting the server
* with the correct bootstrap container name.</p>
*
* @author Iain Shigeoka
*/
public class XMPPServerStarter extends ServerStarter {
/**
* Starts Messenger.
*
* @param args The command line arguments (currently unused)
*/
public static void main(String[] args) {
// Update Build to use the weblogic parser.
//System.setProperty("javax.xml.stream.XMLInputFactory", "weblogic.xml.stax.XMLStreamInputFactory");
//System.setProperty("javax.xml.stream.XMLOutputFactory", "weblogic.xml.stax.XMLStreamOutputFactory");
new XMPPServerStarter().start();
}
protected String getBootContainerClassName() {
return "org.jivesoftware.messenger.XMPPBootContainer";
}
}
......@@ -121,7 +121,7 @@ public class WebManager extends WebBean {
public boolean isEmbedded() {
try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter");
ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
return true;
}
catch (Exception ignored) {
......
......@@ -61,7 +61,7 @@
// embedded mode?
boolean embeddedMode = false;
try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter");
ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
embeddedMode = true;
}
catch (Exception ignored) {}
......
......@@ -50,7 +50,7 @@
// embedded mode?
boolean embeddedMode = false;
try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter");
ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
embeddedMode = true;
}
catch (Exception ignored) {}
......
......@@ -50,7 +50,7 @@
// embedded mode?
boolean embeddedMode = false;
try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter");
ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
embeddedMode = true;
}
catch (Exception ignored) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment