Search in sources :

Example 56 with Service

use of org.apache.catalina.Service in project tomcat by apache.

the class StandardServer method getDomainInternal.

/**
 * Obtain the MBean domain for this server. The domain is obtained using
 * the following search order:
 * <ol>
 * <li>Name of first {@link org.apache.catalina.Engine}.</li>
 * <li>Name of first {@link Service}.</li>
 * </ol>
 */
@Override
protected String getDomainInternal() {
    String domain = null;
    Service[] services = findServices();
    if (services.length > 0) {
        Service service = services[0];
        if (service != null) {
            domain = service.getDomain();
        }
    }
    return domain;
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(org.apache.catalina.Service)

Example 57 with Service

use of org.apache.catalina.Service in project tomcat by apache.

the class ConnectorCreateRule method begin.

// --------------------------------------------------------- Public Methods
/**
 * Process the beginning of this element.
 *
 * @param namespace the namespace URI of the matching element, or an
 *   empty string if the parser is not namespace aware or the element has
 *   no namespace
 * @param name the local name if the parser is namespace aware, or just
 *   the element name otherwise
 * @param attributes The attribute list for this element
 */
@Override
public void begin(String namespace, String name, Attributes attributes) throws Exception {
    Service svc = (Service) digester.peek();
    Executor ex = null;
    String executorName = attributes.getValue("executor");
    if (executorName != null) {
        ex = svc.getExecutor(executorName);
    }
    String protocolName = attributes.getValue("protocol");
    Connector con = new Connector(protocolName);
    if (ex != null) {
        setExecutor(con, ex);
    }
    String sslImplementationName = attributes.getValue("sslImplementationName");
    if (sslImplementationName != null) {
        setSSLImplementationName(con, sslImplementationName);
    }
    digester.push(con);
    StringBuilder code = digester.getGeneratedCode();
    if (code != null) {
        code.append(System.lineSeparator());
        code.append(Connector.class.getName()).append(' ').append(digester.toVariableName(con));
        code.append(" = new ").append(Connector.class.getName());
        code.append("(new ").append(con.getProtocolHandlerClassName()).append("());");
        code.append(System.lineSeparator());
        if (ex != null) {
            code.append(digester.toVariableName(con)).append(".getProtocolHandler().setExecutor(");
            code.append(digester.toVariableName(svc)).append(".getExecutor(").append(executorName);
            code.append("));");
            code.append(System.lineSeparator());
        }
        if (sslImplementationName != null) {
            code.append("((").append(AbstractHttp11JsseProtocol.class.getName()).append("<?>) ");
            code.append(digester.toVariableName(con)).append(".getProtocolHandler()).setSslImplementationName(\"");
            code.append(sslImplementationName).append("\");");
            code.append(System.lineSeparator());
        }
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) Executor(org.apache.catalina.Executor) Service(org.apache.catalina.Service)

Example 58 with Service

use of org.apache.catalina.Service in project tomcat by apache.

the class TesterDigestAuthenticatorPerformance method setUp.

@Before
public void setUp() throws Exception {
    ConcurrentMessageDigest.init("MD5");
    // Configure the Realm
    TesterMapRealm realm = new TesterMapRealm();
    realm.addUser(USER, PWD);
    realm.addUserRole(USER, ROLE);
    // Add the Realm to the Context
    Context context = new StandardContext();
    context.setName(CONTEXT_PATH);
    context.setRealm(realm);
    Host host = new StandardHost();
    context.setParent(host);
    Engine engine = new StandardEngine();
    host.setParent(engine);
    Service service = new StandardService();
    engine.setService(service);
    // Configure the Login config
    LoginConfig config = new LoginConfig();
    config.setRealmName(REALM);
    context.setLoginConfig(config);
    // Make the Context and Realm visible to the Authenticator
    authenticator.setContainer(context);
    authenticator.setNonceCountWindowSize(8 * 1024);
    authenticator.start();
}
Also used : Context(org.apache.catalina.Context) StandardContext(org.apache.catalina.core.StandardContext) TesterMapRealm(org.apache.catalina.startup.TesterMapRealm) StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) StandardContext(org.apache.catalina.core.StandardContext) LoginConfig(org.apache.tomcat.util.descriptor.web.LoginConfig) StandardService(org.apache.catalina.core.StandardService) Service(org.apache.catalina.Service) StandardHost(org.apache.catalina.core.StandardHost) Host(org.apache.catalina.Host) StandardService(org.apache.catalina.core.StandardService) StandardEngine(org.apache.catalina.core.StandardEngine) Engine(org.apache.catalina.Engine) Before(org.junit.Before)

Example 59 with Service

use of org.apache.catalina.Service in project tomcat by apache.

the class ManagerServlet method getConnectors.

private Connector[] getConnectors() {
    Engine e = (Engine) host.getParent();
    Service s = e.getService();
    return s.findConnectors();
}
Also used : Service(org.apache.catalina.Service) Engine(org.apache.catalina.Engine)

Example 60 with Service

use of org.apache.catalina.Service 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();
    // Set configuration source
    ConfigFileLoader.setSource(new CatalinaBaseConfigurationSource(new File(basedir), null));
    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) JarFile(java.util.jar.JarFile) File(java.io.File)

Aggregations

Service (org.apache.catalina.Service)64 StandardService (org.apache.catalina.core.StandardService)25 Connector (org.apache.catalina.connector.Connector)22 Engine (org.apache.catalina.Engine)20 StandardEngine (org.apache.catalina.core.StandardEngine)16 ObjectName (javax.management.ObjectName)13 StandardHost (org.apache.catalina.core.StandardHost)12 Container (org.apache.catalina.Container)8 Executor (org.apache.catalina.Executor)8 Server (org.apache.catalina.Server)8 MBeanServer (javax.management.MBeanServer)7 InstanceNotFoundException (javax.management.InstanceNotFoundException)6 MBeanException (javax.management.MBeanException)6 Host (org.apache.catalina.Host)6 File (java.io.File)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)5 StandardContext (org.apache.catalina.core.StandardContext)5 JarFile (java.util.jar.JarFile)3