rendered paste bodypackage org.apache.geronimo.system.main;
import java.io.ObjectInputStream;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gbean.GBeanData;
import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.InternalKernelException;
import org.apache.geronimo.kernel.KernelFactory;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.config.Configuration;
import org.apache.geronimo.kernel.log.GeronimoLogging;
import org.apache.geronimo.system.url.GeronimoURLFactory;
/**
* @version $Rev: 169154 $ $Date: 2005-05-08 15:35:23 -0400 (Sun, 08 May 2005) $
*/
public class CommandLine {
protected static final Log log;
static {
// This MUST be done before the first log is acquired
GeronimoLogging.initialize(GeronimoLogging.ERROR);
log = LogFactory.getLog(CommandLine.class.getName());
// Install our url factory
GeronimoURLFactory.install();
}
/**
* Command line entry point called by executable jar
* @param args command line args
*/
public static void main(String[] args) {
log.info("Server startup begun");
try {
// the interesting entries from the manifest
CommandLineManifest manifest = CommandLineManifest.getManifestEntries();
List configurations = manifest.getConfigurations();
ObjectName mainGBean = manifest.getMainGBean();
String mainMethod = manifest.getMainMethod();
new CommandLine().invokeMainGBean(configurations, mainGBean, mainMethod, args);
log.info("Server shutdown completed");
} catch (Exception e) {
ExceptionUtil.trimStackTrace(e);
e.printStackTrace();
System.exit(2);
throw new AssertionError();
}
}
private Kernel kernel;
private GBeanData configuration;
public void invokeMainGBean(List configurations, ObjectName mainGBean, String mainMethod, String[] args) throws Exception {
startKernel(configurations);
log.info("Server startup completed");
// invoke the main method
kernel.invoke(
mainGBean,
mainMethod,
new Object[]{args},
new String[]{String[].class.getName()});
log.info("Server shutdown begun");
stopKernel();
}