EMMA Coverage Report (generated Wed Jun 08 12:10:57 KST 2005)
[all classes][org.apache.mina.io.socket]

COVERAGE SUMMARY FOR SOURCE FILE [SocketSession.java]

nameclass, %method, %block, %line, %
SocketSession.java100% (1/1)82%  (14/17)89%  (105/118)83%  (34/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SocketSession100% (1/1)82%  (14/17)89%  (105/118)83%  (34/41)
getLocalAddress (): SocketAddress 0%   (0/1)0%   (0/3)0%   (0/1)
getRemoteAddress (): SocketAddress 0%   (0/1)0%   (0/3)0%   (0/1)
getTransportType (): TransportType 0%   (0/1)0%   (0/2)0%   (0/1)
close (boolean): void 100% (1/1)72%  (13/18)60%  (6/10)
SocketSession (IoSessionManagerFilterChain, SocketChannel, IoHandler): void 100% (1/1)100% (44/44)100% (11/11)
getChannel (): SocketChannel 100% (1/1)100% (3/3)100% (1/1)
getConfig (): SessionConfig 100% (1/1)100% (3/3)100% (1/1)
getFilterChain (): IoFilterChain 100% (1/1)100% (3/3)100% (1/1)
getHandler (): IoHandler 100% (1/1)100% (3/3)100% (1/1)
getManagerFilterChain (): IoSessionManagerFilterChain 100% (1/1)100% (3/3)100% (1/1)
getSelectionKey (): SelectionKey 100% (1/1)100% (3/3)100% (1/1)
getWriteBufferQueue (): Queue 100% (1/1)100% (3/3)100% (1/1)
getWriteMarkerQueue (): Queue 100% (1/1)100% (3/3)100% (1/1)
isConnected (): boolean 100% (1/1)100% (4/4)100% (1/1)
notifyClose (): void 100% (1/1)100% (9/9)100% (4/4)
setSelectionKey (SelectionKey): void 100% (1/1)100% (4/4)100% (2/2)
write (ByteBuffer, Object): void 100% (1/1)100% (7/7)100% (2/2)

1/*
2 *   @(#) $Id: SocketSession.java 165302 2005-04-29 12:53:46Z 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 */
19package org.apache.mina.io.socket;
20 
21import java.net.SocketAddress;
22import java.nio.channels.SelectionKey;
23import java.nio.channels.SocketChannel;
24 
25import org.apache.mina.common.BaseSession;
26import org.apache.mina.common.ByteBuffer;
27import org.apache.mina.common.SessionConfig;
28import org.apache.mina.common.TransportType;
29import org.apache.mina.io.IoHandler;
30import org.apache.mina.io.IoFilterChain;
31import org.apache.mina.io.IoSession;
32import org.apache.mina.io.IoSessionFilterChain;
33import org.apache.mina.io.IoSessionManagerFilterChain;
34import org.apache.mina.util.Queue;
35 
36/**
37 * An {@link IoSession} for socket transport (TCP/IP).
38 * 
39 * @author Trustin Lee (trustin@apache.org)
40 * @version $Rev: 165302 $, $Date: 2005-04-29 21:53:46 +0900 $
41 */
42class SocketSession extends BaseSession implements IoSession
43{
44    private final IoSessionManagerFilterChain managerFilterChain;
45    
46    private final IoSessionFilterChain filterChain;
47 
48    private final SocketChannel ch;
49 
50    private final SocketSessionConfig config;
51 
52    private final Queue writeBufferQueue;
53 
54    private final Queue writeMarkerQueue;
55 
56    private final IoHandler handler;
57 
58    private final SocketAddress remoteAddress;
59 
60    private final SocketAddress localAddress;
61 
62    private SelectionKey key;
63    
64    private boolean disposed;
65 
66    /**
67     * Creates a new instance.
68     */
69    SocketSession( IoSessionManagerFilterChain managerFilterChain,
70                   SocketChannel ch, IoHandler defaultHandler )
71    {
72        this.managerFilterChain = managerFilterChain;
73        this.filterChain = new IoSessionFilterChain( managerFilterChain );
74        this.ch = ch;
75        this.config = new SocketSessionConfig( this );
76        this.writeBufferQueue = new Queue();
77        this.writeMarkerQueue = new Queue();
78        this.handler = defaultHandler;
79        this.remoteAddress = ch.socket().getRemoteSocketAddress();
80        this.localAddress = ch.socket().getLocalSocketAddress();
81    }
82    
83    IoSessionManagerFilterChain getManagerFilterChain()
84    {
85        return managerFilterChain;
86    }
87    
88    public IoFilterChain getFilterChain()
89    {
90        return filterChain;
91    }
92 
93    SocketChannel getChannel()
94    {
95        return ch;
96    }
97 
98    SelectionKey getSelectionKey()
99    {
100        return key;
101    }
102 
103    void setSelectionKey( SelectionKey key )
104    {
105        this.key = key;
106    }
107 
108    public IoHandler getHandler()
109    {
110        return handler;
111    }
112    
113    synchronized void notifyClose()
114    {
115        if( !disposed )
116        {
117            disposed = true;
118            notify();
119        }
120    }
121    
122 
123    public synchronized void close( boolean wait )
124    {
125        if( disposed )
126        {
127            return;
128        }
129 
130        SocketIoProcessor.getInstance().removeSession( this );
131        if( wait )
132        {
133            while( disposed )
134            {
135                try
136                {
137                    wait();
138                }
139                catch( InterruptedException e )
140                {
141                }
142            }
143        }
144    }
145 
146    Queue getWriteBufferQueue()
147    {
148        return writeBufferQueue;
149    }
150 
151    Queue getWriteMarkerQueue()
152    {
153        return writeMarkerQueue;
154    }
155 
156    public void write( ByteBuffer buf, Object marker )
157    {
158        filterChain.filterWrite( this, buf, marker );
159    }
160 
161    public TransportType getTransportType()
162    {
163        return TransportType.SOCKET;
164    }
165 
166    public boolean isConnected()
167    {
168        return ch.isConnected();
169    }
170 
171    public SessionConfig getConfig()
172    {
173        return config;
174    }
175 
176    public SocketAddress getRemoteAddress()
177    {
178        return remoteAddress;
179    }
180 
181    public SocketAddress getLocalAddress()
182    {
183        return localAddress;
184    }
185}

[all classes][org.apache.mina.io.socket]
EMMA 2.0.4217 (C) Vladimir Roubtsov