org.tfe.core
Class AlertServerImpl

java.lang.Object
  |
  +--org.omg.PortableServer.Servant
        |
        +--org.tfe.core.AlertServerPOA
              |
              +--org.tfe.core.AlertServerImpl
All Implemented Interfaces:
AlertServerOperations, org.omg.CORBA.portable.InvokeHandler

public class AlertServerImpl
extends AlertServerPOA


Constructor Summary
AlertServerImpl()
           
 
Method Summary
 void _initialize_inheritance_tree()
           
 void addAlert(Alert a)
          Adds an Alert to the memory buffer.
static int assignAlertID()
          Assigns an ID number to each new alert.
static int assignCollectionID()
          Assigns a collection ID to each alert.
 User authenticate(java.lang.String username, java.lang.String pwHash)
           
 void deregisterApp(User user, int appnum)
          De-registers a client application from the RTA Server.
 Alert get(User user, int index)
          Retrieves alerts from the server.
 Alert getAlert(User user, int ID)
          Retrieves an Alert from the server.
 int getAlertBufferSize(User user)
          Gets the number of Alerts that are currently in the alertBuffer.
 AppsCallBack getApp(int index)
          Accessor method for the registeredApps array.
 int getNumClients()
          Accessor method for the numClients variable.
 int getNumClients(User user)
           
 int getNumCollections(User user)
           
 int getNumUsers(User user)
           
static int getRegisteredAppsLength()
          Accessor method for the registeredApps size.
 java.lang.String getServerStatus(User user)
           
 int registerApp(AppsCallBack objRef, User user, java.lang.String host)
          Registers a client with the RTA Server.
 void removeAlert(int ID, User user, java.lang.String host)
          Removes an Alert from the server.
 java.lang.String requestSeed(java.lang.String user)
           
 void resetAlerts(User user, java.lang.String host)
          Removes all Alerts from the server.
 void sendMessage(User user, java.lang.String message)
          Used to send a text message to other clients.
 
Methods inherited from class org.tfe.core.AlertServerPOA
_all_interfaces, _invoke, _this, _this
 
Methods inherited from class org.omg.PortableServer.Servant
_default_POA, _get_delegate, _get_interface_def, _is_a, _non_existent, _object_id, _orb, _poa, _set_delegate, _this_object, _this_object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlertServerImpl

public AlertServerImpl()
Method Detail

addAlert

public void addAlert(Alert a)
Adds an Alert to the memory buffer. Inserts the Alert into the alertBuffer and then perform callbacks to all registered clients.

Parameters:
a - the Alert to be added to the alertBuffer

getAlert

public Alert getAlert(User user,
                      int ID)
               throws NotAuthorizedException
Retrieves an Alert from the server. This function can be used by registered CORBA clients to retrieve an Alert from the RTAServer.

Parameters:
user - the username associated with the client making the request.
ID - the ID number of the Alert to be retrieved.
Returns:
the Alert with the corresponding ID, or null if it was not found.
NotAuthorizedException

get

public Alert get(User user,
                 int index)
          throws NotAuthorizedException
Retrieves alerts from the server. This function is used to get Alerts by their index in the alertBuffer rather than by their Alert ID (which will not always be the same). This is useful at startup when the client application only wants to get the last X number of Alerts.

Parameters:
user - the username associated with the client making the request.
index - the index of the alert to be retrieved.
Returns:
the Alert at the specified index in the alertBuffer, or a null Alert if they request an Alert at an index outside of the bounds of the alertBuffer.
NotAuthorizedException

removeAlert

public void removeAlert(int ID,
                        User user,
                        java.lang.String host)
                 throws NotAuthorizedException
Removes an Alert from the server. This function is used to remove an Alert with the specified ID number from the RTA Server.

Parameters:
ID - the ID number of the Alert to be removed.
user - the username associated with the client making the request.
host - the hostname associated with the client making the request.
NotAuthorizedException

resetAlerts

