amber.server.application
Interface ApplicationInterface

All Known Implementing Classes:
ApplicationHandler, ComponentHandler

public interface ApplicationInterface

This is an interface that all application type systems must conform to for the communication threads to work with it.

Version:
1.0.0
Author:
Dr. David J. Knowles
See Also:
ApplicationHandler

Method Summary
 void addReceivedPacket(Packet packet)
          Called by the ReceiveThread when a packet has been received.
 void directPacket(Packet packet)
          Called by the ReceiveThread when a packet has been received.
 void forwardEventPacket(Packet packet)
          Called by the EventThread when a packet has been received.
 Log getLog()
          Returns the Log object.
 ApplicationInterface getModalObject()
          Returns the current object which is receiving all input packets.
 CoreInterface getParentServer()
          Returns the original server which started this ApplicationInterface.
 int getValidId()
          This function allocates a valid unused ID from a pool of ID's held within the Application.
 boolean isConnected()
          This function returns the state of the application handler.
 void restart(java.net.Socket newConnection)
          This function restarts the functioning of the ApplicationInterface.
 void sendPacket(Packet packet)
          Writes a packet to the output stream.
 void setConnectedState(boolean state)
          This function will force the application to go active/inactive.
 void setLog(Log logFile)
          Sets the Log for this ApplicationInterface.
 void setModalObject(ApplicationInterface object)
          Sets the current object which is to receive all input packets.
 void setParentServer(CoreInterface server)
          Sets the original server which started this ApplicationInterface.
 void shutDown()
          This function attempts to shut down the page handler gracefully.
 void shutDownClient()
          This function will force the client to shut down.
 void shutDownClient(java.lang.String message)
          This function will force the client to shut down.
 void start(java.net.Socket newConnection)
          This function initiates the functioning of the ApplicationInterface.
 

Method Detail

forwardEventPacket

public void forwardEventPacket(Packet packet)
                        throws ApplicationException
Called by the EventThread when a packet has been received. This function examines the packet and passes it to the appropriate handler.
Parameters:
packet - Packet to forward to the specified component.

start

public void start(java.net.Socket newConnection)
           throws java.lang.IllegalThreadStateException
This function initiates the functioning of the ApplicationInterface. This function is required as the page handler will not immediately start operation until it is handed the socket by the main handling system.
Parameters:
newConnection - The Socket which is connected to the page in operation. If null uses the connection already set.
Throws:
java.lang.IllegalThreadStateException - containing any problems.

restart

public void restart(java.net.Socket newConnection)
             throws java.lang.IllegalThreadStateException
This function restarts the functioning of the ApplicationInterface. This function is called when an application has lost the connection which is then reestablished.
Parameters:
newConnection - The Socket which is connected to the page in operation. If null uses the connection already set.
Throws:
java.lang.IllegalThreadStateException - containing any problems.

addReceivedPacket

public void addReceivedPacket(Packet packet)
Called by the ReceiveThread when a packet has been received. This function adds the packet to the Vector of pending packets. The run method of the ApplicationInterface class will dispatch the packet in the run method.
Parameters:
packet - Packet to forward to the specified component.

getParentServer

public CoreInterface getParentServer()
Returns the original server which started this ApplicationInterface.
Returns:
CoreInterface which is the parent server.

setParentServer

public void setParentServer(CoreInterface server)
Sets the original server which started this ApplicationInterface.
Parameters:
server - CoreInterface which is the parent server.

getLog

public Log getLog()
Returns the Log object.
Returns:
Log which is the Logging object.

setLog

public void setLog(Log logFile)
Sets the Log for this ApplicationInterface.
Parameters:
logFile - Log object for logging.

shutDown

public void shutDown()
This function attempts to shut down the page handler gracefully. If the program is already shut down it does nothing.

getModalObject

public ApplicationInterface getModalObject()
Returns the current object which is receiving all input packets.
Returns:
ApplicationInterface which is the modal object.

setModalObject

public void setModalObject(ApplicationInterface object)
Sets the current object which is to receive all input packets.
Parameters:
object - ApplicationInterface which is the modal object.

directPacket

public void directPacket(Packet packet)
                  throws ApplicationException
Called by the ReceiveThread when a packet has been received. This function examines the packet and passes it to the appropriate handler.
Parameters:
packet - Packet to forward to the specified component.
Throws:
ApplicationException - containing errors.

isConnected

public boolean isConnected()
This function returns the state of the application handler. If the application is connected and can message to the server then this function returns true.
Returns:
boolean connection state.

sendPacket

public void sendPacket(Packet packet)
                throws ApplicationHandlerException
Writes a packet to the output stream.
Parameters:
packet - Packet which will be written to the remote browser.
Throws:
amber.server.applicationException - containing error information

getValidId

public int getValidId()
               throws ApplicationHandlerException
This function allocates a valid unused ID from a pool of ID's held within the Application. This function is typically called from a component when it is created. The ID's start unaltered at a base of 200.
Returns:
int containing the valid ID.
Throws:
ApplicationHandlerException - should the component ID overflow the maximum allowed.

shutDownClient

public void shutDownClient()
                    throws ApplicationHandlerException
This function will force the client to shut down.
Throws:
ApplicationHandlerException - should there be a messaging error.

shutDownClient

public void shutDownClient(java.lang.String message)
                    throws ApplicationHandlerException
This function will force the client to shut down. The function waits for the client to respond that it has shut down before returning.
Parameters:
message - String optional message which the client will display in a message box when the client is closed. A null value sends no message and silently shuts down the client.
Throws:
ApplicationHandlerException - should there be a messaging error.

setConnectedState

public void setConnectedState(boolean state)
This function will force the application to go active/inactive. An inactive application is assumed to be not connected to the remote client. Should a reconnection occur the application is re-activated.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.