JavaGantt 2011.1 API

eu.beesoft.gaia.swing.server
Class ApplicationServer

java.lang.Object
  extended by eu.beesoft.gaia.server.AbstractServer
      extended by eu.beesoft.gaia.swing.server.ApplicationServer
All Implemented Interfaces:
ApplicationContainer

public class ApplicationServer
extends AbstractServer
implements ApplicationContainer

This is a server to process SwingClient requests. It manages an instances of Application and redirects requests to the appropriate instance (accodring to client / application id).


Constructor Summary
ApplicationServer()
          Creates a new instance of application server.
 
Method Summary
protected  Application createApplication(ApplicationRequest request)
          Creates a new application as an instance of the class which name is equal to the request's action.
 void finishApplication(Application application)
          Removes given application instance from internal map, so it cannot be invoked from client and it does not take a space in memory.
static void main(java.lang.String[] arg)
          Creates a new instance of ApplicationServer and starts it.
protected  void process(java.net.Socket socket)
          Implementation of processs() method from AbstractServer.
protected  ApplicationResponse processRequest(ApplicationRequest request, Application application)
          Invokes request processing on given application.
 
Methods inherited from class eu.beesoft.gaia.server.AbstractServer
getLog, getMaxThreads, getMinThreads, getPort, isRunning, setMaxThreads, setMaxThreads, setMinThreads, setMinThreads, setPort, setPort, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationServer

public ApplicationServer()
Creates a new instance of application server.

Method Detail

process

protected void process(java.net.Socket socket)
Implementation of processs() method from AbstractServer. It covers all communication with SwingClient. It transforms received data to ApplicationRequest and delivers it to referenced Application instance to process.

Specified by:
process in class AbstractServer
Parameters:
socket - - socket to communicate

createApplication

protected Application createApplication(ApplicationRequest request)
Creates a new application as an instance of the class which name is equal to the request's action. This method is invoked from process(Socket) if there is no application instance found for incomming client (application) id.

Parameters:
request - - request to process
Returns:
newly created application

processRequest

protected ApplicationResponse processRequest(ApplicationRequest request,
                                             Application application)
Invokes request processing on given application. This method is invoked from process(Socket). Override this method if you need pre-process or post-process the request processing.

Parameters:
request - - request to process
application - - application which should process given request
Returns:
response from application

finishApplication

public void finishApplication(Application application)
Removes given application instance from internal map, so it cannot be invoked from client and it does not take a space in memory. Can be invoked from your application (probably the best place for this is the Application.timedOut() method).

Specified by:
finishApplication in interface ApplicationContainer
Parameters:
application - - application to finish

main

public static void main(java.lang.String[] arg)
Creates a new instance of ApplicationServer and starts it.


JavaGantt 2011.1 API