AddToSystemProperty(extensionDirs, extensionDirsFromManifest, geronimoInstallDirectory);
// load this configuration
ClassLoader classLoader = Daemon.class.getClassLoader();
GBeanData configuration = new GBeanData();
ObjectInputStream ois = new ObjectInputStream(classLoader.getResourceAsStream("META-INF/config.ser"));
try {
configuration.readExternal(ois);
} finally {
ois.close();
}
URI configurationId = (URI) configuration.getAttribute("id");
ObjectName configName = Configuration.getConfigurationObjectName(configurationId);
configuration.setName(configName);
// todo: JNB for now we clear out the dependency list but we really need a way to resolve them
configuration.setAttribute("dependencies", Collections.EMPTY_LIST);
// create a mbean server
MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer("geronimo");
String mbeanServerId = (String) mbeanServer.getAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId");
// create the kernel
final Kernel kernel = KernelFactory.newInstance().createKernel("geronimo");
// boot the kernel
try {
kernel.boot();
} catch (Exception e) {
e.printStackTrace();
System.exit(2);
throw new AssertionError();
}
// load this configuration into the kernel
kernel.loadGBean(configuration, classLoader);
kernel.setAttribute(configName, "baseURL", classLoader.getResource("/"));
// add our shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown Thread") {
public void run() {
log.info("Server shutdown begun");
System.out.println("\rServer shutdown begun ");
kernel.shutdown();
log.info("Server shutdown completed");
System.out.println("Server shutdown completed");
}
});
// add the jmx bridge
ObjectName mbeanServerKernelBridgeName = new ObjectName("geronimo.boot:role=MBeanServerKernelBridge");
GBeanData mbeanServerKernelBridge = new GBeanData(mbeanServerKernelBridgeName, MBeanServerKernelBridge.GBEAN_INFO);
mbeanServerKernelBridge.setAttribute("mbeanServerId", mbeanServerId);
kernel.loadGBean(mbeanServerKernelBridge, classLoader);
kernel.startGBean(mbeanServerKernelBridgeName);
// start this configuration
kernel.startRecursiveGBean(configuration.getName());