use of org.apache.catalina.Engine in project tomcat by apache.
the class SingleSignOn method startInternal.
@Override
protected synchronized void startInternal() throws LifecycleException {
Container c = getContainer();
while (c != null && !(c instanceof Engine)) {
c = c.getParent();
}
if (c instanceof Engine) {
engine = (Engine) c;
}
super.startInternal();
}
use of org.apache.catalina.Engine in project tomcat by apache.
the class FarmWarDeployer method start.
/*--Logic---------------------------------------------------*/
@Override
public void start() throws Exception {
if (started)
return;
Container hcontainer = getCluster().getContainer();
if (!(hcontainer instanceof Host)) {
log.error(sm.getString("farmWarDeployer.hostOnly"));
return;
}
host = (Host) hcontainer;
// Check to correct engine and host setup
Container econtainer = host.getParent();
if (!(econtainer instanceof Engine)) {
log.error(sm.getString("farmWarDeployer.hostParentEngine", host.getName()));
return;
}
Engine engine = (Engine) econtainer;
String hostname = null;
hostname = host.getName();
try {
oname = new ObjectName(engine.getName() + ":type=Deployer,host=" + hostname);
} catch (Exception e) {
log.error(sm.getString("farmWarDeployer.mbeanNameFail", engine.getName(), hostname), e);
return;
}
if (watchEnabled) {
watcher = new WarWatcher(this, getWatchDirFile());
if (log.isInfoEnabled()) {
log.info(sm.getString("farmWarDeployer.watchDir", getWatchDir()));
}
}
configBase = host.getConfigBaseFile();
// Retrieve the MBean server
mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
started = true;
count = 0;
getCluster().addClusterListener(this);
if (log.isInfoEnabled())
log.info(sm.getString("farmWarDeployer.started"));
}
use of org.apache.catalina.Engine in project tomcat by apache.
the class ThreadLocalLeakPreventionListener method stopIdleThreads.
/**
* Updates each ThreadPoolExecutor with the current time, which is the time
* when a context is being stopped.
*
* @param context
* the context being stopped, used to discover all the Connectors
* of its parent Service.
*/
private void stopIdleThreads(Context context) {
if (serverStopping)
return;
if (!(context instanceof StandardContext) || !((StandardContext) context).getRenewThreadsWhenStoppingContext()) {
log.debug("Not renewing threads when the context is stopping. " + "It is not configured to do it.");
return;
}
Engine engine = (Engine) context.getParent().getParent();
Service service = engine.getService();
Connector[] connectors = service.findConnectors();
if (connectors != null) {
for (Connector connector : connectors) {
ProtocolHandler handler = connector.getProtocolHandler();
Executor executor = null;
if (handler != null) {
executor = handler.getExecutor();
}
if (executor instanceof ThreadPoolExecutor) {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
threadPoolExecutor.contextStopping();
} else if (executor instanceof StandardThreadExecutor) {
StandardThreadExecutor stdThreadExecutor = (StandardThreadExecutor) executor;
stdThreadExecutor.contextStopping();
}
}
}
}
use of org.apache.catalina.Engine in project tomcat by apache.
the class MBeanFactory method createStandardContext.
/**
* Create a new StandardContext.
*
* @param parent MBean Name of the associated parent component
* @param path The context path for this Context
* @param docBase Document base directory (or WAR) for this Context
* @param xmlValidation if XML descriptors should be validated
* @param xmlNamespaceAware if the XML processor should namespace aware
* @return the object name of the created context
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardContext(String parent, String path, String docBase, boolean xmlValidation, boolean xmlNamespaceAware) throws Exception {
// Create a new StandardContext instance
StandardContext context = new StandardContext();
path = getPathStr(path);
context.setPath(path);
context.setDocBase(docBase);
context.setXmlValidation(xmlValidation);
context.setXmlNamespaceAware(xmlNamespaceAware);
ContextConfig contextConfig = new ContextConfig();
context.addLifecycleListener(contextConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
ObjectName deployer = new ObjectName(pname.getDomain() + ":type=Deployer,host=" + pname.getKeyProperty("host"));
if (mserver.isRegistered(deployer)) {
String contextName = context.getName();
mserver.invoke(deployer, "addServiced", new Object[] { contextName }, new String[] { "java.lang.String" });
String configPath = (String) mserver.getAttribute(deployer, "configBaseName");
String baseName = context.getBaseName();
File configFile = new File(new File(configPath), baseName + ".xml");
if (configFile.isFile()) {
context.setConfigFile(configFile.toURI().toURL());
}
mserver.invoke(deployer, "manageApp", new Object[] { context }, new String[] { "org.apache.catalina.Context" });
mserver.invoke(deployer, "removeServiced", new Object[] { contextName }, new String[] { "java.lang.String" });
} else {
log.warn("Deployer not found for " + pname.getKeyProperty("host"));
Service service = getService(pname);
Engine engine = service.getContainer();
Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
host.addChild(context);
}
// Return the corresponding MBean name
return context.getObjectName().toString();
}
use of org.apache.catalina.Engine in project tomcat by apache.
the class MBeanFactory method createStandardHost.
/**
* Create a new StandardHost.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this Host
* @param appBase Application base directory name
* @param autoDeploy Should we auto deploy?
* @param deployOnStartup Deploy on server startup?
* @param deployXML Should we deploy Context XML config files property?
* @param unpackWARs Should we unpack WARs when auto deploying?
* @return the object name of the created host
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardHost(String parent, String name, String appBase, boolean autoDeploy, boolean deployOnStartup, boolean deployXML, boolean unpackWARs) throws Exception {
// Create a new StandardHost instance
StandardHost host = new StandardHost();
host.setName(name);
host.setAppBase(appBase);
host.setAutoDeploy(autoDeploy);
host.setDeployOnStartup(deployOnStartup);
host.setDeployXML(deployXML);
host.setUnpackWARs(unpackWARs);
// add HostConfig for active reloading
HostConfig hostConfig = new HostConfig();
host.addLifecycleListener(hostConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
Engine engine = service.getContainer();
engine.addChild(host);
// Return the corresponding MBean name
return (host.getObjectName().toString());
}
Aggregations