/**
* Licensed to niosmtp developers ('niosmtp') under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* niosmtp 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 me.normanmaurer.niosmtp.transport;

import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;


import me.normanmaurer.niosmtp.SMTPMultiResponseCallback;
import me.normanmaurer.niosmtp.SMTPPipeliningRequest;
import me.normanmaurer.niosmtp.SMTPRequest;

import org.slf4j.Logger;

/**
 * Abstract base implementation of a {@link SMTPClientSession}
 * 
 * @author Norman Maurer
 *
 */
public abstract class AbstractSMTPClientSession implements SMTPClientSession {


    private final Logger logger;
    private final SMTPDeliveryMode mode;
    private final SMTPClientConfig config;
    private final Set<String> extensions = new HashSet<String>();
    private final Map<String, Object> attrs = new HashMap<String, Object>();
    private final InetSocketAddress remote;
    private final InetSocketAddress local;
    
    public AbstractSMTPClientSession(Logger logger, SMTPClientConfig config, SMTPDeliveryMode mode, InetSocketAddress local, InetSocketAddress remote) {
        this.logger = logger;
        this.mode = mode;
        this.config = config;
        this.remote = remote;
        this.local = local;
    }

    @Override
    public InetSocketAddress getRemoteAddress() {
        return remote;
    }

    @Override
    public InetSocketAddress getLocalAddress() {
        return local;
    }

    @Override
    public SMTPDeliveryMode getDeliveryMode() {
        return mode;
    }

    @Override
    public Map<String, Object> getAttributes() {
        return attrs;
    }

    @Override
    public Set<String> getSupportedExtensions() {
        return Collections.unmodifiableSet(extensions);
    }

    @Override
    public void addSupportedExtensions(String extensions) {
        this.extensions.add(extensions);
    }


    @Override
    public Logger getLogger() {
        return logger;
    }

  
    @Override
    public SMTPClientConfig getConfig() {
        return config;
    }

    /**
     * Implementation which just send each {@link SMTPRequest} which is hold in the {@link SMTPPipeliningRequest#getRequests()} method via
     * {@link #send(SMTPRequest, me.normanmaurer.niosmtp.SMTPResponseCallback)} method. 
     * 
     */
    @Override
    public void send(SMTPPipeliningRequest request, SMTPMultiResponseCallback callback) {
        for(SMTPRequest req: request.getRequests()) {
            send(req, callback);
        }
    }
    
    
}

@@ -915,20 +915,16 @@
 va.util.
-Hash
 Map;%0D%0Aim
@@ -938,23 +938,67 @@
 va.util.
+Set;%0D%0Aimport java.util.concurrent.Concurrent
 Hash
-Set
+Map
 ;%0D%0Aimpor
@@ -1001,32 +1001,53 @@
 mport java.util.
+concurrent.Concurrent
 Map;%0D%0Aimport jav
@@ -1049,24 +1049,51 @@
 t java.util.
+concurrent.CopyOnWriteArray
 Set;%0D%0A%0D%0A%0D%0Aim
@@ -1610,16 +1610,32 @@
 e final 
+CopyOnWriteArray
 Set%3CStri
@@ -1655,20 +1655,32 @@
 s = new 
-Hash
+CopyOnWriteArray
 Set%3CStri
@@ -1705,16 +1705,26 @@
 e final 
+Concurrent
 Map%3CStri
@@ -1747,16 +1747,26 @@
 s = new 
+Concurrent
 HashMap%3C

Prepare for concurrent access