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 018 019 package org.apache.geronimo.jetty6.handler; 020 021 import org.mortbay.jetty.Handler; 022 import org.mortbay.jetty.HandlerContainer; 023 import org.mortbay.jetty.Server; 024 import org.mortbay.jetty.handler.AbstractHandler; 025 import org.mortbay.jetty.handler.AbstractHandlerContainer; 026 027 /** 028 * @version $Rev: 520756 $ $Date: 2007-03-21 01:24:12 -0400 (Wed, 21 Mar 2007) $ 029 */ 030 public abstract class AbstractImmutableHandler extends AbstractHandlerContainer { 031 protected final AbstractHandler next; 032 033 protected AbstractImmutableHandler(AbstractHandler next) { 034 this.next = next; 035 } 036 037 protected void doStart() throws Exception { 038 next.start(); 039 } 040 041 protected void doStop() throws Exception { 042 next.stop(); 043 } 044 045 public void setServer(Server server) { 046 super.setServer(server); 047 next.setServer(server); 048 } 049 050 public void lifecycleCommand(LifecycleCommand lifecycleCommand) throws Exception { 051 if (next instanceof AbstractImmutableHandler) { 052 ((AbstractImmutableHandler) next).lifecycleCommand(lifecycleCommand); 053 } else { 054 lifecycleCommand.lifecycleMethod(); 055 } 056 } 057 058 059 public void addHandler(Handler handler) { 060 if (next instanceof HandlerContainer) { 061 ((HandlerContainer) next).addHandler(handler); 062 } else { 063 throw new RuntimeException("geronimo HandlerContainers are immutable"); 064 } 065 } 066 067 /** 068 * this is basically the implementation from HandlerWrapper. 069 * @param list partial list of handlers matching byClass (may be null) 070 * @param byClass class of the handlers we want 071 * @return extended list of handlers matching byClass 072 */ 073 protected Object expandChildren(Object list, Class byClass) 074 { 075 return expandHandler(next, list, byClass); 076 } 077 078 }