use of org.apache.catalina.Service 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();
}
use of org.apache.catalina.Service in project tomcat by apache.
the class ServiceMBean method getExecutor.
/**
* Retrieves executor by name
* @param name Name of the executor to be retrieved
* @return a string representation of the executor
* @throws MBeanException error accessing the associated service
*/
public String getExecutor(String name) throws MBeanException {
Service service = doGetManagedResource();
Executor executor = service.getExecutor(name);
return executor.toString();
}
use of org.apache.catalina.Service in project tomcat by apache.
the class StandardServerSF method storeChildren.
/**
* Store the specified server element children.
*
* @param aWriter Current output writer
* @param indent Indentation level
* @param aObject Server to store
* @param parentDesc The element description
* @throws Exception Configuration storing error
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aObject, StoreDescription parentDesc) throws Exception {
if (aObject instanceof StandardServer) {
StandardServer server = (StandardServer) aObject;
// Store nested <Listener> elements
LifecycleListener[] listeners = server.findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
/*LifecycleListener listener = null;
for (int i = 0; listener == null && i < listeners.length; i++)
if (listeners[i] instanceof ServerLifecycleListener)
listener = listeners[i];
if (listener != null) {
StoreDescription elementDesc = getRegistry()
.findDescription(
StandardServer.class.getName()
+ ".[ServerLifecycleListener]");
if (elementDesc != null) {
elementDesc.getStoreFactory().store(aWriter, indent,
listener);
}
}*/
// Store nested <GlobalNamingResources> element
NamingResourcesImpl globalNamingResources = server.getGlobalNamingResources();
StoreDescription elementDesc = getRegistry().findDescription(NamingResourcesImpl.class.getName() + ".[GlobalNamingResources]");
if (elementDesc != null) {
elementDesc.getStoreFactory().store(aWriter, indent, globalNamingResources);
}
// Store nested <Service> elements
Service[] services = server.findServices();
storeElementArray(aWriter, indent, services);
}
}
use of org.apache.catalina.Service in project tomcat by apache.
the class ThreadLocalLeakPreventionListener method registerListenersForServer.
private void registerListenersForServer(Server server) {
for (Service service : server.findServices()) {
Engine engine = service.getContainer();
engine.addContainerListener(this);
registerListenersForEngine(engine);
}
}
use of org.apache.catalina.Service in project spring-boot by spring-projects.
the class TomcatServletWebServerFactoryTests method tomcatAdditionalConnectors.
@Test
public void tomcatAdditionalConnectors() throws Exception {
TomcatServletWebServerFactory factory = getFactory();
Connector[] listeners = new Connector[4];
for (int i = 0; i < listeners.length; i++) {
Connector connector = mock(Connector.class);
given(connector.getState()).willReturn(LifecycleState.STOPPED);
listeners[i] = connector;
}
factory.addAdditionalTomcatConnectors(listeners);
this.webServer = factory.getWebServer();
Map<Service, Connector[]> connectors = ((TomcatWebServer) this.webServer).getServiceConnectors();
assertThat(connectors.values().iterator().next().length).isEqualTo(listeners.length + 1);
}
Aggregations