All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jetty.server.handler.HandlerCollection Maven / Gradle / Ivy

//
//  ========================================================================
//  Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
//  ------------------------------------------------------------------------
//  All rights reserved. This program and the accompanying materials
//  are made available under the terms of the Eclipse Public License v1.0
//  and Apache License v2.0 which accompanies this distribution.
//
//      The Eclipse Public License is available at
//      http://www.eclipse.org/legal/epl-v10.html
//
//      The Apache License v2.0 is available at
//      http://www.opensource.org/licenses/apache2.0.php
//
//  You may elect to redistribute this code under either of these licenses.
//  ========================================================================
//

package org.eclipse.jetty.server.handler;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.MultiException;

/* ------------------------------------------------------------ */
/** A collection of handlers.  
 * 

* The default implementations calls all handlers in list order, * regardless of the response status or exceptions. Derived implementation * may alter the order or the conditions of calling the contained * handlers. *

* * @org.apache.xbean.XBean */ public class HandlerCollection extends AbstractHandlerContainer { private final boolean _mutableWhenRunning; private volatile Handler[] _handlers; private boolean _parallelStart=false; /* ------------------------------------------------------------ */ public HandlerCollection() { _mutableWhenRunning=false; } /* ------------------------------------------------------------ */ public HandlerCollection(boolean mutableWhenRunning) { _mutableWhenRunning=mutableWhenRunning; } /* ------------------------------------------------------------ */ /** * @return Returns the handlers. */ public Handler[] getHandlers() { return _handlers; } /* ------------------------------------------------------------ */ /** * * @param handlers The handlers to set. */ public void setHandlers(Handler[] handlers) { if (!_mutableWhenRunning && isStarted()) throw new IllegalStateException(STARTED); Handler [] old_handlers = _handlers==null?null:_handlers.clone(); _handlers = handlers; Server server = getServer(); MultiException mex = new MultiException(); for (int i=0;handlers!=null && i0;) try{_handlers[i].stop();}catch(Throwable e){mex.add(e);} } mex.ifExceptionThrow(); } /* ------------------------------------------------------------ */ @Override public void setServer(Server server) { if (isStarted()) throw new IllegalStateException(STARTED); Server old_server=getServer(); super.setServer(server); Handler[] h=getHandlers(); for (int i=0;h!=null && i0 ) setHandlers((Handler[])LazyList.removeFromArray(handlers, handler)); } /* ------------------------------------------------------------ */ @Override protected Object expandChildren(Object list, Class byClass) { Handler[] handlers = getHandlers(); for (int i=0;handlers!=null && i





© 2015 - 2024 Weber Informatics LLC | Privacy Policy