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;
 
 
 
Implementation of LifecycleListener that will init and and destroy APR.

Author(s):
Remy Maucherat
Filip Hanik
Version:
$Revision: 1692 $ $Date: 2011-04-01 20:00:38 +0200 (Fri, 01 Apr 2011) $
Since:
4.1
 
 
 public class AprLifecycleListener
     implements LifecycleListener {
 
     // ---------------------------------------------- Constants
 
 
     protected static final int TCN_REQUIRED_MAJOR = 1;
     protected static final int TCN_REQUIRED_MINOR = 1;
     protected static final int TCN_REQUIRED_PATCH = 8;
     protected static final int TCN_RECOMMENDED_PV = 21;
 
 
     // ---------------------------------------------- Properties
     protected static String SSLEngine = "on"//default on
     protected static String SSLRandomSeed = "builtin";
     protected static boolean sslInitialized = false;
     protected static boolean aprInitialized = false;
 
     // ---------------------------------------------- LifecycleListener Methods
 
    
Primary entry point for startup and shutdown events.

Parameters:
event The event that has occurred
 
     public void lifecycleEvent(LifecycleEvent event) {
 
         if (..equals(event.getType())) {
              = init();
             if () {
                 try {
                     initializeSSL();
                 } catch (Throwable t) {
                     if (!..isDebugEnabled()) {
                         ..aprSslEngineInitFailed();
                     } else {
                         ..aprSslEngineInitFailedWithThrowable(t);
                     }
                 }
             }
         }
 
     }
 
     private boolean init()
     {
         int major = 0;
         int minor = 0;
         int patch = 0;
         if () {
             return true;    
         }
         try {
             String methodName = "initialize";
             Class<?> paramTypes[] = new Class[1];
             paramTypes[0] = String.class;
             Object paramValues[] = new Object[1];
             paramValues[0] = null;
            Class<?> clazz = Class.forName("org.apache.tomcat.jni.Library");
            Method method = clazz.getMethod(methodNameparamTypes);
            method.invoke(nullparamValues);
            major = clazz.getField("TCN_MAJOR_VERSION").getInt(null);
            minor = clazz.getField("TCN_MINOR_VERSION").getInt(null);
            patch = clazz.getField("TCN_PATCH_VERSION").getInt(null);
        } catch (Throwable t) {
            if (!..isDebugEnabled()) {
                ..aprInitFailed(System.getProperty("java.library.path"));
            } else {
                ..aprInitFailedWithThrowable(System.getProperty("java.library.path"), t);
            }
            return false;
        }
        if ((major != )  ||
            (minor != ) ||
            (patch <  )) {
            ..aprInvalidVersion(majorminorpatch
                    );
            return false;
        }
        if (patch <  ) {
            ..aprRecommendedVersion(majorminorpatch
                    );
        }
                    .);
        return true;
    }
    private static synchronized void initializeSSL()
    {
        if ("off".equalsIgnoreCase()) {
            return;
        }
        if () {
             //only once per VM
            return;
        }
        String methodName = "randSet";
        Class<?> paramTypes[] = new Class[1];
        paramTypes[0] = String.class;
        Object paramValues[] = new Object[1];
        paramValues[0] = ;
        Class<?> clazz = Class.forName("org.apache.tomcat.jni.SSL");
        Method method = clazz.getMethod(methodNameparamTypes);
        method.invoke(nullparamValues);
        methodName = "initialize";
        paramValues[0] = "on".equalsIgnoreCase()?null:;
        method = clazz.getMethod(methodNameparamTypes);
        method.invoke(nullparamValues);
 
         = true;
    }
    public static boolean isAprInitialized() {
        return ;
    }
    public String getSSLEngine() {
        return ;
    }
    public void setSSLEngine(String SSLEngine) {
        this. = SSLEngine;
    }
    public String getSSLRandomSeed() {
        return ;
    }
    public void setSSLRandomSeed(String SSLRandomSeed) {
        this. = SSLRandomSeed;
    }
New to GrepCode? Check out our FAQ X