001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.geronimo.tomcat.listener;
018
019 import org.apache.catalina.Lifecycle;
020 import org.apache.catalina.LifecycleEvent;
021 import org.apache.catalina.core.AprLifecycleListener;
022
023 /*
024 * GeronimoAprLifecycleListener translates START_EVENT to INIT_EVENT
025 * and STOP_EVENT to AFTER_STOP_EVENT for the AprLifecycleListener
026 * so that the APR library is initialized correctly. The translation is
027 * necessary as the INIT_EVENT and STOP_EVENT event are generated by Tomcat's
028 * StandardServer which is not present in this Tomcat integration code.
029 */
030 public class GeronimoAprLifecycleListener extends AprLifecycleListener {
031
032 @Override
033 public void lifecycleEvent(LifecycleEvent event) {
034 if (Lifecycle.START_EVENT.equals(event.getType())) {
035 event = new LifecycleEvent(event.getLifecycle(),
036 Lifecycle.INIT_EVENT,
037 event.getData());
038 } else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
039 event = new LifecycleEvent(event.getLifecycle(),
040 Lifecycle.AFTER_STOP_EVENT,
041 event.getData());
042 }
043
044 super.lifecycleEvent(event);
045 }
046 }