engine.setDefaultHost(localHost.getName()); engine.setJvmRoute(jvmRoute); engine.setService(new StandardService()); container.addEngine(engine);
engine.setBackgroundProcessorDelay(-1); final StandardService service = new StandardService(); service.setName(config.serviceName()); service.setContainer(engine); service.addConnector(connector);
@Override protected String getDomainInternal() { String domain = null; Container engine = getContainer(); // Use the engine name first if (engine != null) { domain = engine.getName(); } // No engine or no engine name, use the service name if (domain == null) { domain = getName(); } // No service name, return null which will trigger the use of the // default return domain; }
/** * Invoke a pre-startup initialization. This is used to allow connectors * to bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (engine != null) { engine.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof JmxEnabled) { ((JmxEnabled) executor).setDomain(getDomain()); } executor.init(); } // Initialize mapper listener mapperListener.init(); // Initialize our defined Connectors synchronized (connectorsLock) { for (Connector connector : connectors) { connector.init(); } } }
/** * Return a String representation of this component. */ @Override public String toString() { StringBuilder sb = new StringBuilder("StandardService["); sb.append(getName()); sb.append("]"); return sb.toString(); }
/** * @return the JMX service names. */ public ObjectName[] getServiceNames() { ObjectName onames[]=new ObjectName[ services.length ]; for( int i=0; i<services.length; i++ ) { onames[i]=((StandardService)services[i]).getObjectName(); } return onames; }
/** * Add a new Connector to the set of defined Connectors. The newly * added Connector will be associated with the most recently added Engine. * * @param connector The connector to be added * * @exception IllegalStateException if no engines have been added yet */ public synchronized void addConnector(Connector connector) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, "Adding connector (" + connector.getInfo() + ")"); } // Make sure we have a Container to send requests to if (engines.length < 1) throw new IllegalStateException (rb.getString(LogFacade.NO_ENGINES_DEFINED)); /* * Add the connector. This will set the connector's container to the * most recently added Engine */ super.addConnector(connector); }
/** * Create a new StandardService. * * @param parent MBean Name of the associated parent component * @param name Unique name of this StandardService * * @exception Exception if an MBean cannot be created or registered */ public String createStandardService(String parent, String name, String domain) throws Exception { // Create a new StandardService instance StandardService service = new StandardService(); service.setName(name); // Add the new instance to its parent component Server server = ServerFactory.getServer(); server.addService(service); // Return the corresponding MBean name return (service.getObjectName().toString()); }
StandardService service = (StandardService) getService(oname); Engine engine = (Engine) service.getContainer(); String name = oname.getKeyProperty("name"); name = name.substring(2);
@Override protected void destroyInternal() throws LifecycleException { mapperListener.destroy(); // Destroy our defined Connectors synchronized (connectorsLock) { for (Connector connector : connectors) { connector.destroy(); } } // Destroy any Executors for (Executor executor : findExecutors()) { executor.destroy(); } if (engine != null) { engine.destroy(); } super.destroyInternal(); }
/** * Adds a named executor to the service * @param ex Executor */ @Override public void addExecutor(Executor ex) { synchronized (executors) { if (!executors.contains(ex)) { executors.add(ex); if (getState().isAvailable()) try { ex.start(); } catch (LifecycleException x) { log.error("Executor.start", x); } } } }
setState(LifecycleState.STARTING);
Executor[] executors = service.findExecutors(); storeElementArray(aWriter, indent, executors); Connector connectors[] = service.findConnectors(); storeElementArray(aWriter, indent, connectors); Container container = service.getContainer(); if (container != null) { StoreDescription elementDesc = getRegistry().findDescription(
public void init() { try { initialize(); } catch( Throwable t ) { log.error(sm.getString("standardService.initialize.failed",domain),t); } }
@Override public void start() throws LifecycleException { if( log.isInfoEnabled() ) log.info("Starting tomcat server"); // Validate the setup of our required system properties initDirs(); // Initialize some naming specific properties initNaming(); // Validate and update our current component state if (started) throw new LifecycleException (sm.getString("embedded.alreadyStarted")); lifecycle.fireLifecycleEvent(START_EVENT, null); started = true; service.initialize(); // Start our defined Engines first for (int i = 0; i < engines.length; i++) { if (engines[i] instanceof Lifecycle) ((Lifecycle) engines[i]).start(); } // Start our defined Connectors second Connector[] connectors = service.findConnectors(); for (int i = 0; i < connectors.length; i++) { connectors[i].initialize(); if (connectors[i] instanceof Lifecycle) ((Lifecycle) connectors[i]).start(); } }
/** * Invoke a pre-startup initialization. This is used to allow connectors * to bind to restricted ports under Unix operating environments. */ @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (engine != null) { engine.init(); } // Initialize any Executors for (Executor executor : findExecutors()) { if (executor instanceof JmxEnabled) { ((JmxEnabled) executor).setDomain(getDomain()); } executor.init(); } // Initialize mapper listener mapperListener.init(); // Initialize our defined Connectors synchronized (connectorsLock) { for (Connector connector : connectors) { connector.init(); } } }
/** * Return a String representation of this component. */ public String toString() { StringBuilder sb = new StringBuilder("StandardService["); sb.append(getName()); sb.append("]"); return (sb.toString()); }
/** * Return the JMX service names. */ public ObjectName[] getServiceNames() { ObjectName onames[]=new ObjectName[ services.length ]; for( int i=0; i<services.length; i++ ) { onames[i]=((StandardService)services[i]).getObjectName(); } return onames; }
/** * Add a new Connector to the set of defined Connectors. The newly * added Connector will be associated with the most recently added Engine. * * @param connector The connector to be added * * @exception IllegalStateException if no engines have been added yet */ public synchronized void addConnector(Connector connector) { if( log.isDebugEnabled() ) { log.debug("Adding connector (" + connector.getInfo() + ")"); } // Make sure we have a Container to send requests to if (engines.length < 1) throw new IllegalStateException (sm.getString("embedded.noEngines")); /* * Add the connector. This will set the connector's container to the * most recently added Engine */ super.addConnector(connector); }
try { Container engine=this.getContainer(); domain=engine.getName(); oname=new ObjectName(domain + ":type=Service,serviceName="+name);