net.sweetohm.ant.server
Class ServerTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by net.sweetohm.ant.server.ServerTask
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Runnable

public class ServerTask
extends org.apache.tools.ant.Task
implements java.lang.Runnable

This task runs a server to handle build requests send by sockets.

Version:
1.0
Author:
Michel CASABIANCA

Field Summary
(package private)  java.util.List ips
          List of allowed IPs for connection
(package private)  int port
          The port the server is listening to
(package private)  org.apache.tools.ant.Project project
          The project to build
(package private)  java.net.ServerSocket server
          The server socket to listen port
(package private)  java.lang.Thread thread
          The thread that is running
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location
 
Constructor Summary
ServerTask()
          Empty constructor.
 
Method Summary
(package private)  boolean checkAccess(java.net.Socket socket)
          Check that the access is granted by searching the IP of the client in the list of granted IPs.
 void execute()
          Lauch the server for Ant management, ant wait for shutdown.
 void run()
          The main loop of the server.
 void setIps(java.lang.String ips)
          Set the list of granted IPs for connection.
 void setPort(int port)
          Set the port the server is listening.
 void start()
          Start the server.
 void stop()
          Stop the server.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thread

java.lang.Thread thread
The thread that is running


port

int port
The port the server is listening to


ips

java.util.List ips
List of allowed IPs for connection


project

org.apache.tools.ant.Project project
The project to build


server

java.net.ServerSocket server
The server socket to listen port

Constructor Detail

ServerTask

public ServerTask()
Empty constructor.

Method Detail

setPort

public void setPort(int port)
Set the port the server is listening.

Parameters:
port - The port the server is listening.

setIps

public void setIps(java.lang.String ips)
Set the list of granted IPs for connection.

Parameters:
ips - The coma separated list of IPs.

execute

public void execute()
Lauch the server for Ant management, ant wait for shutdown. If the server is already running, skip the task.

Overrides:
execute in class org.apache.tools.ant.Task

run

public void run()
The main loop of the server.

Specified by:
run in interface java.lang.Runnable

start

public void start()
Start the server.


stop

public void stop()
Stop the server.


checkAccess

boolean checkAccess(java.net.Socket socket)
              throws java.lang.SecurityException
Check that the access is granted by searching the IP of the client in the list of granted IPs. Return true if access is granted and false if it is not.

Parameters:
socket - The Socket for the connection.
Throws:
java.lang.SecurityException - if access is not granted for this IP.