Java Code Examples for org.apache.catalina.Service#setContainer()

The following examples show how to use org.apache.catalina.Service#setContainer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MBeanFactory.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * 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();
}
 
Example 2
Source File: MBeanFactory.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * 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 
 *
 * @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);
    engine.setBaseDir(baseDir);

    Service service = new StandardService();
    service.setContainer(engine);
    service.setName(domain);
    
    ((Server) container).addService(service);
    
    return engine.getObjectName().toString();
}
 
Example 3
Source File: MBeanFactory.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * 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 
 *
 * @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);
    engine.setBaseDir(baseDir);

    Service service = new StandardService();
    service.setContainer(engine);
    service.setName(domain);
    
    ((Server) container).addService(service);
    
    return engine.getObjectName().toString();
}
 
Example 4
Source File: Tomcat.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Access to the engine, for further customization.
 * @return The engine
 */
public Engine getEngine() {
    Service service = getServer().findServices()[0];
    if (service.getContainer() != null) {
        return service.getContainer();
    }
    Engine engine = new StandardEngine();
    engine.setName( "Tomcat" );
    engine.setDefaultHost(hostname);
    engine.setRealm(createDefaultRealm());
    service.setContainer(engine);
    return engine;
}