public void resetAlerts(User user,
                        java.lang.String host)
                 throws NotAuthorizedException
Removes all Alerts from the server. This function is used to remove all Alerts from the alertBuffer, basically resetting the RTA Server. USE WITH CAUTION.

Parameters:
user - the username associated with the client making the request.
host - the hostname associated with the client making the request.
NotAuthorizedException

registerApp

public int registerApp(AppsCallBack objRef,
                       User user,
                       java.lang.String host)
                throws NotAuthorizedException
Registers a client with the RTA Server. This function is how a client registers with the RTA Server so that it can receive Alerts from the server.

Parameters:
objRef - a callback reference to the client, so that the RTA Server can exchange objects with the client.
user - the username associated with the client.
host - the hostname associated with the client.
Returns:
the index at which the application was registered, if successful. -1 if the Server has too many clients registered. -2 if the client was not permitted to connect.
NotAuthorizedException

deregisterApp

public void deregisterApp(User user,
                          int appnum)
                   throws NotAuthorizedException
De-registers a client application from the RTA Server. This is done either by the client (if it's nice), or automatically by the server if it finds a dead client. The EventServantMaintenanceThread sends periodic messages to the clients and if a client fails to respond, it is deregistered.

Parameters:
user - the username associated with the client making the request.
appnum - the index number of the client making the request.
NotAuthorizedException

sendMessage

public void sendMessage(User user,
                        java.lang.String message)
                 throws NotAuthorizedException
Used to send a text message to other clients.

Parameters:
user - the username of the client that is sending the message.
message - the text of the message.
NotAuthorizedException

assignCollectionID

public static int assignCollectionID()
Assigns a collection ID to each alert. This method is used to assign new collection ID numbers to alerts. Alerts that match certain patterns will be grouped together with like Collection IDs. Alerts that do not match any patterns will be assigned a new Collection ID through this method.

Returns:
integer value of the new Collection ID

assignAlertID

public static int assignAlertID()
Assigns an ID number to each new alert. This method is accessed by the AlertHandlerThread to assign an ID number to each new Alert as it arrives. The Alert ID is not based on the alertBuffer size (since this will reach a point (Server.maxAlerts) where it will be fixed. Rather, this is a separate int value that is incremented for each new Alert that is received.

Returns:
integer value of the Alert ID

getNumClients

public int getNumClients()
Accessor method for the numClients variable. numClients is a variable that keeps track of the current number of registered clients at any given point in time.

Returns:
integer value of the current number of registered clients.

getApp

public AppsCallBack getApp(int index)
Accessor method for the registeredApps array. This method allows the user to retrieve an app callback reference at a particular index in the registeredApps array.

Returns:
null if null, AppsCallBack representation of the application if not null.

getRegisteredAppsLength

public static int getRegisteredAppsLength()
Accessor method for the registeredApps size.

Returns:
integer value of the size of the registeredApps array.

getAlertBufferSize

public int getAlertBufferSize(User user)
                       throws NotAuthorizedException
Gets the number of Alerts that are currently in the alertBuffer. This is useful at startup when determining how many Alerts need to be retrieved.

Parameters:
user - the username associated with the client making the request.
Returns:
the integer value of the number of Alerts on the RTA Server.
NotAuthorizedException

authenticate

public User authenticate(java.lang.String username,
                         java.lang.String pwHash)
                  throws AuthenticationFailedException
AuthenticationFailedException

requestSeed

public java.lang.String requestSeed(java.lang.String user)

getServerStatus

public java.lang.String getServerStatus(User user)
                                 throws NotAuthorizedException
NotAuthorizedException

getNumClients

public int getNumClients(User user)
                  throws NotAuthorizedException
NotAuthorizedException

getNumCollections

public int getNumCollections(User user)
                      throws NotAuthorizedException
NotAuthorizedException

getNumUsers

public int getNumUsers(User user)
                throws NotAuthorizedException
NotAuthorizedException

_initialize_inheritance_tree

public void _initialize_inheritance_tree()