View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.mina.transport.udp;
21  
22  import javax.net.ssl.SSLException;
23  
24  import org.apache.mina.api.IoClient;
25  import org.apache.mina.api.IoSession;
26  import org.apache.mina.service.executor.IoHandlerExecutor;
27  import org.apache.mina.service.server.AbstractIoServer;
28  
29  /**
30   * Base implementation for all the UDP servers.
31   * 
32   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
33   */
34  public abstract class AbstractUdpServer extends AbstractIoServer implements IoClient {
35      /**
36       * Create an new AbsractUdpServer instance
37       * 
38       * @param eventExecutor used for executing IoHandler event in another pool of thread (not in the low level I/O one).
39       *        Use <code>null</code> if you don't want one. Be careful, the IoHandler processing will block the I/O
40       *        operations.
41       */
42      protected AbstractUdpServer(IoHandlerExecutor ioHandlerExecutor) {
43          super(new DefaultUdpSessionConfig(), ioHandlerExecutor);
44      }
45  
46      /**
47       * Create an new AbsractUdpServer instance
48       * 
49       * @param sessionConfig The configuration to use for this server
50       * @param eventExecutor used for executing IoHandler event in another pool of thread (not in the low level I/O one).
51       *        Use <code>null</code> if you don't want one. Be careful, the IoHandler processing will block the I/O
52       *        operations.
53       */
54      protected AbstractUdpServer(UdpSessionConfig config, IoHandlerExecutor ioHandlerExecutor) {
55          super(config, ioHandlerExecutor);
56          this.config = new DefaultUdpSessionConfig();
57      }
58  
59      /**
60       * {@inheritDoc}
61       */
62      public void initSecured(IoSession session) throws SSLException {
63          throw new IllegalStateException("SSL is not supported for UDP");
64      }
65  
66      /**
67       * {@inheritDoc}
68       */
69      @Override
70      public UdpSessionConfig getSessionConfig() {
71          return (UdpSessionConfig) config;
72      }
73  
74      /**
75       * {@inheritDoc}
76       */
77      public void setSessionConfig(UdpSessionConfig config) {
78          this.config = config;
79      }
80  }