use of org.apache.catalina.core.StandardEngine in project tomcat by apache.
the class MBeanFactory method createStandardServiceEngine.
/**
* Creates a new StandardService and StandardEngine.
*
* @param domain Domain name for the container instance
* @param defaultHost Name of the default host to be used in the Engine
* @param baseDir Base directory value for Engine
* @return the object name of the created service
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception {
if (!(container instanceof Server)) {
throw new Exception("Container not Server");
}
StandardEngine engine = new StandardEngine();
engine.setDomain(domain);
engine.setName(domain);
engine.setDefaultHost(defaultHost);
Service service = new StandardService();
service.setContainer(engine);
service.setName(domain);
((Server) container).addService(service);
return engine.getObjectName().toString();
}
use of org.apache.catalina.core.StandardEngine in project tomcat by apache.
the class MBeanFactory method getParentContainerFromParent.
/**
* Get Parent Container to add its child component
* from parent's ObjectName
*/
private Container getParentContainerFromParent(ObjectName pname) throws Exception {
String type = pname.getKeyProperty("type");
String j2eeType = pname.getKeyProperty("j2eeType");
Service service = getService(pname);
StandardEngine engine = (StandardEngine) service.getContainer();
if ((j2eeType != null) && (j2eeType.equals("WebModule"))) {
String name = pname.getKeyProperty("name");
name = name.substring(2);
int i = name.indexOf('/');
String hostName = name.substring(0, i);
String path = name.substring(i);
Container host = engine.findChild(hostName);
String pathStr = getPathStr(path);
Container context = host.findChild(pathStr);
return context;
} else if (type != null) {
if (type.equals("Engine")) {
return engine;
} else if (type.equals("Host")) {
String hostName = pname.getKeyProperty("host");
Container host = engine.findChild(hostName);
return host;
}
}
return null;
}
use of org.apache.catalina.core.StandardEngine in project tomcat by apache.
the class Tomcat method getEngine.
/**
* Access to the engine, for further customization.
* @return The engine
*/
public Engine getEngine() {
Service service = getServer().findServices()[0];
if (service.getContainer() != null) {
return service.getContainer();
}
Engine engine = new StandardEngine();
engine.setName("Tomcat");
engine.setDefaultHost(hostname);
engine.setRealm(createDefaultRealm());
service.setContainer(engine);
return engine;
}
use of org.apache.catalina.core.StandardEngine in project tomee by apache.
the class GlobalListenerSupport method serviceRemoved.
/**
* Service removed.
*
* @param service tomcat service
*/
private void serviceRemoved(final Service service) {
final Container container = service.getContainer();
if (container instanceof StandardEngine) {
final StandardEngine engine = (StandardEngine) container;
engineRemoved(engine);
}
}
use of org.apache.catalina.core.StandardEngine in project tomcat by apache.
the class StandardEngineSF method storeChildren.
/**
* Store the specified Engine properties.
*
* @param aWriter
* PrintWriter to which we are storing
* @param indent
* Number of spaces to indent this element
* @param aEngine
* Object whose properties are being stored
*
* @exception Exception
* if an exception occurs while storing
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, StoreDescription parentDesc) throws Exception {
if (aEngine instanceof StandardEngine) {
StandardEngine engine = (StandardEngine) aEngine;
// Store nested <Listener> elements
LifecycleListener[] listeners = ((Lifecycle) engine).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <Realm> element
Realm realm = engine.getRealm();
Realm parentRealm = null;
// TODO is this case possible? (see it a old Server 5.0 impl)
if (engine.getParent() != null) {
parentRealm = engine.getParent().getRealm();
}
if (realm != parentRealm) {
storeElement(aWriter, indent, realm);
}
// Store nested <Valve> elements
Valve[] valves = engine.getPipeline().getValves();
if (valves != null && valves.length > 0) {
List<Valve> engineValves = new ArrayList<>();
for (int i = 0; i < valves.length; i++) {
if (!(valves[i] instanceof ClusterValve))
engineValves.add(valves[i]);
}
storeElementArray(aWriter, indent, engineValves.toArray());
}
// store all <Cluster> elements
Cluster cluster = engine.getCluster();
if (cluster != null) {
storeElement(aWriter, indent, cluster);
}
// store all <Host> elements
Container[] children = engine.findChildren();
storeElementArray(aWriter, indent, children);
}
}
Aggregations