/****************************************************************
 * 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 javax.annotation.Resource;

import org.apache.james.protocols.api.Request;
import org.apache.james.protocols.api.Response;
import org.apache.james.protocols.lib.POP3BeforeSMTPHelper;
import org.apache.james.protocols.pop3.POP3Response;
import org.apache.james.protocols.pop3.POP3Session;
import org.apache.james.protocols.pop3.core.PassCmdHandler;
import org.apache.james.protocols.pop3.mailbox.MailboxFactory;

/**
 * {@link PassCmdHandler} which also handles POP3 Before SMTP
 * 
 */
public class JamesPassCmdHandler extends PassCmdHandler {

    // TODO fix me as a final field...
    private MailboxFactory factory;

    public JamesPassCmdHandler() {
        super(null);
    }

    @Resource(name = "mailboxfactory")
    public void setMailboxFactory(MailboxFactory factory) {
        this.factory = factory;
    }

    @Override
    public Response onCommand(POP3Session session, Request request) {
        Response response =  super.onCommand(session, request);
        if (POP3Response.OK_RESPONSE.equals(response.getRetCode())) {
            POP3BeforeSMTPHelper.addIPAddress(session.getRemoteAddress().getAddress().toString());
        }
        return response;
    }
    
}

@@ -1241,24 +1241,56 @@
 er.core;%0D%0A%0D%0A
+import java.util.Collection;%0D%0A%0D%0A
 import javax
@@ -1403,32 +1403,95 @@
 .api.Response;%0D%0A
+import org.apache.james.protocols.api.handler.CommandHandler;%0D%0A
 import org.apach
@@ -1884,30 +1884,33 @@
 ler 
-extends PassCm
+implements Comman
 dHandler
  %7B%0D%0A
@@ -1909,88 +1909,61 @@
 dler
- %7B%0D%0A%0D%0A    // TODO fix me as a final field...%0D%0A    private MailboxFactory factory
+%3CPOP3Session%3E %7B%0D%0A%0D%0A    private PassCmdHandler handler
 ;%0D%0A%0D
@@ -2003,30 +2003,8 @@
  %7B%0D%0A
-        super(null);%0D%0A
     
@@ -2126,25 +2126,45 @@
 his.
-factory = 
+handler = new PassCmdHandler(
 factory
+)
 ;%0D%0A 
@@ -2175,23 +2175,8 @@
 %0D%0A%0D%0A
-    @Override%0D%0A
     
@@ -2275,11 +2275,13 @@
  =  
-sup
+handl
 er.o
@@ -2524,17 +2524,131 @@
 %0A    %7D%0D%0A
+%0D%0A
     
+@Override%0D%0A    public Collection%3CString%3E getImplCommands() %7B%0D%0A        return handler.getImplCommands();%0D%0A    %7D%0D%0A
 %0D%0A%7D%0D%0A

Fix JamesPassCmdHandler. This is part of JAMES-1360