use of org.apache.catalina.core.StandardService in project tomcat by apache.
the class MBeanFactory method getService.
private Service getService(ObjectName oname) throws Exception {
if (container instanceof Service) {
// Don't bother checking the domain - this is the only option
return (Service) container;
}
StandardService service = null;
String domain = oname.getDomain();
if (container instanceof Server) {
Service[] services = ((Server) container).findServices();
for (int i = 0; i < services.length; i++) {
service = (StandardService) services[i];
if (domain.equals(service.getObjectName().getDomain())) {
break;
}
}
}
if (service == null || !service.getObjectName().getDomain().equals(domain)) {
throw new Exception("Service with the domain is not found");
}
return service;
}
use of org.apache.catalina.core.StandardService 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.StandardService in project tomcat by apache.
the class StandardServiceSF method storeChildren.
/**
* Store the specified service element children.
*
* @param aWriter Current output writer
* @param indent Indentation level
* @param aService Service to store
* @param parentDesc The element description
* @throws Exception Configuration storing error
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aService, StoreDescription parentDesc) throws Exception {
if (aService instanceof StandardService) {
StandardService service = (StandardService) aService;
// Store nested <Listener> elements
LifecycleListener[] listeners = ((Lifecycle) service).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <Executor> elements
Executor[] executors = service.findExecutors();
storeElementArray(aWriter, indent, executors);
Connector[] connectors = service.findConnectors();
storeElementArray(aWriter, indent, connectors);
// Store nested <Engine> element
Engine container = service.getContainer();
if (container != null) {
StoreDescription elementDesc = getRegistry().findDescription(container.getClass());
if (elementDesc != null) {
IStoreFactory factory = elementDesc.getStoreFactory();
factory.store(aWriter, indent, container);
}
}
}
}
use of org.apache.catalina.core.StandardService in project pinpoint by naver.
the class StandardServiceModifierTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.service = new StandardService();
this.service.setContainer(this.engine);
}
use of org.apache.catalina.core.StandardService in project tomcat by apache.
the class Tomcat method getServer.
/**
* Get the server object. You can add listeners and few more
* customizations. JNDI is disabled by default.
* @return The Server
*/
public Server getServer() {
if (server != null) {
return server;
}
System.setProperty("catalina.useNaming", "false");
server = new StandardServer();
initBaseDir();
server.setPort(-1);
Service service = new StandardService();
service.setName("Tomcat");
server.addService(service);
return server;
}
Aggregations