EMMA Coverage Report (generated Tue Dec 20 11:01:01 KST 2005)
[all classes][org.apache.mina.protocol.vmpipe]

COVERAGE SUMMARY FOR SOURCE FILE [VmPipeSession.java]

nameclass, %method, %block, %line, %
VmPipeSession.java0%   (0/1)0%   (0/15)0%   (0/191)0%   (0/53)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VmPipeSession0%   (0/1)0%   (0/15)0%   (0/191)0%   (0/53)
VmPipeSession (Object, SocketAddress, VmPipeSessionManagerFilterChain, Protoc... 0%   (0/1)0%   (0/77)0%   (0/23)
VmPipeSession (VmPipeSession, VmPipeAcceptor$Entry): void 0%   (0/1)0%   (0/38)0%   (0/10)
close (boolean): void 0%   (0/1)0%   (0/37)0%   (0/8)
getConfig (): SessionConfig 0%   (0/1)0%   (0/3)0%   (0/1)
getDecoder (): ProtocolDecoder 0%   (0/1)0%   (0/2)0%   (0/1)
getEncoder (): ProtocolEncoder 0%   (0/1)0%   (0/2)0%   (0/1)
getFilterChain (): ProtocolFilterChain 0%   (0/1)0%   (0/3)0%   (0/1)
getHandler (): ProtocolHandler 0%   (0/1)0%   (0/3)0%   (0/1)
getLocalAddress (): SocketAddress 0%   (0/1)0%   (0/3)0%   (0/1)
getManagerFilterChain (): VmPipeSessionManagerFilterChain 0%   (0/1)0%   (0/3)0%   (0/1)
getRemoteAddress (): SocketAddress 0%   (0/1)0%   (0/3)0%   (0/1)
getScheduledWriteRequests (): int 0%   (0/1)0%   (0/2)0%   (0/1)
getTransportType (): TransportType 0%   (0/1)0%   (0/2)0%   (0/1)
isConnected (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
write (Object): void 0%   (0/1)0%   (0/6)0%   (0/2)

1/*
2 * @(#) $Id: VmPipeSession.java 357871 2005-12-20 01:56:40Z trustin $
3 */
4package org.apache.mina.protocol.vmpipe;
5 
6import java.io.IOException;
7import java.net.SocketAddress;
8 
9import org.apache.mina.common.BaseSession;
10import org.apache.mina.common.SessionConfig;
11import org.apache.mina.common.TransportType;
12import org.apache.mina.protocol.ProtocolDecoder;
13import org.apache.mina.protocol.ProtocolEncoder;
14import org.apache.mina.protocol.ProtocolFilterChain;
15import org.apache.mina.protocol.ProtocolHandler;
16import org.apache.mina.protocol.ProtocolSession;
17import org.apache.mina.protocol.ProtocolSessionFilterChain;
18import org.apache.mina.protocol.vmpipe.VmPipeAcceptor.Entry;
19import org.apache.mina.util.ExceptionUtil;
20 
21/**
22 * A {@link ProtocolSession} for in-VM transport (VM_PIPE).
23 * 
24 * @author The Apache Directory Project (dev@directory.apache.org)
25 * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
26 */
27class VmPipeSession extends BaseSession implements ProtocolSession
28{
29    private final SocketAddress localAddress;
30 
31    private final SocketAddress remoteAddress;
32 
33    private final ProtocolHandler handler;
34    
35    private final VmPipeSessionConfig config = new VmPipeSessionConfig();
36 
37    private final ProtocolSessionFilterChain filterChain;
38    
39    private final VmPipeSessionManagerFilterChain managerFilterChain;
40 
41    final VmPipeSession remoteSession;
42 
43    final Object lock;
44 
45    boolean closed;
46 
47    /**
48     * Constructor for client-side session.
49     */
50    VmPipeSession( Object lock, SocketAddress localAddress,
51                   VmPipeSessionManagerFilterChain managerFilterChain,
52                   ProtocolHandler handler,
53                   Entry remoteEntry ) throws IOException
54    {
55        this.lock = lock;
56        this.localAddress = localAddress;
57        this.remoteAddress = remoteEntry.address;
58        this.handler = handler;
59        this.filterChain = new ProtocolSessionFilterChain( managerFilterChain );
60        this.managerFilterChain = managerFilterChain;
61 
62        remoteSession = new VmPipeSession( this, remoteEntry );
63        
64        // initialize remote session
65        try
66        {
67            remoteEntry.handler.sessionCreated( remoteSession );
68        }
69        catch( Throwable t )
70        {
71            remoteEntry.acceptor.getExceptionMonitor().exceptionCaught( remoteEntry.acceptor, t );
72            IOException e = new IOException( "Failed to initialize remote session." );
73            e.initCause( t );
74            throw e;
75        }
76        
77        // initialize client session
78        try
79        {
80            handler.sessionCreated( this );
81        }
82        catch( Throwable t )
83        {
84            ExceptionUtil.throwException( t );
85        }
86 
87        remoteEntry.managerFilterChain.sessionOpened( remoteSession );
88        managerFilterChain.sessionOpened( this );
89    }
90 
91    /**
92     * Constructor for server-side session.
93     */
94    VmPipeSession( VmPipeSession remoteSession, Entry entry )
95    {
96        this.lock = remoteSession.lock;
97        this.localAddress = remoteSession.remoteAddress;
98        this.remoteAddress = remoteSession.localAddress;
99        this.handler = entry.handler;
100        this.managerFilterChain = entry.managerFilterChain;
101        this.filterChain = new ProtocolSessionFilterChain( entry.managerFilterChain );
102        this.remoteSession = remoteSession;
103    }
104    
105    VmPipeSessionManagerFilterChain getManagerFilterChain()
106    {
107        return managerFilterChain;
108    }
109    
110    public ProtocolFilterChain getFilterChain()
111    {
112        return filterChain;
113    }
114 
115    public ProtocolHandler getHandler()
116    {
117        return handler;
118    }
119 
120    public ProtocolEncoder getEncoder()
121    {
122        return null;
123    }
124 
125    public ProtocolDecoder getDecoder()
126    {
127        return null;
128    }
129 
130    public void close( boolean wait )
131    {
132        synchronized( lock )
133        {
134            if( closed )
135                return;
136 
137            closed = remoteSession.closed = true;
138            managerFilterChain.sessionClosed( this );
139            remoteSession.getManagerFilterChain().sessionClosed( remoteSession );
140        }
141    }
142 
143    public void write( Object message )
144    {
145        this.filterChain.filterWrite( this, message );
146    }
147 
148    public int getScheduledWriteRequests()
149    {
150        return 0;
151    }
152 
153    public TransportType getTransportType()
154    {
155        return TransportType.VM_PIPE;
156    }
157 
158    public boolean isConnected()
159    {
160        return !closed;
161    }
162 
163    public SessionConfig getConfig()
164    {
165        return config;
166    }
167 
168    public SocketAddress getRemoteAddress()
169    {
170        return remoteAddress;
171    }
172 
173    public SocketAddress getLocalAddress()
174    {
175        return localAddress;
176    }
177}

[all classes][org.apache.mina.protocol.vmpipe]
EMMA 2.0.4217 (C) Vladimir Roubtsov