costin      2003/03/07 08:01:35

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardEngine.java
  Log:
  Added a "baseDir" attribute. In theory you should be able to have more engines
  in a JVM - but if all use catalina.base system property it won't work.
  
  Added JMX hooks to self-register in the Service - in JMX components
  can be loaded/reloaded in an arbitrary order.
  
  Use log for the start message instead of System.out.
  
  Revision  Changes    Path
  1.4       +49 -5     
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardEngine.java
  
  Index: StandardEngine.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardEngine.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StandardEngine.java       27 Jan 2003 23:36:16 -0000      1.3
  +++ StandardEngine.java       7 Mar 2003 16:01:35 -0000       1.4
  @@ -69,6 +69,8 @@
   import javax.servlet.ServletException;
   import javax.servlet.ServletRequest;
   import javax.servlet.http.HttpServletResponse;
  +import javax.management.ObjectName;
  +import javax.management.MBeanServer;
   import org.apache.catalina.Container;
   import org.apache.catalina.Context;
   import org.apache.catalina.DefaultContext;
  @@ -79,6 +81,8 @@
   import org.apache.catalina.Response;
   import org.apache.catalina.Service;
   import org.apache.catalina.util.ServerInfo;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
    * Standard implementation of the <b>Engine</b> interface.  Each
  @@ -93,6 +97,7 @@
       extends ContainerBase
       implements Engine {
   
  +    private static Log log = LogFactory.getLog(StandardEngine.class);
   
       // ----------------------------------------------------------- Constructors
   
  @@ -142,6 +147,11 @@
        */
       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;
   
       /**
        * DefaultContext config
  @@ -278,6 +288,16 @@
   
       }
   
  +    public String getBaseDir() {
  +        if( baseDir==null ) {
  +            baseDir=System.getProperty("catalina.base");
  +        }
  +        return baseDir;
  +    }
  +
  +    public void setBaseDir(String baseDir) {
  +        this.baseDir = baseDir;
  +    }
   
       // --------------------------------------------------------- Public Methods
   
  @@ -345,7 +365,8 @@
       public void start() throws LifecycleException {
   
           // Log our server identification information
  -        System.out.println(ServerInfo.getServerInfo());
  +        //System.out.println(ServerInfo.getServerInfo());
  +        log.info( "Starting Servlet Engine: " + ServerInfo.getServerInfo());
   
           // Standard container startup
           super.start();
  @@ -381,5 +402,28 @@
   
       }
   
  +    // -------------------- JMX registration  --------------------
  +
  +    public ObjectName preRegister(MBeanServer server,
  +                                  ObjectName name) throws Exception
  +    {
  +        super.preRegister(server,name);
  +
  +        // Register with the Service. XXX Do we really need a Service ??
  +        // BTW - the connector can go directly here.
  +        ObjectName serviceName=new ObjectName(domain +
  +                ":type=Service,name=Tomcat-Standalone");
  +        if( server.isRegistered( serviceName )) {
  +            log.info("Registering with the service ");
  +            try {
  +                server.invoke( serviceName, "setContainer",
  +                        new Object[] { this },
  +                    new String[] { "org.apache.catalina.Container" } );
  +            } catch( Exception ex ) {
  +                ex.printStackTrace();
  +            }
  +        }
   
  +        return name;
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to