com.wrq.vhi.script.api
Class LifeCycleEventHandler

java.lang.Object
  extended by com.wrq.vhi.script.api.LifeCycleEventHandler
All Implemented Interfaces:
EventHandler

public abstract class LifeCycleEventHandler
extends java.lang.Object
implements EventHandler

Abstract base class for a lifecycle event handler. All classes that extend this class appear as lifecycle event handlers in the VHI design tool.

Except for the authenticate client event, the lifecycle events correspond to the build up and tear down of objects within VHI. Their primary purpose is to allow for the initialization and cleanup of the model and client shared state. None of the events have access to the terminal screen. If initialization or cleanup of the terminal is needed, see ModelEventHandler.

The order in which these events fire on build up is as follows:

The order in which these events fire on tear down is as follows:


Field Summary
 
Fields inherited from interface com.wrq.vhi.script.api.EventHandler
DEFAULT_TIMEOUT
 
Constructor Summary
LifeCycleEventHandler()
           
 
Method Summary
 boolean authenticateUser(AuthenticateUserEvent event)
          Called to authenticate a client connecting to the VHI server.
 void clientSessionCreated(ClientSessionCreatedEvent event)
          Called when a client session is created.
 void clientSessionDestroyed(ClientSessionDestroyedEvent event)
          Called when a client session is destroyed.
 void hostSessionCreated(HostSessionCreatedEvent event)
          Called when a host session is created.
 void hostSessionDestroyed(HostSessionDestroyedEvent event)
          Called when a host session is destroyed.
 void modelLoaded(ModelLoadedEvent event)
          Called when a model is loaded.
 void modelUnloaded(ModelUnloadedEvent event)
          Called when a model is unloaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifeCycleEventHandler

public LifeCycleEventHandler()
Method Detail

modelLoaded

public void modelLoaded(ModelLoadedEvent event)
                 throws ApptrieveException
Called when a model is loaded. For the VHI server this occurs when the server starts and when a model is deployed. For the VHI design tool this occurs when a model is opened or when the jar files are rebuilt.

This event will fire once per version of a model before any associated host sessions are created. It is the first opportunity to initialize the model shared state.

If an exception is thrown from this event the VHI server will log the error and fail to load the model. This means that clients will be unable to connect to the model or any session pools based on the model. The design tool will simply report the exception and move on.

Parameters:
event - the event instance
Throws:
ApptrieveException

modelUnloaded

public void modelUnloaded(ModelUnloadedEvent event)
                   throws ApptrieveException
Called when a model is unloaded. For the VHI server this occurs when the server is shutdown or when a model is undeployed. For the VHI design tool this occurs when a model is closed and when the jar files are rebuilt.

This event will fire once per version of a model only after all associated host sessions have been destroyed. It is the last opportunity to do any cleanup of the model shared state.

If an exception is thrown from this event the VHI server will log the error and move on. The design tool will report the exception and move on.

Parameters:
event - the event instance
Throws:
ApptrieveException

hostSessionCreated

public void hostSessionCreated(HostSessionCreatedEvent event)
                        throws ApptrieveException
Called when a host session is created. For the VHI server this occurs when a session pool is created or augmented and when a dedicated session is created for a client in response to connectToModel(). For the VHI design tool this occurs when a model is loaded and when the jar files are rebuilt.

This event is the first opportunity to initialize the model shared state with any host session specific information. The host session ID can be used to construct a unique key for storing such information.

This event does not have access to the host session's terminal. If initialization of the terminal is needed, see ModelEventHandler.executeLogin(com.wrq.vhi.script.api.ExecuteLoginEvent).

If an exception is thrown from this event the VHI server will log the error and fail the host session creation. If the host session is being created in response to a connectToModel() request, the connection will fail. The design tool will simply report the exception and move on.

Parameters:
event - the event instance
Throws:
ApptrieveException

hostSessionDestroyed

public void hostSessionDestroyed(HostSessionDestroyedEvent event)
                          throws ApptrieveException
Called when a host session is destroyed. For the VHI server this occurs when a session pool is destroyed or decreased in size and when a dedicated session obtained via connecToModel() is released by its client. For the VHI design tool this occurs when a model is closed and when the jar files are rebuilt.

This event is the last opportunity to do any cleanup of host session specific information stored in the model shared state.

This event does not have access to the host session's terminal. If cleanup of the terminal is needed, see ModelEventHandler.executeLogout(com.wrq.vhi.script.api.ExecuteLogoutEvent).

If an exception is thrown from this event the VHI server will log the error and move on. The design tool will report the exception and move on.

Parameters:
event - the event instance
Throws:
ApptrieveException

authenticateUser

public boolean authenticateUser(AuthenticateUserEvent event)
                         throws ApptrieveException
Called to authenticate a client connecting to the VHI server. This occurs after a client has been authenticated and authorized by VHI security. The VHI design tool simulates a client connecting when a model is loaded and when the jar files are rebuilt. This event always fires before a client session is created.

The VHI server will reject the client's connection request if false is returned or an exception is thrown. The design tool will simply report the rejection or exception.

Parameters:
event - the event instance
Returns:
true to allow the connection or false to reject it
Throws:
ApptrieveException

clientSessionCreated

public void clientSessionCreated(ClientSessionCreatedEvent event)
                          throws ApptrieveException
Called when a client session is created. This occurs after a client has been granted access to a host session but before a client is allowed to make any requests. The VHI design tool simulates a client connecting when a model is loaded and when the jar files are rebuilt. This event always fires before the ModelEventHandler.clientConnected(com.wrq.vhi.script.api.ClientConnectedEvent) event.

This event is the first opportunity to initialize the client session shared state.

If an exception is thrown from this event the VHI server will log the error and fail the client connection. The design tool will simply report the exception and move on.

Parameters:
event - the event instance
Throws:
ApptrieveException

clientSessionDestroyed

public void clientSessionDestroyed(ClientSessionDestroyedEvent event)
                            throws ApptrieveException
Called when a client session is destroyed. This occurs after a client has disconnected. The VHI design tool simulates a client disconnecting when a model is closed and when the jar files are rebuilt. This event always fires after the ModelEventHandler.clientDisconnected(com.wrq.vhi.script.api.ClientDisconnectedEvent) event.

This event is the last opportunity to do any needed cleanup of the client session shared state.

If an exception is thrown from this event the VHI server will log the error and move on. The design tool will report the exception and move on.

Parameters:
event - the event instance
Throws:
ApptrieveException