Package org.apache.james.pop3server.core

Source Code of org.apache.james.pop3server.core.POP3CommandDispatcherLineHandler

/****************************************************************
* 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   *
*                                                              *
*   http://www.apache.org/licenses/LICENSE-2.0                 *
*                                                              *
* 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.pop3server.core;

import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;

import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.pop3server.POP3Session;
import org.apache.james.protocols.api.AbstractCommandDispatcher;
import org.apache.james.protocols.api.CommandHandler;

/**
* Dispatch POP3 {@link CommandHandler}
*
*
*/
public class POP3CommandDispatcherLineHandler extends AbstractCommandDispatcher<POP3Session> {
    private final static String[] mandatoryCommands = { "USER", "PASS", "LIST" };
    private final CommandHandler<POP3Session> unknownHandler = new UnknownCmdHandler();
    private MailboxManager manager;

    @Resource(name = "mailboxmanager")
    public void setMailboxManager(MailboxManager manager) {
        this.manager = manager;
    }

    /**
     * @see org.apache.james.api.protocol.AbstractCommandDispatcher#getMandatoryCommands()
     */
    protected List<String> getMandatoryCommands() {
        return Arrays.asList(mandatoryCommands);
    }

    /**
     * @see org.apache.james.api.protocol.AbstractCommandDispatcher#getUnknownCommandHandler()
     */
    protected CommandHandler<POP3Session> getUnknownCommandHandler() {
        return unknownHandler;
    }

    /**
     * @see org.apache.james.api.protocol.AbstractCommandDispatcher#getUnknownCommandHandlerIdentifier()
     */
    protected String getUnknownCommandHandlerIdentifier() {
        return UnknownCmdHandler.COMMAND_NAME;
    }

    @Override
    public void onLine(POP3Session session, byte[] line) {
        MailboxSession mSession = (MailboxSession) session.getState().get(POP3Session.MAILBOX_SESSION);

        // notify the mailboxmanager about the start of the processing
        manager.startProcessingRequest(mSession);

        // do the processing
        super.onLine(session, line);

        // notify the mailboxmanager about the end of the processing
        manager.endProcessingRequest(mSession);

    }

}
TOP

Related Classes of org.apache.james.pop3server.core.POP3CommandDispatcherLineHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.