Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.catalina.core;
 
 
 import static org.jboss.web.CatalinaMessages.MESSAGES;
 
 
 
Standard implementation of the Engine interface. Each child container must be a Host implementation to process the specific fully qualified host name of that virtual host.
You can set the jvmRoute direct or with the System.property jvmRoute.

Author(s):
Craig R. McClanahan
Version:
$Revision: 1673 $ $Date: 2011-03-12 18:58:07 +0100 (Sat, 12 Mar 2011) $
 
 
 public class StandardEngine
     extends ContainerBase
     implements Engine {
 
     // ----------------------------------------------------------- Constructors
 

    
Create a new StandardEngine component with the default basic Valve.
 
     public StandardEngine() {
 
         super();
         .setBasic(new StandardEngineValve());
         /* Set the jmvRoute using the system property jvmRoute */
         try {
             setJvmRoute(System.getProperty("jvmRoute"));
         } catch(Exception ex) {
         }
         // By default, the engine will hold the reloading thread
          = 10;
 
     }
 
 
     // ----------------------------------------------------- Instance Variables
 

    
Host name to use when no server host, or an unknown host, is specified in the request.
 
     private String defaultHost = null;


    
The descriptive information string for this implementation.
 
     private static final String info =
         "org.apache.catalina.core.StandardEngine/1.0";


    
The Service that owns this Engine, if any.
 
     private Service service = null;

    
Allow the base dir to be specified explicitely for each engine. In time we should stop using catalina.base property - otherwise we loose some flexibility.
 
     private String baseDir = null;

    
The JVM Route ID for this Tomcat instance. All Route ID's must be unique across the cluster.
    private String jvmRouteId;
    // ------------------------------------------------------------- Properties

    
Return the default host.
    public String getDefaultHost() {
        return ();
    }


    
Set the default host.

Parameters:
host The new default host
    public void setDefaultHost(String host) {
        String oldDefaultHost = this.;
        if (host == null) {
            this. = null;
        } else {
            this. = host.toLowerCase(.);
        }
        .firePropertyChange("defaultHost"oldDefaultHost,
                                   this.);
    }
    
    public void setName(String name ) {
        if != null ) {
            // keep name==domain, ignore override
            // we are already registered
            super.setName );
            return;
        }
        // The engine name is used as domain
        =name// XXX should we set it in init() ? It shouldn't matter
        super.setNamename );
    }


    
Set the cluster-wide unique identifier for this Engine. This value is only useful in a load-balancing scenario.

This property should not be changed once it is set.

    public void setJvmRoute(String routeId) {
         = routeId;
    }


    
Retrieve the cluster-wide unique identifier for this Engine. This value is only useful in a load-balancing scenario.
    public String getJvmRoute() {
        return ;
    }


    
Return the Service with which we are associated (if any).
    public Service getService() {
        return (this.);
    }


    
Set the Service with which we are associated (if any).

Parameters:
service The service that owns this Engine
    public void setService(Service service) {
        this. = service;
    }
    public String getBaseDir() {
        if==null ) {
            =System.getProperty("catalina.base");
        }
        if==null ) {
            =System.getProperty("catalina.home");
        }
        return ;
    }
    public void setBaseDir(String baseDir) {
        this. = baseDir;
    }
    // --------------------------------------------------------- Public Methods


    
Add a child Container, only if the proposed child is an implementation of Host.

Parameters:
child Child container to be added
    public void addChild(Container child) {
        if (!(child instanceof Host))
            throw .engineChildMustBeHost();
        super.addChild(child);
    }


    
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
    public String getInfo() {
        return ();
    }

    
Disallow any attempt to set a parent for this Container, since an Engine is supposed to be at the top of the Container hierarchy.

Parameters:
container Proposed parent Container
    public void setParent(Container container) {
        throw .engineHasNoParent();
    }
    private boolean initialized=false;
    
    public void init() {
        if ) return;
        =true;
        if (.....) {
            if==null ) {
                // not registered in JMX yet - standalone mode
                try {
                    if (==null) {
                        =getName();
                    }
                    =new ObjectName( + ":type=Engine");
                    =;
                    Registry.getRegistry(nullnull)
                    .registerComponent(thisnull);
                } catchThrowable t ) {
                    ..failedEngineJmxRegistration(t);
                }
            }
        }
        
        if==null ) {
            // for consistency...: we are probably in embeded mode
            try {
                =new StandardService();
                .setContainerthis );
                .initialize();
            } catchThrowable t ) {
                ..failedServiceCreation(t);
            }
        }
        
    }
    
    public void destroy() throws LifecycleException {
        if( !  ) return;
        =false;
        
        // if we created it, make sure it's also destroyed
        // this call implizit this.stop()
        ((StandardService)).destroy();
        if (.....) {
            if (  != null ) {
                try {
                    if ==  ) {
                        Registry.getRegistry(nullnull).unregisterComponent();
                    }
                } catchThrowable t ) {
                    ..failedContainerJmxUnregistration(t);
                }
            }
            // force all metadata to be reloaded.
            // That doesn't affect existing beans. We should make it per
            // registry - and stop using the static.
            Registry.getRegistry(nullnull).resetMetadata();
        }        
    }
    
    
Start this Engine component.

Throws:
org.apache.catalina.LifecycleException if a startup error occurs
    public void start() throws LifecycleException {
        if ) {
            return;
        }
        if( ! ) {
            init();
        }
        // Standard container startup
        super.start();
    }
    
    
Return a String representation of this component.
    public String toString() {
        StringBuilder sb = new StringBuilder("StandardEngine[");
        sb.append(getName());
        sb.append("]");
        return (sb.toString());
    }
    // ------------------------------------------------------ Protected Methods
    // -------------------- JMX registration  --------------------
    public ObjectName preRegister(MBeanServer server,
                                  ObjectName namethrows Exception
    {
        super.preRegister(server,name);
        this.setNamename.getDomain());
        return name;
    }
    // FIXME Remove -- not used 
        if (getService()==null) {
            return null;
        }
        String name = getService().getName();
        ObjectName serviceName=new ObjectName( +
                        ":type=Service,serviceName="+name);
        return serviceName;                
    }
    
    public ObjectName createObjectName(String domainObjectName parent)
        throws Exception
    {
        return new ObjectNamedomain + ":type=Engine");
    }
    public String getDomain() {
        if (!=null) {
            return ;
        } else { 
            return getName();
        }
    }
    
    public void setDomain(String domain) {
        this. = domain;
    }
    
New to GrepCode? Check out our FAQ X