View Javadoc

1   /*
2    *   @(#) $Id: SessionConfig.java 357871 2005-12-20 01:56:40Z trustin $
3    *
4    *   Copyright 2004 The Apache Software Foundation
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   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, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   *
18   */
19  package org.apache.mina.common;
20  
21  import org.apache.mina.io.IoSession;
22  import org.apache.mina.io.WriteTimeoutException;
23  import org.apache.mina.io.datagram.DatagramSessionConfig;
24  import org.apache.mina.io.socket.SocketSessionConfig;
25  import org.apache.mina.protocol.ProtocolSession;
26  
27  /***
28   * Provides general or {@link TransportType}-specific configuration.
29   * <p>
30   * <ul>
31   *   <li><code>idleTime</code> (secs) - <code>sessionIdle</code> event is
32   *       enabled if this value is greater than 0.
33   *   <li><code>writeTimeout</code> (secs) - {@link WriteTimeoutException} is
34   *       thrown when the write buffer of session is full for the specified
35   *       time.</li>
36   * </ul>
37   * <p>
38   * Please refer to {@link SocketSessionConfig} and {@link DatagramSessionConfig}
39   * for {@link TransportType}-specific configurations.
40   * <p>
41   * {@link SessionConfig} can be obtained by {@link IoSession#getConfig()} and
42   * by {@link ProtocolSession#getConfig()}.  To adjust
43   * {@link TransportType}-specific settings, please downcast it:
44   * <pre>
45   * public void sessionOpened( IoSession s )
46   * {
47   *     ( ( SocketSessionConfig ) s.getConfig() ).setReuseAddress( true );
48   * }
49   * </pre>
50   * 
51   * @author The Apache Directory Project (dev@directory.apache.org)
52   * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
53   */
54  public interface SessionConfig
55  {
56      /***
57       * Returns idle time for the specified type of idleness in seconds.
58       */
59      int getIdleTime( IdleStatus status );
60  
61      /***
62       * Returnd idle time for the specified type of idleness in milliseconds.
63       */
64      long getIdleTimeInMillis( IdleStatus status );
65  
66      /***
67       * Sets idle time for the specified type of idleness in seconds.
68       */
69      void setIdleTime( IdleStatus status, int idleTime );
70  
71      /***
72       * Returns write timeout in seconds.
73       */
74      int getWriteTimeout();
75  
76      /***
77       * Returns write timeout in milliseconds.
78       */
79      long getWriteTimeoutInMillis();
80  
81      /***
82       * Sets write timeout in seconds.
83       */
84      void setWriteTimeout( int writeTimeout );
85  }