Using Common Services APIs with Multiple Sessions
In environments such as web environments there may exist multiple sessions. The following are issues that should be considered in a multiple session environment.
Creation of EMF Resources
In a multiple session environment the resources used by the Common Services should not be shared across sessions. For this reason the org.eclipse.hyades.models.hierarchy.util.ISessionManager interface is provided that manages the resource set creation based on a session id. This interface provides the following API:
/**
* Creates a resource based on a unique identifier.
* @param sessionID a string that identifies a session
* @return a resource set based on a unique identifier
*/
public ResourceSet getResourceSet(String sessionID);
The getResourceSet API should be implemented and return a resource set based on a specific session id. Note the resource set that is returned should have the ability to create the various TPTP EMF resources such as TRCAgents, TRCNodes, TRCMonitors, TRCProcesses, Symptom Catalogs, and Correlations.
An instance of this manager should be passed to the common service via the context object as follows:
context.setProperty(ISessionManager.CONTEXT_SESSION_MANAGER, MySessionManager.getInstance());
context.setProperty(ISessionManager.CONTEXT_SESSION_ID, "MySessionID");
Notice that a singleton of an implementation of the ISessionManager is passed in. The function of this singleton is to manage the creation of the resource sets across multiple sessions. Also notice that a session id is passed in to the context object to identify the session that is currently being processed.
Locale
Each session may contain define a different locale. For example one session may process information in French while another session may process information in Chinese. The Locale for a specific session can be passed in via the context object. This is showed as follows:
context.setProperty(IImportHandler.CONTEXT_LOCALE, Locale.FRENCH);
Note that each service provides a property name that signifies the Locale. For example the import service defines the IImportHandler.CONTEXT_LOCALE property name, while the export service defines the IExportHandler.CONTEXT_LOCALE.