You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2005/05/27 11:41:38 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/conf server.xml

remm        2005/05/27 02:41:38

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardServer.java LocalStrings.properties
               catalina/src/conf server.xml
  Added:       catalina/src/share/org/apache/catalina/core
                        AprLifecycleListener.java
  Log:
  - Add a listener for handling APR init/shutdown.
  - Unfortunately, some hacks remain in the Connector class, as the protocol
    handler is instantiated too early right now. Fixing it is not urgent, though.
  
  Revision  Changes    Path
  1.44      +2 -1      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- StandardServer.java	18 Apr 2005 22:02:02 -0000	1.43
  +++ StandardServer.java	27 May 2005 09:41:38 -0000	1.44
  @@ -734,6 +734,7 @@
                   log.info(sm.getString("standardServer.initialize.initialized"));
               return;
           }
  +        lifecycle.fireLifecycleEvent(INIT_EVENT, null);
           initialized = true;
   
           if( oname==null ) {
  
  
  
  1.22      +2 -0      jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/LocalStrings.properties,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- LocalStrings.properties	3 May 2005 17:24:10 -0000	1.21
  +++ LocalStrings.properties	27 May 2005 09:41:38 -0000	1.22
  @@ -14,6 +14,8 @@
   applicationRequest.badRequest=Request is not a javax.servlet.ServletRequestWrapper
   applicationResponse.badParent=Cannot locate parent Response implementation
   applicationResponse.badResponse=Response is not a javax.servlet.ServletResponseWrapper
  +aprListener.aprInit=The Apache Portable Runtime which allows optimal performance in production environments was not found on the java.library.path: {0}
  +aprListener.aprDestroy=Failed shutdown of Apache Portable Runtime
   containerBase.addDefaultMapper=Exception configuring default mapper of class {0}
   containerBase.alreadyStarted=Container {0} has already been started
   containerBase.notConfigured=No basic Valve has been configured
  
  
  
  1.1                  jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/AprLifecycleListener.java
  
  Index: AprLifecycleListener.java
  ===================================================================
  /*
   * Copyright 2002,2004 The Apache Software Foundation.
   * 
   * Licensed 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 java.lang.reflect.Method;
  import org.apache.catalina.Lifecycle;
  import org.apache.catalina.LifecycleEvent;
  import org.apache.catalina.LifecycleListener;
  import org.apache.catalina.util.StringManager;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  
  /**
   * Implementation of <code>LifecycleListener</code> that will init and
   * and destroy APR.
   *
   * @author Remy Maucherat
   * @version $Revision: 1.1 $ $Date: 2005/05/27 09:41:38 $
   * @since 4.1
   */
  
  public class AprLifecycleListener
      implements LifecycleListener {
  
      private static Log log = LogFactory.getLog(AprLifecycleListener.class);
  
      /**
       * The string manager for this package.
       */
      protected StringManager sm =
          StringManager.getManager(Constants.Package);
  
      // ---------------------------------------------- LifecycleListener Methods
  
  
      /**
       * Primary entry point for startup and shutdown events.
       *
       * @param event The event that has occurred
       */
      public void lifecycleEvent(LifecycleEvent event) {
  
          if (Lifecycle.INIT_EVENT.equals(event.getType())) {
              try {
                  String methodName = "initialize";
                  Class paramTypes[] = new Class[1];
                  paramTypes[0] = String.class;
                  Object paramValues[] = new Object[1];
                  paramValues[0] = null;
                  Method method = Class.forName("org.apache.tomcat.jni.Library")
                      .getMethod(methodName, paramTypes);
                  method.invoke(null, paramValues);
              } catch (Throwable t) {
                  if (!log.isDebugEnabled()) {
                      log.info(sm.getString("aprListener.aprInit", 
                              System.getProperty("java.library.path")));
                  } else {
                      log.debug(sm.getString("aprListener.aprInit", 
                              System.getProperty("java.library.path")), t);
                  }
              }
          } else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
              try {
                  String methodName = "terminate";
                  Class paramTypes[] = new Class[1];
                  paramTypes[0] = Boolean.TYPE;
                  Object paramValues[] = new Object[1];
                  paramValues[0] = Boolean.TRUE;
                  Method method = Class.forName("org.apache.tomcat.jni.Library")
                      .getMethod(methodName, paramTypes);
                  method.invoke(null, paramValues);
              } catch (Throwable t) {
                  if (!log.isDebugEnabled()) {
                      log.info(sm.getString("aprListener.aprDestroy"));
                  } else {
                      log.debug(sm.getString("aprListener.aprDestroy"), t);
                  }
              }
          }
  
      }
  
  
  }
  
  
  
  1.47      +1 -0      jakarta-tomcat-catalina/catalina/src/conf/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/conf/server.xml,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- server.xml	14 Apr 2005 21:12:31 -0000	1.46
  +++ server.xml	27 May 2005 09:41:38 -0000	1.47
  @@ -14,6 +14,7 @@
   
     <!-- Comment these entries out to disable JMX MBeans support used for the 
          administration web application -->
  +  <Listener className="org.apache.catalina.core.AprLifecycleListener" />
     <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
     <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
     <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org