if (server != null) {
embedded = server.getService(serviceName);
engine = (Engine) embedded.getContainer();
} else {
this.engine = (Engine) engineGBean.getInternalObject();
StandardService embedded = new StandardService();
// Assemble FileLogger as a gbean
/*
* FileLogger fileLog = new FileLogger(); fileLog.setDirectory("."); fileLog.setPrefix("vsjMbedTC5");
* fileLog.setSuffix(".log"); fileLog.setTimestamp(true);
*/
// 2. Set the relevant properties of this object itself. In particular,
// you will want to establish the default Logger to be used, as well as
// the default Realm if you are using container-managed security.
//Add default contexts
/*File rootContext = new File(catalinaHome + "/ROOT");
String docBase = "";
if (rootContext.exists()) {
docBase = "ROOT";
}
Container[] hosts = engine.findChildren();
Context defaultContext;
ObjectName objName = objectName == null ? null : ObjectName.getInstance(objectName);
for (Container host : hosts) {
defaultContext = createContext("", classLoader, new WebAppInfo());
defaultContext.setDocBase(docBase);
//Set the name of default context with "", so that while accessing an un-existing context, the default one will be used
defaultContext.setName("");
if (defaultContext instanceof GeronimoStandardContext) {
GeronimoStandardContext ctx = (GeronimoStandardContext) defaultContext;
// Without this the Tomcat FallBack Application is left behind,
// MBean - ...J2EEApplication=none,J2EEServer=none,..........
ctx.setJ2EEApplication(null);
// if objectName != null extract J2EEServer from objectName/host
ctx.setJ2EEServer(objName == null ? "geronimo" : objName.getKeyProperty(NameFactory.J2EE_SERVER));
ctx.setJavaVMs(new String[]{});
ctx.setServer(objName == null ? "geronimo" : objName.getKeyProperty(NameFactory.J2EE_SERVER));
ctx.setInstanceManager(new TomcatInstanceManager(new Holder(), classLoader, null));
}
host.addChild(defaultContext);
}*/
// 6. Call addEngine() to attach this Engine to the set of defined
// Engines for this object.
embedded.setContainer(engine);
if (listenerChain != null){
LifecycleListenerGBean listenerGBean = listenerChain;
while(listenerGBean != null){
embedded.addLifecycleListener((LifecycleListener)listenerGBean.getInternalObject());
listenerGBean = listenerGBean.getNextListener();
}
}
// 9. Call start() to initiate normal operations of all the attached
// components.
embedded.start();
this.embedded = embedded;
//10. Set InstanceManager for each default Context
//The reason for placing the codes here (not in the step 2 ) is NPE is get while invoking the getServletContext method
/*for (Container host : hosts) {