JavaGantt 2011.1 API

eu.beesoft.gaia.app
Class Application

java.lang.Object
  extended by eu.beesoft.gaia.app.Context
      extended by eu.beesoft.gaia.app.Application

public abstract class Application
extends Context

Abstract superclass for each server application. It is created and managed by the running ApplicationContainer implementation.

You need override in you subclass only methods getStartControllerClassName() and getFile(String).


Constructor Summary
Application()
          Default constructor.
 
Method Summary
 Context close()
          Closes this application.
static java.lang.String encryptPassword(java.lang.String password)
          Encryptes given password with MD5 hash function.
 ApplicationContainer getApplicationContainer()
          Returns an application container of this application.
 Context getCurrentContext()
          Returns the current application context.
abstract  java.io.File getFile(java.lang.String fileName)
          Returns a file with given fileName.
 java.lang.String getId()
          Returns id of this application.
static Application getInstance()
          Returns current application (bound to running thread).
 long getLastConnectionTime()
          Returns last time when this application was requested by the client.
abstract  java.lang.String getStartControllerClassName()
          Returns the name of the controller that should be started when this application is created.
 long getTimeout()
          Returns a time period to kill this application if no client request will be delivered in (default value is 1 hour).
 ApplicationResponse process(ApplicationRequest request)
          Processes a client request by forwarding it to the appropriate controller.
 void setApplicationContainer(ApplicationContainer applicationContainer)
          Sets an application container of this application.
 void setId(java.lang.String id)
          Sets an application id.
static void setInstance(Application application)
          Sets the current application (bound to running thread).
 void setLastConnectionTime(long lastConnectionTime)
          Sets last time when this application was requested by the client (in milliseconds since 1.1.1970).
 void setTimeout(long timeout)
          Sets a time period to kill this application if no client request will be delivered in.
 void timedOut()
          Finishes this application by invocation of ApplicationContainer.finishApplication(Application) method.
 
Methods inherited from class eu.beesoft.gaia.app.Context
containsValue, containsValue, findValue, findValue, getApplication, getChildContext, getParentContext, getRunner, getStarter, getValue, getValue, isClosed, removeValue, removeValue, setRunner, setValue, setValue, startNewContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Application

public Application()
Default constructor.

Method Detail

getInstance

public static Application getInstance()
Returns current application (bound to running thread).

Returns:
current application

setInstance

public static void setInstance(Application application)
Sets the current application (bound to running thread). This method is invoked from the running ApplicationContainer implementation.

Parameters:
application - - application to set current

getId

public java.lang.String getId()
Returns id of this application. It is the same as session id in the ApplicationRequest.

Returns:
the application / session id

setId

public void setId(java.lang.String id)
Sets an application id. This method is invoked from the running ApplicationContainer implementation.

Parameters:
id - - the id to set

getLastConnectionTime

public long getLastConnectionTime()
Returns last time when this application was requested by the client.

Returns:
last connection time (in milliseconds since 1.1.1970).

setLastConnectionTime

public void setLastConnectionTime(long lastConnectionTime)
Sets last time when this application was requested by the client (in milliseconds since 1.1.1970). This method is invoked from the running ApplicationContainer implementation after client request is processed.


getTimeout

public long getTimeout()
Returns a time period to kill this application if no client request will be delivered in (default value is 1 hour).

Returns:
the application timeout

setTimeout

public void setTimeout(long timeout)
Sets a time period to kill this application if no client request will be delivered in.

Parameters:
timeout - - the timeout to set

getApplicationContainer

public ApplicationContainer getApplicationContainer()
Returns an application container of this application.

Returns:
the application container

setApplicationContainer

public void setApplicationContainer(ApplicationContainer applicationContainer)
Sets an application container of this application. This method is invoked from the running ApplicationContainer implementation when this application is created.

Parameters:
applicationContainer - - the application container to set

getCurrentContext

public Context getCurrentContext()
Returns the current application context.

Overrides:
getCurrentContext in class Context
Returns:
current context

close

public Context close()
Closes this application. Removes context's entries.

Overrides:
close in class Context
Returns:
null

process

public ApplicationResponse process(ApplicationRequest request)
Processes a client request by forwarding it to the appropriate controller. That is a runner controller in the current context.

Parameters:
request - - a client request to process
Returns:
response for a client

timedOut

public void timedOut()
Finishes this application by invocation of ApplicationContainer.finishApplication(Application) method. Is invoked from an application container when a client does not request anything for more time than is an application timeout set.


getFile

public abstract java.io.File getFile(java.lang.String fileName)
Returns a file with given fileName. You need override this method to map the given relative file name to absolute file name in file system.

Parameters:
fileName - - a relative name of the requested file
Returns:
File instance for requested name

getStartControllerClassName

public abstract java.lang.String getStartControllerClassName()
Returns the name of the controller that should be started when this application is created. This method is invoked only once.

Returns:
qualified class name of the application start controller

encryptPassword

public static java.lang.String encryptPassword(java.lang.String password)
Encryptes given password with MD5 hash function. This is the one-way encryption (there is no way to get an original password again). Use this method to encrypt password before you transfer it or before you store it to the database.

Parameters:
password - - text to encrypt
Returns:
encrypted text

JavaGantt 2011.1 API