EMMA Coverage Report (generated Sat Nov 12 08:39:53 KST 2005)
[all classes][org.apache.mina.io.filter]

COVERAGE SUMMARY FOR SOURCE FILE [IoThreadPoolFilter.java]

nameclass, %method, %block, %line, %
IoThreadPoolFilter.java100% (1/1)80%  (8/10)78%  (91/117)80%  (33/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IoThreadPoolFilter100% (1/1)80%  (8/10)78%  (91/117)80%  (33/41)
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% (4/4)100% (2/2)
IoThreadPoolFilter (String): void 100% (1/1)100% (4/4)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 332218 2005-11-10 03:52:42Z 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 The Apache Directory Project (dev@directory.apache.org)
36 * @version $Rev: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
37 * 
38 * @see ThreadPool
39 * @see BaseThreadPool
40 */
41public class IoThreadPoolFilter extends BaseThreadPool implements ThreadPool, IoFilter
42{
43    /**
44     * Creates a new instance of 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        this( "IoThreadPool" );
50    }
51    
52    /**
53     * Creates a new instance of this filter with default thread pool settings.
54     * You'll have to invoke {@link #start()} method to start threads actually.
55     * 
56     * @param threadNamePrefix the prefix of the thread names this pool will create.
57     */
58    public IoThreadPoolFilter( String threadNamePrefix )
59    {
60        super( threadNamePrefix );
61    }
62 
63    public void sessionOpened( NextFilter nextFilter, IoSession session )
64    {
65        fireEvent( nextFilter, session, EventType.OPENED, null );
66    }
67 
68    public void sessionClosed( NextFilter nextFilter, IoSession session )
69    {
70        fireEvent( nextFilter, session, EventType.CLOSED, null );
71    }
72 
73    public void sessionIdle( NextFilter nextFilter, IoSession session,
74                            IdleStatus status )
75    {
76        fireEvent( nextFilter, session, EventType.IDLE, status );
77    }
78 
79    public void exceptionCaught( NextFilter nextFilter, IoSession session,
80                                Throwable cause )
81    {
82        fireEvent( nextFilter, session, EventType.EXCEPTION, cause );
83    }
84 
85    public void dataRead( NextFilter nextFilter, IoSession session,
86                          ByteBuffer buf )
87    {
88        // MINA will release the buffer if this method returns.
89        buf.acquire();
90        fireEvent( nextFilter, session, EventType.READ, buf );
91    }
92 
93    public void dataWritten( NextFilter nextFilter, IoSession session,
94                            Object marker )
95    {
96        fireEvent( nextFilter, session, EventType.WRITTEN, marker );
97    }
98 
99    protected void processEvent( Object nextFilter0, Session session0,
100                                 EventType type, Object data )
101    {
102        NextFilter nextFilter = ( NextFilter ) nextFilter0;
103        IoSession session = ( IoSession ) session0;
104        if( type == EventType.READ )
105        {
106            ByteBuffer buf = ( ByteBuffer ) data;
107            nextFilter.dataRead( session, buf );
108            buf.release();
109        }
110        else if( type == EventType.WRITTEN )
111        {
112            nextFilter.dataWritten( session, data );
113        }
114        else if( type == EventType.EXCEPTION )
115        {
116            nextFilter.exceptionCaught( session, ( Throwable ) data );
117        }
118        else if( type == EventType.IDLE )
119        {
120            nextFilter.sessionIdle( session, ( IdleStatus ) data );
121        }
122        else if( type == EventType.OPENED )
123        {
124            nextFilter.sessionOpened( session );
125        }
126        else if( type == EventType.CLOSED )
127        {
128            nextFilter.sessionClosed( session );
129        }
130    }
131 
132    public void filterWrite( NextFilter nextFilter, IoSession session, ByteBuffer buf, Object marker ) throws Exception
133    {
134        nextFilter.filterWrite( session, buf, marker );
135    }
136}

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