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

COVERAGE SUMMARY FOR SOURCE FILE [Client.java]

nameclass, %method, %block, %line, %
Client.java0%   (0/1)0%   (0/2)0%   (0/95)0%   (0/28)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Client0%   (0/1)0%   (0/2)0%   (0/95)0%   (0/28)
Client (): void 0%   (0/1)0%   (0/3)0%   (0/1)
main (String []): void 0%   (0/1)0%   (0/92)0%   (0/27)

1/*
2 *   @(#) $Id: Client.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.examples.sumup;
20 
21import java.io.IOException;
22import java.net.InetSocketAddress;
23 
24import org.apache.mina.io.filter.IoThreadPoolFilter;
25import org.apache.mina.io.socket.SocketConnector;
26import org.apache.mina.protocol.ProtocolProvider;
27import org.apache.mina.protocol.ProtocolSession;
28import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
29import org.apache.mina.protocol.io.IoProtocolConnector;
30 
31/**
32 * (<strong>Entry Point</strong>) Starts SumUp client.
33 * 
34 * @author The Apache Directory Project
35 * @version $Rev: 332218 $, $Date: 2005-11-10 12:52:42 +0900 $
36 */
37public class Client
38{
39    private static final String HOSTNAME = "localhost";
40    private static final int PORT = 8080;
41    private static final int CONNECT_TIMEOUT = 30; // seconds
42 
43    public static void main( String[] args ) throws Throwable
44    {
45        if( args.length == 0 )
46        {
47            System.out.println( "Please specify the list of any integers" );
48            return;
49        }
50 
51        // prepare values to sum up
52        int[] values = new int[ args.length ];
53        for( int i = 0; i < args.length; i++ )
54        {
55            values[ i ] = Integer.parseInt( args[ i ] );
56        }
57 
58        // Create I/O and Protocol thread pool filter.
59        // I/O thread pool performs encoding and decoding of messages.
60        // Protocol thread pool performs actual protocol flow.
61        IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
62        ProtocolThreadPoolFilter protocolThreadPoolFilter = new ProtocolThreadPoolFilter();
63 
64        // and start both.
65        ioThreadPoolFilter.start();
66        protocolThreadPoolFilter.start();
67 
68        IoProtocolConnector connector = new IoProtocolConnector(
69                new SocketConnector() );
70        connector.getIoConnector().getFilterChain().addFirst( "threadPool",
71                ioThreadPoolFilter );
72        connector.getFilterChain().addFirst( "threadPool",
73                protocolThreadPoolFilter );
74 
75        ProtocolProvider protocolProvider = new ClientProtocolProvider( values );
76        ProtocolSession session;
77        for( ;; )
78        {
79            try
80            {
81                session = connector.connect( new InetSocketAddress( HOSTNAME,
82                        PORT ), CONNECT_TIMEOUT, protocolProvider );
83                break;
84            }
85            catch( IOException e )
86            {
87                System.err.println( "Failed to connect." );
88                e.printStackTrace();
89                Thread.sleep( 5000 );
90            }
91        }
92 
93        // wait until the summation is done
94        while( session.isConnected() )
95        {
96            Thread.sleep( 100 );
97        }
98 
99        ioThreadPoolFilter.stop();
100        protocolThreadPoolFilter.stop();
101    }
102}

[all classes][org.apache.mina.examples.sumup]
EMMA 2.0.4217 (C) Vladimir Roubtsov