Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * /
 package org.apache.james.protocols.smtp;
 import java.util.List;
This org.apache.james.protocols.api.ProtocolHandlerChain implementation add all needed handlers to the chain to act as full blown SMTPServer. By default messages will just get rejected after the DATA command. If you want to accept the messagejust add a org.apache.james.protocols.smtp.hook.MessageHook implementation to the chain and handle the queuing
     private final List<ObjectdefaultHandlers = new ArrayList<Object>();
     private final List<Hookhooks = new ArrayList<Hook>();
     private final List<Objecthandlers = new ArrayList<Object>();
     public SMTPProtocolHandlerChain() throws WiringException {
         .add(new ExpnCmdHandler());
         .add(new EhloCmdHandler());
         .add(new HeloCmdHandler());
         .add(new HelpCmdHandler());
         .add(new MailCmdHandler());
         .add(new NoopCmdHandler());
         .add(new QuitCmdHandler());
         .add(new RcptCmdHandler());
         .add(new RsetCmdHandler());
         .add(new VrfyCmdHandler());
         .add(new DataCmdHandler());
         .add(new MailSizeEsmtpExtension());
         .add(new WelcomeMessageHandler());
         .add(new PostmasterAbuseRcptHook());
         .add(new ReceivedDataLineFilter());

Add the hook to the chain

     public final synchronized void addHook(Hook hookthrows WiringException {
         addHook(.size(), hook);

Add the hook to the chain on the given index

    public final synchronized void addHook(int indexHook hookthrows WiringException {

Remove the Hook found on the given index from the chain

    public final synchronized Hook removeHook(int indexthrows WiringException {
        Hook hook = .remove(index);
        return hook;

Return the index of the given hook

    public synchronized int getIndexOfHook(Hook hook) {
        return .indexOf(hook);
     * (non-Javadoc)
     * @see
     * org.apache.james.protocols.api.AbstractProtocolHandlerChain#getHandlers()
    protected synchronized List<ObjectgetHandlers() {
        return Collections.unmodifiableList();

Copy the lists
    private void copy() {
New to GrepCode? Check out our FAQ X