Search in sources :

Example 1 with StandardService

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;
}
Also used : MBeanServer(javax.management.MBeanServer) Server(org.apache.catalina.Server) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardService(org.apache.catalina.core.StandardService)

Example 2 with StandardService

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();
}
Also used : StandardEngine(org.apache.catalina.core.StandardEngine) MBeanServer(javax.management.MBeanServer) Server(org.apache.catalina.Server) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardService(org.apache.catalina.core.StandardService)

Example 3 with StandardService

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);
            }
        }
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) Executor(org.apache.catalina.Executor) Lifecycle(org.apache.catalina.Lifecycle) StandardService(org.apache.catalina.core.StandardService) LifecycleListener(org.apache.catalina.LifecycleListener) Engine(org.apache.catalina.Engine)

Example 4 with StandardService

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);
}
Also used : StandardService(org.apache.catalina.core.StandardService) Before(org.junit.Before)

Example 5 with StandardService

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;
}
Also used : StandardServer(org.apache.catalina.core.StandardServer) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardService(org.apache.catalina.core.StandardService)

Aggregations

StandardService (org.apache.catalina.core.StandardService)7 Service (org.apache.catalina.Service)4 Engine (org.apache.catalina.Engine)3 StandardEngine (org.apache.catalina.core.StandardEngine)3 MBeanServer (javax.management.MBeanServer)2 Context (org.apache.catalina.Context)2 Host (org.apache.catalina.Host)2 Server (org.apache.catalina.Server)2 StandardContext (org.apache.catalina.core.StandardContext)2 StandardHost (org.apache.catalina.core.StandardHost)2 Before (org.junit.Before)2 ObjectName (javax.management.ObjectName)1 Executor (org.apache.catalina.Executor)1 Lifecycle (org.apache.catalina.Lifecycle)1 LifecycleListener (org.apache.catalina.LifecycleListener)1 Connector (org.apache.catalina.connector.Connector)1 StandardServer (org.apache.catalina.core.StandardServer)1 TesterMapRealm (org.apache.catalina.startup.TesterMapRealm)1 LoginConfig (org.apache.tomcat.util.descriptor.web.LoginConfig)1