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, null);
defaultContext.setDocBase(docBase);
if (objName != null) {
defaultContext.setName(objName.getKeyProperty(NameFactory.J2EE_NAME));
}
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));
}
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;
}
this.objectName = objectName;
this.applicationListeners = applicationListeners;
this.manager = manager;