I've been playing with cornerstone/phoenix all week trying to get a
simple application to work.

At this point, I'm just trying to stub out the guts of the
helloworldserver with some
functionality that I would like to see.

If I leave the original code alone ... it works just fine ...  when
I swap it out
for mine ....  I can telnet to the port, but then nothing happens .. no
System.out ...
no debug log entries (even though that's the first thing that should
happen)
, .... and the entire VM seems to lock up ...

Anyone else seen this behavior?

I tried this using phoenix-4.0a1 and the latest cornerstone (oct 03)


/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software
License
 * version 1.1, a copy of which has been included with this distribution
in
 * the LICENSE file.
 */
package org.apache.avalon.cornerstone.demos.helloworldserver;

import java.io.IOException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InterruptedIOException;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import java.net.SocketException;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.logger.AbstractLoggable;
import
org.apache.avalon.cornerstone.services.connection.ConnectionHandler;

import com.scooter.app.listener.*;
import com.scooter.util.err.*;
import com.scooter.app.queue.*;
import com.scooter.app.converter.protocol.*;

/**
 * This handles an individual incoming request.  It outputs a greeting
as html.
 * @author  Paul Hammant <[EMAIL PROTECTED]>
 * @author Federico Barbieri <[EMAIL PROTECTED]>
 * @version 1.0
 */
public class HelloWorldHandler
    extends AbstractLoggable
    implements Component, ConnectionHandler
{
    protected static int        c_counter;

    protected static String prefix;
    protected String            m_greeting;
    private DataInputStream     input;
    private DataOutputStream    output;
    public static int BUFFER_SIZE = 30000;

    protected HelloWorldHandler( final String greeting )
    {
        m_greeting = greeting;
    }

    /**
     * Handle a connection.
     * This handler is responsible for processing connections as they
occur.
     *
     * @param socket the connection
     * @exception IOException if an error reading from socket occurs
     */
    public void handleConnection( final Socket socket )
        throws IOException
    {

/*

        final String remoteHost = socket.getInetAddress().getHostName();

        final String remoteIP =
socket.getInetAddress().getHostAddress();
        final PrintWriter out = new PrintWriter(
socket.getOutputStream(), true );

        try
        {
            getLogger().debug( "creating instance of ListenerService
...");
            getLogger().debug( "      ... done");
            out.println( "<html><body><b>" + m_greeting + "!</b><br>
Requests so far = " +
                         ++c_counter + "<br>" );
            out.println( "you are " + remoteHost + " at " + remoteIP +
"<br>" );
            out.println( "</body></html>" );

            socket.close();
        }
        catch( final SocketException se )
        {
            getLogger().debug( "Socket to " + remoteHost + " closed
remotely in HelloWorld", se );
        }
        catch( final InterruptedIOException iioe )
        {
            getLogger().debug( "Socket to " + remoteHost + " timeout in
HelloWorld", iioe );
        }
        catch( final IOException ioe )
        {
            getLogger().debug( "Exception in HelloWorld handling socket
to " + remoteHost ,
                               ioe );
        }
        catch( final Exception e )
        {
            getLogger().debug( "Exception in HelloWorld opening socket",
e );
        }
        finally
        {
            try { socket.close(); }
            catch( final IOException ioe )
            {
                getLogger().error( "Exception closing socket ", ioe );
            }
        }

        getLogger().info( "Connection from " + remoteHost + " (" +
remoteIP + ")" );

*/

        getLogger().info( "ListenerHandler.handleConnection()");
        final String remoteHost = socket.getInetAddress().getHostName();

        getLogger().info( "ListenerHandler.handleConnection() ...
remoteHost = " + remoteHost);
        final String remoteIP =
socket.getInetAddress().getHostAddress();
        getLogger().info( "ListenerHandler.handleConnection() ...
remoteIP = " + remoteIP);
        //final PrintWriter out = new PrintWriter(
socket.getOutputStream(), true );
        getLogger().info( "ListenerHandler.handleConnection() ...
remoteIP = " + remoteIP);
        //final PrintWriter out = new PrintWriter(
socket.getOutputStream(), true );

        try
        {
                input = new DataInputStream(socket.getInputStream());
                output = new DataOutputStream(socket.getOutputStream());

                run();
            //out.println( "<html><body><b>" + m_greeting + "!</b><br>
Requests so far = " +
                         //++c_counter + "<br>" );
            //out.println( "you are " + remoteHost + " at " + remoteIP +
"<br>" );
            //out.println( "</body></html>" );

            getLogger().info( "Listener creating a new ListenerService
object");
            System.out.println( "Listener creating a new ListenerService
object");
                //ListenerService ls = new ListenerService();
            getLogger().info( "Listener ... setting args on
ListenerService");
            System.out.println( "Listener ... setting args on
ListenerService");
                //ls.setArguments(new String[] {"", "name", "localhost",
"12000"});
            getLogger().info( "Listener ... setting streams on
ListenerService");
            System.out.println( "Listener ... setting streams on
ListenerService");
                //ls.setStreams(socket.getInputStream(),
socket.getOutputStream());
            getLogger().info( "Listener ... launching run() method on
ListenerService (in this thread)");
            System.out.println( "Listener ... launching run() method on
ListenerService (in this thread)");
                //ls.serviceStreams();
            getLogger().info( "Listener ... run() completed");
            System.out.println( "Listener ... run() completed");

            socket.close();
        }
        catch( final SocketException se )
        {
            getLogger().info( "Socket to " + remoteHost + " closed
remotely in HelloWorld", se );
            System.out.println( "Socket to " + remoteHost + " closed
remotely in HelloWorld");
        }
        catch( final InterruptedIOException iioe )
        {
            getLogger().info( "Socket to " + remoteHost + " timeout in
HelloWorld", iioe );
            System.out.println( "Socket to " + remoteHost + " timeout in
HelloWorld" + iioe.getMessage() );
        }
        catch( final IOException ioe )
        {
            getLogger().info( "Exception in HelloWorld handling socket
to " + remoteHost ,
                               ioe );
            System.out.println( "Exception in HelloWorld handling socket
to " + remoteHost);
        }
        catch( final Exception e )
        {
            getLogger().info( "Exception in HelloWorld opening socket",
e );
            System.out.println( "Exception in HelloWorld opening socket"
+ e.getMessage() );
        }
        finally
        {
            try { socket.close(); }
            catch( final IOException ioe )
            {
                getLogger().error( "Exception closing socket ", ioe );
                System.out.println( "Exception closing socket " +
ioe.getMessage() );
            }
        }

        getLogger().info( "Connection from " + remoteHost + " (" +
remoteIP + ")" );
        System.out.println( "Connection from " + remoteHost + " (" +
remoteIP + ")" );


    }
 .
 .
 .
 . run() ...

}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to