001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.transport.socket;
021
022import java.net.InetSocketAddress;
023import java.util.Set;
024
025import org.apache.mina.core.service.IoAcceptor;
026import org.apache.mina.core.session.IoSession;
027import org.apache.mina.core.session.IoSessionRecycler;
028
029/**
030 * {@link IoAcceptor} for datagram transport (UDP/IP).
031 *
032 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
033 */
034public interface DatagramAcceptor extends IoAcceptor {
035    /**
036     * @return the local InetSocketAddress which is bound currently.  If more than one
037     * address are bound, only one of them will be returned, but it's not
038     * necessarily the firstly bound address.
039     * This method overrides the {@link IoAcceptor#getLocalAddress()} method.
040     */
041    InetSocketAddress getLocalAddress();
042
043    /**
044     * @return a {@link Set} of the local InetSocketAddress which are bound currently.
045     * This method overrides the {@link IoAcceptor#getDefaultLocalAddress()} method.
046     */
047    InetSocketAddress getDefaultLocalAddress();
048
049    /**
050     * Sets the default local InetSocketAddress to bind when no argument is specified in
051     * {@link #bind()} method. Please note that the default will not be used
052     * if any local InetSocketAddress is specified.
053     * This method overrides the {@link IoAcceptor#setDefaultLocalAddress(java.net.SocketAddress)} method.
054     * 
055     * @param localAddress The local address
056     */
057    void setDefaultLocalAddress(InetSocketAddress localAddress);
058
059    /**
060     * @return the {@link IoSessionRecycler} for this service.
061     */
062    IoSessionRecycler getSessionRecycler();
063
064    /**
065     * Sets the {@link IoSessionRecycler} for this service.
066     *
067     * @param sessionRecycler <tt>null</tt> to use the default recycler
068     */
069    void setSessionRecycler(IoSessionRecycler sessionRecycler);
070
071    /**
072     * @return the default Datagram configuration of the new {@link IoSession}s
073     * created by this service.
074     */
075    DatagramSessionConfig getSessionConfig();
076}