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: */package org.apache.geronimo.jetty6.handler;
017:
018: import org.mortbay.jetty.Handler;
019: import org.mortbay.jetty.HandlerContainer;
020: import org.mortbay.jetty.Server;
021: import org.mortbay.jetty.handler.AbstractHandler;
022: import org.mortbay.jetty.handler.AbstractHandlerContainer;
023:
024: /**
025: * @version $Rev: 601149 $ $Date: 2007-12-04 15:30:18 -0800 (Tue, 04 Dec 2007) $
026: */
027: public abstract class AbstractImmutableHandler implements Handler /*extends AbstractHandlerContainer*/{
028: protected final Handler next;
029:
030: protected AbstractImmutableHandler(Handler next) {
031: this .next = next;
032: }
033:
034: protected void doStart() throws Exception {
035: next.start();
036: }
037:
038: protected void doStop() throws Exception {
039: next.stop();
040: }
041:
042: public void setServer(Server server) {
043: // super.setServer(server);
044: next.setServer(server);
045: }
046:
047: public Server getServer() {
048: return next.getServer();
049: }
050:
051: public void destroy() {
052: next.destroy();
053: }
054:
055: public void lifecycleCommand(LifecycleCommand lifecycleCommand)
056: throws Exception {
057: if (next instanceof AbstractImmutableHandler) {
058: ((AbstractImmutableHandler) next)
059: .lifecycleCommand(lifecycleCommand);
060: } else {
061: lifecycleCommand.lifecycleMethod();
062: }
063: }
064:
065: public void addHandler(Handler handler) {
066: if (next instanceof HandlerContainer) {
067: ((HandlerContainer) next).addHandler(handler);
068: } else {
069: throw new RuntimeException(
070: "geronimo HandlerContainers are immutable");
071: }
072: }
073:
074: /**
075: * this is basically the implementation from HandlerWrapper.
076: * @param list partial list of handlers matching byClass (may be null)
077: * @param byClass class of the handlers we want
078: * @return extended list of handlers matching byClass
079: */
080: protected Object expandChildren(Object list, Class byClass) {
081: // return expandHandler(next, list, byClass);
082: return null;
083: }
084:
085: public void start() throws Exception {
086: next.start();
087: }
088:
089: public void stop() throws Exception {
090: next.stop();
091: }
092:
093: public boolean isRunning() {
094: return next.isRunning();
095: }
096:
097: public boolean isStarted() {
098: return next.isStarted();
099: }
100:
101: public boolean isStarting() {
102: return next.isStarting();
103: }
104:
105: public boolean isStopping() {
106: return next.isStopping();
107: }
108:
109: public boolean isStopped() {
110: return next.isStopped();
111: }
112:
113: public boolean isFailed() {
114: return false;
115: }
116: }
|