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.common.support;
21  
22  import java.net.SocketAddress;
23  import java.util.Set;
24  
25  import org.apache.mina.common.ConnectFuture;
26  import org.apache.mina.common.DefaultIoFilterChainBuilder;
27  import org.apache.mina.common.IoConnector;
28  import org.apache.mina.common.IoFilterChainBuilder;
29  import org.apache.mina.common.IoHandler;
30  import org.apache.mina.common.IoServiceConfig;
31  import org.apache.mina.common.IoServiceListener;
32  
33  /**
34   * A delegated {@link IoConnector} that wraps the other {@link IoConnector}.
35   * 
36   * @author The Apache Directory Project (mina-dev@directory.apache.org)
37   * @version $Rev: 555855 $, $Date: 2007-07-13 12:19:00 +0900 (금, 13  7월 2007) $
38   */
39  public class DelegatedIoConnector implements IoConnector {
40      protected IoConnector delegate;
41  
42      /**
43       * Creates a new instance.
44       */
45      protected DelegatedIoConnector() {
46      }
47  
48      /**
49       * Sets the delegate.  This method should be invoked before any operation
50       * is requested.
51       */
52      protected void init(IoConnector delegate) {
53          this.delegate = delegate;
54      }
55  
56      public ConnectFuture connect(SocketAddress address, IoHandler handler) {
57          return delegate.connect(address, handler);
58      }
59  
60      public ConnectFuture connect(SocketAddress address, IoHandler handler,
61              IoServiceConfig config) {
62          return delegate.connect(address, handler, config);
63      }
64  
65      public ConnectFuture connect(SocketAddress address,
66              SocketAddress localAddress, IoHandler handler) {
67          return delegate.connect(address, localAddress, handler);
68      }
69  
70      public ConnectFuture connect(SocketAddress address,
71              SocketAddress localAddress, IoHandler handler,
72              IoServiceConfig config) {
73          return delegate.connect(address, localAddress, handler, config);
74      }
75  
76      public boolean isManaged(SocketAddress serviceAddress) {
77          return delegate.isManaged(serviceAddress);
78      }
79  
80      public Set getManagedServiceAddresses() {
81          return delegate.getManagedServiceAddresses();
82      }
83  
84      public Set getManagedSessions(SocketAddress serviceAddress) {
85          return delegate.getManagedSessions(serviceAddress);
86      }
87  
88      public IoServiceConfig getDefaultConfig() {
89          return delegate.getDefaultConfig();
90      }
91  
92      public IoFilterChainBuilder getFilterChainBuilder() {
93          return delegate.getFilterChainBuilder();
94      }
95  
96      public void setFilterChainBuilder(IoFilterChainBuilder builder) {
97          delegate.setFilterChainBuilder(builder);
98      }
99  
100     public DefaultIoFilterChainBuilder getFilterChain() {
101         return delegate.getFilterChain();
102     }
103 
104     public void addListener(IoServiceListener listener) {
105         delegate.addListener(listener);
106     }
107 
108     public void removeListener(IoServiceListener listener) {
109         delegate.removeListener(listener);
110     }
111 }