interface. Each
child container must be a Host implementation to process the specific
fully qualified host name of that virtual host.
.
| Method from org.apache.catalina.core.StandardEngine Detail: |
public void addChild(Container child) {
if (!(child instanceof Host))
throw new IllegalArgumentException
(sm.getString("standardEngine.notHost"));
super.addChild(child);
}
Add a child Container, only if the proposed child is an implementation
of Host. |
public ObjectName createObjectName(String domain,
ObjectName parent) throws Exception {
if( log.isDebugEnabled())
log.debug("Create ObjectName " + domain + " " + parent );
return new ObjectName( domain + ":type=Engine");
}
|
public void destroy() throws LifecycleException {
if( ! initialized ) return;
initialized=false;
// if we created it, make sure it's also destroyed
// this call implizit this.stop()
((StandardService)service).destroy();
if( mbeans != null ) {
try {
Registry.getRegistry(null, null)
.invoke(mbeans, "destroy", false);
} catch (Exception e) {
log.error(sm.getString("standardEngine.unregister.mbeans.failed" ,mbeansFile), e);
}
}
//
if( mbeans != null ) {
try {
for( int i=0; i< mbeans.size() ; i++ ) {
Registry.getRegistry(null, null)
.unregisterComponent((ObjectName)mbeans.get(i));
}
} catch (Exception e) {
log.error(sm.getString("standardEngine.unregister.mbeans.failed", mbeansFile), e);
}
}
// force all metadata to be reloaded.
// That doesn't affect existing beans. We should make it per
// registry - and stop using the static.
Registry.getRegistry(null, null).resetMetadata();
}
|
public String getBaseDir() {
if( baseDir==null ) {
baseDir=System.getProperty("catalina.base");
}
if( baseDir==null ) {
baseDir=System.getProperty("catalina.home");
}
return baseDir;
}
|
public String getDefaultHost() {
return (defaultHost);
}
|
public String getDomain() {
if (domain!=null) {
return domain;
} else {
return getName();
}
}
|
public String getInfo() {
return (info);
}
Return descriptive information about this Container implementation and
the corresponding version number, in the format
<description>/<version>. |
public String getJvmRoute() {
return jvmRouteId;
}
Retrieve the cluster-wide unique identifier for this Engine.
This value is only useful in a load-balancing scenario. |
public String getMbeansFile() {
return mbeansFile;
}
|
public ObjectName getParentName() throws MalformedObjectNameException {
if (getService()==null) {
return null;
}
String name = getService().getName();
ObjectName serviceName=new ObjectName(domain +
":type=Service,serviceName="+name);
return serviceName;
}
|
public Realm getRealm() {
// ------------------------------------------------------------- Properties
Realm configured=super.getRealm();
// If no set realm has been called - default to JAAS
// This can be overriden at engine, context and host level
if( configured==null ) {
configured=new JAASRealm();
this.setRealm( configured );
}
return configured;
}
Provide a default in case no explicit configuration is set |
public Service getService() {
return (this.service);
}
Return the Service with which we are associated (if any). |
public void init() {
if( initialized ) return;
initialized=true;
if( oname==null ) {
// not registered in JMX yet - standalone mode
try {
if (domain==null) {
domain=getName();
}
if(log.isDebugEnabled())
log.debug( "Register " + domain );
oname=new ObjectName(domain + ":type=Engine");
controller=oname;
Registry.getRegistry(null, null)
.registerComponent(this, oname, null);
} catch( Throwable t ) {
log.info("Error registering ", t );
}
}
if( mbeansFile == null ) {
String defaultMBeansFile=getBaseDir() + "/conf/tomcat5-mbeans.xml";
File f=new File( defaultMBeansFile );
if( f.exists() ) mbeansFile=f.getAbsolutePath();
}
if( mbeansFile != null ) {
readEngineMbeans();
}
if( mbeans != null ) {
try {
Registry.getRegistry(null, null).invoke(mbeans, "init", false);
} catch (Exception e) {
log.error("Error in init() for " + mbeansFile, e);
}
}
// not needed since the following if statement does the same thing the right way
// remove later after checking
//if( service==null ) {
// try {
// ObjectName serviceName=getParentName();
// if( mserver.isRegistered( serviceName )) {
// log.info("Registering with the service ");
// try {
// mserver.invoke( serviceName, "setContainer",
// new Object[] { this },
// new String[] { "org.apache.catalina.Container" } );
// } catch( Exception ex ) {
// ex.printStackTrace();
// }
// }
// } catch( Exception ex ) {
// log.error("Error registering with service ");
// }
//}
if( service==null ) {
// for consistency...: we are probably in embeded mode
try {
service=new StandardService();
service.setContainer( this );
service.initialize();
} catch( Throwable t ) {
log.error(t);
}
}
}
|
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
super.preRegister(server,name);
this.setName( name.getDomain());
return name;
}
|
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}
|
public void setDefaultHost(String host) {
String oldDefaultHost = this.defaultHost;
if (host == null) {
this.defaultHost = null;
} else {
this.defaultHost = host.toLowerCase();
}
support.firePropertyChange("defaultHost", oldDefaultHost,
this.defaultHost);
}
|
public void setDomain(String domain) {
this.domain = domain;
}
|
public void setJvmRoute(String routeId) {
jvmRouteId = routeId;
}
|
public void setMbeansFile(String mbeansFile) {
this.mbeansFile = mbeansFile;
}
|
public void setName(String name) {
if( domain != null ) {
// keep name==domain, ignore override
// we are already registered
super.setName( domain );
return;
}
// The engine name is used as domain
domain=name; // XXX should we set it in init() ? It shouldn't matter
super.setName( name );
}
|
public void setParent(Container container) {
throw new IllegalArgumentException
(sm.getString("standardEngine.notParent"));
}
Disallow any attempt to set a parent for this Container, since an
Engine is supposed to be at the top of the Container hierarchy. |
public void setService(Service service) {
this.service = service;
}
Set the Service with which we are associated (if any). |
public void start() throws LifecycleException {
if( started ) {
return;
}
if( !initialized ) {
init();
}
// Look for a realm - that may have been configured earlier.
// If the realm is added after context - it'll set itself.
if( realm == null ) {
ObjectName realmName=null;
try {
realmName=new ObjectName( domain + ":type=Realm");
if( mserver.isRegistered(realmName ) ) {
mserver.invoke(realmName, "init",
new Object[] {},
new String[] {}
);
}
} catch( Throwable t ) {
log.debug("No realm for this engine " + realmName);
}
}
// Log our server identification information
//System.out.println(ServerInfo.getServerInfo());
if(log.isInfoEnabled())
log.info( "Starting Servlet Engine: " + ServerInfo.getServerInfo());
if( mbeans != null ) {
try {
Registry.getRegistry(null, null)
.invoke(mbeans, "start", false);
} catch (Exception e) {
log.error("Error in start() for " + mbeansFile, e);
}
}
// Standard container startup
super.start();
}
Start this Engine component. |
public void stop() throws LifecycleException {
super.stop();
if( mbeans != null ) {
try {
Registry.getRegistry(null, null).invoke(mbeans, "stop", false);
} catch (Exception e) {
log.error("Error in stop() for " + mbeansFile, e);
}
}
}
|
public String toString() {
StringBuffer sb = new StringBuffer("StandardEngine[");
sb.append(getName());
sb.append("]");
return (sb.toString());
}
Return a String representation of this component. |