net.sweetohm.ant.server
Class RequestHandler

java.lang.Object
  extended by net.sweetohm.ant.server.RequestHandler
All Implemented Interfaces:
java.util.EventListener, org.apache.tools.ant.BuildListener

public class RequestHandler
extends java.lang.Object
implements org.apache.tools.ant.BuildListener

This class handles requests for Ant and process them.

Version:
1.0
Author:
Michel CASABIANCA

Field Summary
(package private) static java.lang.String BLANKS
          Blank characters
(package private) static java.lang.String COMMAND_PACKAGE
          The package name for commands
(package private)  java.io.Writer out
          The out writer
(package private)  org.apache.tools.ant.Project project
          The running project
(package private)  org.apache.tools.ant.Task task
          The running task
 
Constructor Summary
RequestHandler(org.apache.tools.ant.Project project, org.apache.tools.ant.Task task)
          Creates a new RequestHandler instance.
 
Method Summary
 void buildFinished(org.apache.tools.ant.BuildEvent event)
          Fired after the last target has finished.
 void buildStarted(org.apache.tools.ant.BuildEvent event)
          Fired before any targets are started.
(package private)  java.lang.String getClassName(java.lang.String command)
          Return the class name for a given command.
 void handle(java.net.Socket socket)
          Method to handle requests.
 void messageLogged(org.apache.tools.ant.BuildEvent event)
          Fired whenever a message is logged.
(package private)  void process(java.lang.String commandLine)
          Process a command.
(package private)  void send(java.lang.String message)
          Send a message to the client.
 void targetFinished(org.apache.tools.ant.BuildEvent event)
          Fired when a target has finished.
 void targetStarted(org.apache.tools.ant.BuildEvent event)
          Fired when a target is started.
 void taskFinished(org.apache.tools.ant.BuildEvent event)
          Fired when a task has finished.
 void taskStarted(org.apache.tools.ant.BuildEvent event)
          Fired when a task is started.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

project

org.apache.tools.ant.Project project
The running project


task

org.apache.tools.ant.Task task
The running task


out

java.io.Writer out
The out writer


BLANKS

static final java.lang.String BLANKS
Blank characters

See Also:
Constant Field Values

COMMAND_PACKAGE

static final java.lang.String COMMAND_PACKAGE
The package name for commands

See Also:
Constant Field Values
Constructor Detail

RequestHandler

public RequestHandler(org.apache.tools.ant.Project project,
                      org.apache.tools.ant.Task task)
Creates a new RequestHandler instance.

Parameters:
project - The running Ant Project.
Method Detail

handle

public void handle(java.net.Socket socket)
            throws java.lang.InterruptedException
Method to handle requests.

Parameters:
socket - The Socket to read and write.
Throws:
java.lang.InterruptedException

process

void process(java.lang.String commandLine)
       throws java.lang.InterruptedException,
              java.io.IOException
Process a command.

Parameters:
command - The command to process as a String.
Throws:
java.lang.InterruptedException - To stop the server, this is not an error !
java.io.IOException

getClassName

java.lang.String getClassName(java.lang.String command)
Return the class name for a given command. For instance, il the command is help, the class name is Help. Append also the package name for commands.

Parameters:
command - The command.
Returns:
The class name.

send

void send(java.lang.String message)
Send a message to the client.

Parameters:
message - a String value

buildStarted

public void buildStarted(org.apache.tools.ant.BuildEvent event)
Fired before any targets are started.

Specified by:
buildStarted in interface org.apache.tools.ant.BuildListener

buildFinished

public void buildFinished(org.apache.tools.ant.BuildEvent event)
Fired after the last target has finished. This event will still be thrown if an error occured during the build.

Specified by:
buildFinished in interface org.apache.tools.ant.BuildListener
See Also:
BuildEvent.getException()

targetStarted

public void targetStarted(org.apache.tools.ant.BuildEvent event)
Fired when a target is started.

Specified by:
targetStarted in interface org.apache.tools.ant.BuildListener
See Also:
BuildEvent.getTarget()

targetFinished

public void targetFinished(org.apache.tools.ant.BuildEvent event)
Fired when a target has finished. This event will still be thrown if an error occured during the build.

Specified by:
targetFinished in interface org.apache.tools.ant.BuildListener
See Also:
BuildEvent.getException()

taskStarted

public void taskStarted(org.apache.tools.ant.BuildEvent event)
Fired when a task is started.

Specified by:
taskStarted in interface org.apache.tools.ant.BuildListener
See Also:
BuildEvent.getTask()

taskFinished

public void taskFinished(org.apache.tools.ant.BuildEvent event)
Fired when a task has finished. This event will still be throw if an error occured during the build.

Specified by:
taskFinished in interface org.apache.tools.ant.BuildListener
See Also:
BuildEvent.getException()

messageLogged

public void messageLogged(org.apache.tools.ant.BuildEvent event)
Fired whenever a message is logged.

Specified by:
messageLogged in interface org.apache.tools.ant.BuildListener
See Also:
BuildEvent.getMessage(), BuildEvent.getPriority()