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 @@ ...@@ -157,7 +157,7 @@
<fileset dir="${src.i18n.dir}" includes="*.properties" /> <fileset dir="${src.i18n.dir}" includes="*.properties" />
<zipgroupfileset dir="${lib.merge.dir}" includes="*.jar"/> <zipgroupfileset dir="${lib.merge.dir}" includes="*.jar"/>
<manifest> <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)"/> <attribute name="Built-By" value="Jive Software (www.jivesoftware.org)"/>
</manifest> </manifest>
</jar> </jar>
......
...@@ -147,7 +147,7 @@ public abstract class BootstrapContainer implements Container, ServiceLookupProv ...@@ -147,7 +147,7 @@ public abstract class BootstrapContainer implements Container, ServiceLookupProv
private boolean setupMode = true; private boolean setupMode = true;
private static final String STARTER_CLASSNAME = private static final String STARTER_CLASSNAME =
"org.jivesoftware.messenger.container.starter.ServerStarter"; "org.jivesoftware.messenger.starter.ServerStarter";
private static final String WRAPPER_CLASSNAME = private static final String WRAPPER_CLASSNAME =
"org.tanukisoftware.wrapper.WrapperManager"; "org.tanukisoftware.wrapper.WrapperManager";
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* This software is the proprietary information of CoolServlets, Inc. * This software is the proprietary information of CoolServlets, Inc.
* Use is subject to license terms. * Use is subject to license terms.
*/ */
package org.jivesoftware.messenger.container.starter; package org.jivesoftware.messenger.starter;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
......
...@@ -8,60 +8,51 @@ ...@@ -8,60 +8,51 @@
* This software is the proprietary information of CoolServlets, Inc. * This software is the proprietary information of CoolServlets, Inc.
* Use is subject to license terms. * 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; import java.io.File;
/** /**
* A bootstrap class that configures classloaders to ensure easy, * Starts the core XMPP server. A ootstrap class that configures classloaders
* dynamic server startup. * to ensure easy, dynamic server startup.
* <p/> *
* <p>Extend this class and implement a main method that calls the start() * This class should be for standalone mode only. Jive Messenger servers launched
* method on this class in order to start the server.</p> * through a J2EE container (servlet/EJB) will use those environment's
* <p/> * classloading facilities to ensure proper startup.<p>
* <p>This class should be for standalone *
* mode only. Jive servers launched through a J2EE container * Tasks:<ul>
* (servlet/EJB) will use those environment's classloading facilities * <li>Add all jars in the lib directory to the classpath.</li>
* to ensure proper startup. * <li>Add the config directory to the classpath for loadResource()</li>
* <p/> * <li>Start the server</li>
* 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>
* </ul> * </ul>
* *
* @author Iain Shigeoka * @author Iain Shigeoka
*/ */
abstract public class ServerStarter { public class ServerStarter {
/** public static void main(String [] args) {
* <p>Obtain the name of the class for the bootstrap container. new ServerStarter().start();
* 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();
/** /**
* <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 * 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 // setup the classpath using JiveClassLoader
try { try {
// Load up the bootstrap container // Load up the bootstrap container
final ClassLoader parent = findParentClassLoader(); final ClassLoader parent = findParentClassLoader();
// TODO: Possibly load this lib dir as a java property?
File libDir = new File("../lib"); File libDir = new File("../lib");
ClassLoader loader = new JiveClassLoader(parent, libDir); ClassLoader loader = new JiveClassLoader(parent, libDir);
Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setContextClassLoader(loader);
Class containerClass = loader.loadClass(getBootContainerClassName()); Class containerClass = loader.loadClass(
"org.jivesoftware.messenger.XMPPBootContainer");
containerClass.newInstance(); containerClass.newInstance();
} }
catch (Exception e) { catch (Exception e) {
...@@ -84,4 +75,4 @@ abstract public class ServerStarter { ...@@ -84,4 +75,4 @@ abstract public class ServerStarter {
} }
return parent; 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 { ...@@ -121,7 +121,7 @@ public class WebManager extends WebBean {
public boolean isEmbedded() { public boolean isEmbedded() {
try { try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter"); ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
return true; return true;
} }
catch (Exception ignored) { catch (Exception ignored) {
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
// embedded mode? // embedded mode?
boolean embeddedMode = false; boolean embeddedMode = false;
try { try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter"); ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
embeddedMode = true; embeddedMode = true;
} }
catch (Exception ignored) {} catch (Exception ignored) {}
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
// embedded mode? // embedded mode?
boolean embeddedMode = false; boolean embeddedMode = false;
try { try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter"); ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
embeddedMode = true; embeddedMode = true;
} }
catch (Exception ignored) {} catch (Exception ignored) {}
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
// embedded mode? // embedded mode?
boolean embeddedMode = false; boolean embeddedMode = false;
try { try {
ClassUtils.forName("org.jivesoftware.messenger.container.starter.ServerStarter"); ClassUtils.forName("org.jivesoftware.messenger.starter.ServerStarter");
embeddedMode = true; embeddedMode = true;
} }
catch (Exception ignored) {} 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