Using the session service

The session service, which implements the com.ibm.hats.runtime.services.SessionService interface, provides methods for interacting with an instance of a ZIETrans rich client application. Each running application instance, for example, a transformation view instance, has an associated session service. There is a one-to-one mapping between a transformation view instance and a session service.

Sample code for retrieving the complete collection of session services:
IServiceManager serviceManager = 
         RcpRuntimePlugin.getDefault().getServiceManager();
Collection sessionServices = 
         serviceManager.retrieveServiceEntries( ServiceType.SESSION );
Iterator itSessionServices = 
         sessionServices.iterator();
while ( itSessionServices.hasNext() )
{         
ISessionService aSessionService = 
      (ISessionService) itSessionServices.next();
// Your custom code goes here     
}
Table 1 identifies the methods that can be called by the ISessionService object representing an instance of an application.
Table 1. ISessionService methods
Method Description

addPresentationListener
         (IPresentationListener)

Adds the specified presentation listener to the list. Listeners are notified when the presentation is updated.

addSessionServiceListener
       (ISessionServiceListener)

Adds the specified session service listener to the list. Listeners are notified when the state of the session has changed or when a command is about to be sent.
canSendCommand(String) Returns a boolean value of true if the current session service state can send the specified command, otherwise returns a boolean value of false.
disconnect() Disconnects the host session. This method is called by the Disconnect button on the Application keypad. The associated transformation view is not closed by this method. This method will perform no action if the session service is already processing a command.
getApplication() Returns the application associated with this session service instance. The use of the object returned by this method should only be used to retrieve information. Do not use this object to alter any settings.
getApplicationId() Returns the application ID (for example, the plug-in ID) of the application associated with this session service.
getApplicationService() Returns the application service associated with this session service instance.
getClientId() Returns the client ID associated with this session service instance.
getCurrentState() Returns the current state of this session service instance.
getHostScreen() Returns the host screen associated with this session service instance. This returns the last host screen processed by the ZIETrans runtime, not necessarily the current host screen.
getHostScreenDataAccessService() Returns the model containing the values of host field-associated controls on the form. This method is only applicable when a transformation is currently being displayed on the view.
getLocale() Returns the locale that should be used to display messages. This locale might be different than the locale of the Eclipse environment if you have changed the client locale settings in the Project Settings editor for the application.
getMacroPromptDataAccessService() Returns the service used to access the model data.
getParameterDataAccessService() Returns the model containing the values of non-host field-associated controls on the form. This service is used to set and retrieve other form values, such as global variable values, that will be passed to the ZIETrans runtime when the current form is submitted.
getRuntimeService() Returns the runtime service.
getServiceManager() Returns the service manager that instantiated this service.
getSession() Returns the host session associated with this session service instance.
getSessionServiceState() Returns the session service state as a state object.
getViewId() Returns the transformation view instance ID.
isAsyncUpdateEnabled() Returns a boolean value of true if asynchronous update is enabled; otherwise returns a boolean value of false.
isCommandSupported(String) Returns a boolean value of true if the specified command is supported; otherwise returns a boolean value of false.
playMacro(String) Plays the specified macro.
playMacro(String, Properties) Plays the specified macro and passes values for any prompts defined in the macro.

removePresentationListener
            (IPresentationListener)

Removes the specified presentation listener from the list.

removeSessionServiceListener
           (ISessionServiceListener)

Removes the specified session service listener from the list.
sendCommand(String) Sends the specified command. Common commands are: [pf1], [pf2], [enter], [fldext].
Note: The square brackets around some commands are required.
sendCommand(String, Properties) Sends the command specified by String along with the associated properties. A command is either a Host On-Demand mnemonic, such as [enter], or a ZIETrans command, such as default. Additional parameters can be specified. These parameters are included in the request that gets submitted. These parameters override any parameters of the same name that are collected from the SDO model, such as host input fields, or global variables. Override parameter values should be of type String[].
sendContinue() Sends a continue command. This command must be sent to continue from a show composite action or a macro prompt action.
sendEnter() Sends the Enter key command.
sendF1() - sendF24() Sends the respective PF key command.
sendRefresh() Sends the Refresh command.
sendShowDefault() Sends the Show default command.
start(Properties) Start the session service using the specified connection and global variable overrides.
stop() Stops the session service.
updatePresentation(IPresentable) Updates the presentation (generally the transformation view) with the specified presentable.
The associated ISessionService object for a transformation view can be retrieved by calling the getSessionService() method on the view. This method is provided by the ITransformationView interface, which is implemented by the base TransformationView class.