@@ -0,0 +1,3157 @@
+/****************************************************************%0A * Licensed to the Apache Software Foundation (ASF) under one   *%0A * or more contributor license agreements.  See the NOTICE file *%0A * distributed with this work for additional information        *%0A * regarding copyright ownership.  The ASF licenses this file   *%0A * to you under the Apache License, Version 2.0 (the            *%0A * %22License%22); you may not use this file except in compliance   *%0A * with the License.  You may obtain a copy of the License at   *%0A *                                                              *%0A *   http://www.apache.org/licenses/LICENSE-2.0                 *%0A *                                                              *%0A * Unless required by applicable law or agreed to in writing,   *%0A * software distributed under the License is distributed on an  *%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *%0A * KIND, either express or implied.  See the License for the    *%0A * specific language governing permissions and limitations      *%0A * under the License.                                           *%0A ****************************************************************/%0Apackage org.apache.james.protocols.api;%0A%0Aimport java.util.Iterator;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0A/**%0A * Abstract base class for %7B@link ProtocolHandlerChain%7D implementations%0A * %0A *%0A */%0Apublic abstract class AbstractProtocolHandlerChain implements ProtocolHandlerChain%7B%0A%0A%09/**%0A%09 * Return a List of all Handlers%0A%09 * %0A%09 * @return handlerList%0A%09 */%0A%09protected abstract List%3CObject%3E getHandlers();%0A%09%0A%09/*%0A%09 * (non-Javadoc)%0A%09 * @see org.apache.james.protocols.api.ProtocolHandlerChain#getHandlers(java.lang.Class)%0A%09 */%0A    @SuppressWarnings(%22unchecked%22)%0A    public %3CT%3E LinkedList%3CT%3E getHandlers(Class%3CT%3E type) %7B%0A        LinkedList%3CT%3E result = new LinkedList%3CT%3E();%0A        List%3CObject%3E handlers = getHandlers();%0A        for (Iterator%3C?%3E i = handlers.iterator(); i.hasNext(); ) %7B%0A            Object handler = i.next();%0A            if (type.isInstance(handler)) %7B%0A                result.add((T)handler);%0A            %7D%0A        %7D%0A        return result;%0A    %7D%0A    %0A    /**%0A     * ExtensibleHandler wiring. This should get called after the class was constructed%0A     * and every stuff was set%0A     * %0A     * @throws WiringException %0A     */%0A    public final void wireExtensibleHandlers() throws WiringException %7B%0A        List%3CObject%3E handlers = getHandlers();%0A        for (Iterator%3C?%3E h = handlers.iterator(); h.hasNext(); ) %7B%0A            Object handler = h.next();%0A            if (handler instanceof ExtensibleHandler) %7B%0A                final ExtensibleHandler extensibleHandler = (ExtensibleHandler) handler;%0A                final List%3CClass%3C?%3E%3E markerInterfaces = extensibleHandler.getMarkerInterfaces();%0A                for (int i= 0;i %3C markerInterfaces.size(); i++) %7B%0A                    final Class%3C?%3E markerInterface = markerInterfaces.get(i);%0A                    final List%3C?%3E extensions = getHandlers(markerInterface);%0A                    extensibleHandler.wireExtensions(markerInterface,extensions);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add abstract implementation of ProtocolHandlerChain for simplify implementations