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

COVERAGE SUMMARY FOR SOURCE FILE [IoThreadPoolFilter.java]

nameclass, %method, %block, %line, %
IoThreadPoolFilter.java100% (1/1)78%  (7/9)77%  (86/112)79%  (31/39)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IoThreadPoolFilter100% (1/1)78%  (7/9)77%  (86/112)79%  (31/39)
exceptionCaught (IoFilter$NextFilter, IoSession, Throwable): void 0%   (0/1)0%   (0/7)0%   (0/2)
sessionIdle (IoFilter$NextFilter, IoSession, IdleStatus): void 0%   (0/1)0%   (0/7)0%   (0/2)
processEvent (Object, Session, EventType, Object): void 100% (1/1)80%  (47/59)82%  (18/22)
IoThreadPoolFilter (): void 100% (1/1)100% (3/3)100% (2/2)
dataRead (IoFilter$NextFilter, IoSession, ByteBuffer): void 100% (1/1)100% (9/9)100% (3/3)
dataWritten (IoFilter$NextFilter, IoSession, Object): void 100% (1/1)100% (7/7)100% (2/2)
filterWrite (IoFilter$NextFilter, IoSession, ByteBuffer, Object): void 100% (1/1)100% (6/6)100% (2/2)
sessionClosed (IoFilter$NextFilter, IoSession): void 100% (1/1)100% (7/7)100% (2/2)
sessionOpened (IoFilter$NextFilter, IoSession): void 100% (1/1)100% (7/7)100% (2/2)

1/*
2 *   @(#) $Id: IoThreadPoolFilter.java 165586 2005-05-02 06:27:27Z 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.filter;
20 
21import org.apache.mina.common.ByteBuffer;
22import org.apache.mina.common.IdleStatus;
23import org.apache.mina.common.Session;
24import org.apache.mina.io.IoHandler;
25import org.apache.mina.io.IoFilter;
26import org.apache.mina.io.IoSession;
27import org.apache.mina.util.BaseThreadPool;
28import org.apache.mina.util.EventType;
29import org.apache.mina.util.ThreadPool;
30 
31/**
32 * A Thread-pooling filter.  This filter forwards {@link IoHandler} events 
33 * to its thread pool.
34 * 
35 * @author Trustin Lee (trustin@apache.org)
36 * @version $Rev: 165586 $, $Date: 2005-05-02 15:27:27 +0900 $
37 * 
38 * @see ThreadPool
39 * @see BaseThreadPool
40 */
41public class IoThreadPoolFilter extends BaseThreadPool implements ThreadPool, IoFilter
42{
43    /**
44     * Creates a new instanceof this filter with default thread pool settings.
45     * You'll have to invoke {@link #start()} method to start threads actually.
46     */
47    public IoThreadPoolFilter()
48    {
49    }
50 
51    public void sessionOpened( NextFilter nextFilter, IoSession session )
52    {
53        fireEvent( nextFilter, session, EventType.OPENED, null );
54    }
55 
56    public void sessionClosed( NextFilter nextFilter, IoSession session )
57    {
58        fireEvent( nextFilter, session, EventType.CLOSED, null );
59    }
60 
61    public void sessionIdle( NextFilter nextFilter, IoSession session,
62                            IdleStatus status )
63    {
64        fireEvent( nextFilter, session, EventType.IDLE, status );
65    }
66 
67    public void exceptionCaught( NextFilter nextFilter, IoSession session,
68                                Throwable cause )
69    {
70        fireEvent( nextFilter, session, EventType.EXCEPTION, cause );
71    }
72 
73    public void dataRead( NextFilter nextFilter, IoSession session,
74                          ByteBuffer buf )
75    {
76        // MINA will release the buffer if this method returns.
77        buf.acquire();
78        fireEvent( nextFilter, session, EventType.READ, buf );
79    }
80 
81    public void dataWritten( NextFilter nextFilter, IoSession session,
82                            Object marker )
83    {
84        fireEvent( nextFilter, session, EventType.WRITTEN, marker );
85    }
86 
87    protected void processEvent( Object nextFilter0, Session session0,
88                                 EventType type, Object data )
89    {
90        NextFilter nextFilter = ( NextFilter ) nextFilter0;
91        IoSession session = ( IoSession ) session0;
92        if( type == EventType.READ )
93        {
94            ByteBuffer buf = ( ByteBuffer ) data;
95            nextFilter.dataRead( session, buf );
96            buf.release();
97        }
98        else if( type == EventType.WRITTEN )
99        {
100            nextFilter.dataWritten( session, data );
101        }
102        else if( type == EventType.EXCEPTION )
103        {
104            nextFilter.exceptionCaught( session, ( Throwable ) data );
105        }
106        else if( type == EventType.IDLE )
107        {
108            nextFilter.sessionIdle( session, ( IdleStatus ) data );
109        }
110        else if( type == EventType.OPENED )
111        {
112            nextFilter.sessionOpened( session );
113        }
114        else if( type == EventType.CLOSED )
115        {
116            nextFilter.sessionClosed( session );
117        }
118    }
119 
120    public void filterWrite( NextFilter nextFilter, IoSession session, ByteBuffer buf, Object marker ) throws Exception
121    {
122        nextFilter.filterWrite( session, buf, marker );
123    }
124}

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