|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
SessionServer
provides the client interface for requesting AEFSession
objects.
Clients may request either an "available" session (i.e., a session that is not in use by
another session) or a specific session by terminal number. If no session is available,
an AEFException
is thrown. The session returned via a call to getAvailableSession
will not be available to any other callers of getAvailableSession
until the
session.release
method is called. Note that getting an available session does not prevent other
clients from accessing the session by specifying the specific terminal number.
Examples: (server
is an object of type SessionServer
)
Obtaining any available session:
try { AEFSession mySession = server.getAvailableSession(); if (mySession != null) { System.out.println("Using terminal number: " + mySession.getTerminalNumber(); } } catch (RemoteException re) { System.err.println("Couldn't access remote session"); } catch (AEFException ae) { System.err.println("Couldn't obtain an available session"); }
Obtaining a specific session without regard to availability:
To obtain a specific session, either specify the terminal number or, if in a non-TSS environment
where only a single session exists, use the constant LOCAL_SESSION
. In this case, a session is
returned if it is a valid terminal number, even if it is already assigned to a client.
AEFSession mySession = server.getSession("100"); AEFSession aSession = server.getSession(SessionServer.LOCAL_SESSION);
Releasing a session:
Clients are responsible for releasing sessions after they are finished using the session.
This mechanism allows other clients to access the session through the getAvailableSession
method.
Since sessions are a limited resource, this is a critical responsibility of each client and failure
to perform this step may cause performance and memory degradation, and may eventually exhaust the
capacity of the server.
Sessions are released through the releaseSession
method:
server.releaseSession(mySession); mySession = null;
(Note: it is important to set the session pointer to null since the client still has a valid pointer to a session, but no longer "owns" the session).
Field Summary | |
---|---|
static java.lang.String |
ACTIVE
|
static java.lang.String |
INITIALIZING
Valid values for the state of this object, as returned by getState() |
static java.lang.String |
LOCAL_SESSION
Identifier to be used to obtain the local terminal session in non-TSS. |
static java.lang.String |
NAME
Name used to register this object with RMI naming |
Method Summary | |
---|---|
boolean |
addFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory)
Register an AEFSessionFactory with the session server. |
java.lang.String |
addFactoryBeaconInfo(java.lang.String factoryBeaconInfo)
Register a AEFSessionFactory with the session server given it's beacon info. |
void |
destroySession(java.lang.String terminalNumber)
Destroy an AEFSession. |
com.ibm.retail.AEF.session.AEFSession |
getAvailableSession()
Get an AEFSession object with a status of "available". |
com.ibm.retail.AEF.session.AEFSession |
getAvailableSession(int timeout)
Get an AEFSession object with a status of "available". |
com.ibm.retail.AEF.session.AEFSession |
getAvailableSession(com.ibm.retail.AEF.session.SessionParameters parms)
Get an AEFSession object with a status of "available". |
com.ibm.retail.AEF.factory.AEFSessionFactory |
getFactory(int index)
Get a factory registered with this session server. |
com.ibm.retail.AEF.factory.AEFSessionFactory |
getFactoryFromInfo(com.ibm.retail.AEF.factory.AEFSessionFactoryInfo info,
java.lang.StringBuffer narrative)
Get a session factory reference given it's info object. |
java.util.List |
getFactoryIDs()
Get the number of factories registered with this session server. |
java.lang.String |
getID()
Get the identifier for this session server. |
com.ibm.retail.AEF.util.LoggerControl |
getLoggerControl()
Get the LoggerControl object for the Server JVM. |
int |
getNumberOfFactories()
Get the IDs of the factories registered with this session server. |
com.ibm.retail.AEF.server.SessionServer |
getSelfReference()
Returns a self reference. |
com.ibm.retail.AEF.session.AEFSession |
getSession(java.lang.String terminalNumber)
Get a AEFSession object by terminal number. |
com.ibm.retail.AEF.session.AEFSession |
getSession(java.lang.String terminalNumber,
int timeout)
Get a AEFSession object by terminal number. |
com.ibm.retail.AEF.session.AEFSession |
getSession(java.lang.String terminalNumber,
com.ibm.retail.AEF.session.SessionParameters parms)
Get a AEFSession object by terminal number. |
com.ibm.retail.AEF.session.AEFSession |
getSessionFromFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory,
java.lang.String terminalNumber,
com.ibm.retail.AEF.session.SessionParameters parms)
Get a session from a factory. |
java.lang.String |
getState()
Get the state of this session server. |
void |
releaseSession(com.ibm.retail.AEF.session.AEFSession session)
Release an AEFSession to free it for other clients to use |
void |
removeFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory)
Remove a registered AEFSessionFactory from the session server. |
boolean |
sessionExists(java.lang.String terminalNumber)
Indicates if a session for this terminal number has been created. |
void |
updateFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory)
Update factory info from a AEFSessionFactory with the session server. |
Field Detail |
public static final java.lang.String NAME
public static final java.lang.String LOCAL_SESSION
Example:
mySession = server.getSession(SessionServer.LOCAL_SESSION)
public static final java.lang.String INITIALIZING
getState()
public static final java.lang.String ACTIVE
Method Detail |
public com.ibm.retail.AEF.session.AEFSession getAvailableSession() throws java.rmi.RemoteException, AEFException
An AEFSession is in the available state if no other clients have references to it
This method establishes a client reference to the session and removes it from the pool of available sessions.
Clients must use the release() method to return the session to the pool of available sessions.
A session must be in a "ready state", ie ready for input. An exception
is thrown otherwise. This method uses the default timeout value specified
by the property ready.wait.timeout
contained
in the config.properties
file.
If the client wishes the AEF to log some sort of client id with the session number,
then the client should call getAvailableSession(parms)
instead, where parms
includes the client ID.
java.rmi.RemoteException
AEFException
- if a session can not be accessed
AEFException error codes are:
Releasing a session
public com.ibm.retail.AEF.session.AEFSession getAvailableSession(int timeout) throws java.rmi.RemoteException, AEFException
An AEFSession is in the available state if no other clients have references to it.
This method establishes a client reference to the session and removes it from the pool of available sessions.
Clients must use the release() method to return the session to the pool of available sessions.
This method provides a parameter for specifying a timeout value for waiting on a "ready" session. A timeout value of -1 can be used to specify that no wait is to be performed and "non-ready" sessions should be returned. This allows clients access to sessions which have not reached the ready state.
If the client wishes the AEF to log some sort of client id with the session number,
then the client should call getAvailableSession(parms)
instead, where parms
includes the client ID.
timeout
- time to wait for sessions which are not ready for input (milliseconds)
Use a timeout value of -1 to indicate that the session should be returned even if it is not in a ready state.
java.rmi.RemoteException
AEFException
- if a session can not be accessed
AEFException error codes are:
Releasing a session
public com.ibm.retail.AEF.session.AEFSession getAvailableSession(com.ibm.retail.AEF.session.SessionParameters parms) throws java.rmi.RemoteException, AEFException
An AEFSession is in the available state if no other clients have references to it.
This method establishes a client reference to the session and removes it from the pool of available sessions.
Clients must use the release() method to return the session to the pool of available sessions.
If the client wishes the AEF to log some sort of client id with the session number,
then the client should call setClientID
on the SessionParamemters
argument. When a session is returned, an AEF log entry will be made to record the association
between the client ID and the session ID. This information could be used to determine which
session was associated with a particular client.
This method provides a SessionParameter object for specifying parameters.
parms
- SessionParameters object specifies all parameters for this session
java.rmi.RemoteException
AEFException
- if a session can not be accessed
AEFException error codes are:
Releasing a session
public com.ibm.retail.AEF.session.AEFSession getSession(java.lang.String terminalNumber) throws java.rmi.RemoteException, AEFException
If this is a valid terminal number for the factory, the session is returned, regardless of the number of client accesses. This allows sharing of a session among multiple clients.
This method does not remove the session from pool of available sessions. Clients can remove the session from the available session pool by invoking the reference() method of the AEFSession.
A session must be in a "ready state", ie ready for input. An exception is thrown otherwise. This method uses the default timeout value specified in the config.properties property=ready.wait.timeout.
If the client wishes the AEF to log some sort of client id with the session number,
then the client should call getSession(String terminalNumber, SessionParameters parms)
instead, where parms includes the client ID.
terminalNumber
- identifies the session. Use SessionServer.LOCAL_SESSION
to request the real terminal session running in a real terminal.
java.rmi.RemoteException
AEFException
- if a session can not be accessed
AEFException error codes are:
Referencing a session
public com.ibm.retail.AEF.session.AEFSession getSession(java.lang.String terminalNumber, int timeout) throws java.rmi.RemoteException, AEFException
If this is a valid terminal number for the factory, the session is returned, regardless of the number of client accesses. This allows sharing of a session among multiple clients.
This method does not remove the session from pool of available sessions. Clients can remove the session from the available session pool by invoking the reference() method of the AEFSession.
This method provides a parameter for specifying a timeout value for waiting on a "ready" session. A timeout value of -1 can be used to specify that no wait is to be performed and "non-ready" sessions should be returned. This allows clients access to sessions which have not reached the ready state.
If the client wishes the AEF to log some sort of client id with the session number,
then the client should call getSession(String terminalNumber, SessionParameters parms)
instead, where parms includes the client ID.
terminalNumber
- identifies the session. Use SessionServer.LOCAL_SESSION
to request the real terminal session running in a real terminal.
java.rmi.RemoteException
AEFException
- if a session can not be accessed
AEFException error codes are:
Referencing a session
public com.ibm.retail.AEF.session.AEFSession getSession(java.lang.String terminalNumber, com.ibm.retail.AEF.session.SessionParameters parms) throws java.rmi.RemoteException, AEFException
If this is a valid terminal number for the factory, the session is returned, regardless of the number of client accesses. This allows sharing of a session among multiple clients.
This method does not remove the session from pool of available sessions. Clients can remove the session from the available session pool by invoking the reference() method of the AEFSession.
This method provides a SessionParameter object for specifying the session parms.
If the client wishes the AEF to log some sort of client id with the session number,
then the client should call setClientID
on the SessionParamemters
argument. When a session is returned, an AEF log entry will be made to record the association
between the client ID and the session ID. This information could be used to determine which
session was associated with a particular client.
terminalNumber
- identifies the session. Use SessionServer.LOCAL_SESSION
to request the real terminal session running in a real terminal.parms
- SessionParameters object contains the session parameter vales
java.rmi.RemoteException
AEFException
- if a session can not be accessed
AEFException error codes are:
Referencing a session
public void releaseSession(com.ibm.retail.AEF.session.AEFSession session) throws java.rmi.RemoteException, AEFException
session
- AEFSession to be released
java.rmi.RemoteException
- if server is not available
AEFException
- if an error occurs accessing a sessionpublic void destroySession(java.lang.String terminalNumber) throws java.rmi.RemoteException, AEFException
This method applies only to virtual (TSS) sessions. It terminates the POS sales application and removes the AEFSession from the SessionPool.
terminalNumber
- identifies the session
java.rmi.RemoteException
AEFException
- if a session can not be destroyed
AEFException error codes are:
public boolean sessionExists(java.lang.String terminalNumber) throws java.rmi.RemoteException
java.rmi.RemoteException
public boolean addFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory) throws java.rmi.RemoteException
This method is used by factories which create and provide session instances to the server. Several factories may exist on local and remote servers, load balanced by the session server.
factory
- AEFSessionFactory to be added
java.rmi.RemoteException
public java.lang.String addFactoryBeaconInfo(java.lang.String factoryBeaconInfo) throws java.rmi.RemoteException
java.rmi.RemoteException
- if server is not availablepublic void removeFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory) throws java.rmi.RemoteException
factory
- AEFSessionFactory to be removed
java.rmi.RemoteException
- if server is not availablepublic void updateFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory) throws java.rmi.RemoteException, AEFException
This method is used by factories as a callback to keep the SessionServer up-to-date with factory information. Several factories may exist on local and remote servers, load balanced by the session server.
factory
- AEFSessionFactory to be updated
java.rmi.RemoteException
AEFException
public java.util.List getFactoryIDs() throws java.rmi.RemoteException
Several factories may exist on local and remote servers, load balanced by the session server.
java.rmi.RemoteException
- if server is not availablepublic int getNumberOfFactories() throws java.rmi.RemoteException
Several factories may exist on local and remote servers, load balanced by the session server.
java.rmi.RemoteException
- if server is not availablepublic com.ibm.retail.AEF.factory.AEFSessionFactory getFactoryFromInfo(com.ibm.retail.AEF.factory.AEFSessionFactoryInfo info, java.lang.StringBuffer narrative) throws java.rmi.RemoteException
info
- The AEFSessionFactoryInfo object which contains the factory URI.narrative
- A StringBuffer to which will be appended a description of
the attempt to get the factory. This may be set to null
if no narrative is desired.
java.rmi.RemoteException
public com.ibm.retail.AEF.session.AEFSession getSessionFromFactory(com.ibm.retail.AEF.factory.AEFSessionFactory factory, java.lang.String terminalNumber, com.ibm.retail.AEF.session.SessionParameters parms) throws java.rmi.RemoteException, AEFException
factory
- AEFSessionFactoryterminalNumber
- identifies terminal number or null for any available terminalparms
- SessionParameters object contains all parms for the session as
name-value pairs.
java.rmi.RemoteException
AEFException
- AEFException return codes are:
public com.ibm.retail.AEF.factory.AEFSessionFactory getFactory(int index) throws java.rmi.RemoteException, AEFException
Several factories may exist on local and remote servers, load balanced by the session server.
index
- index of factory
AEFException
java.rmi.RemoteException
public com.ibm.retail.AEF.util.LoggerControl getLoggerControl() throws java.rmi.RemoteException, AEFException
java.rmi.RemoteException
AEFException
public java.lang.String getID() throws java.rmi.RemoteException
java.rmi.RemoteException
public java.lang.String getState() throws java.rmi.RemoteException
SessionServerMBean.SERVER_INITIALIZING
and
SessionServerMBean.SERVER_ACTIVE
.
java.rmi.RemoteException
public com.ibm.retail.AEF.server.SessionServer getSelfReference() throws java.rmi.RemoteException
java.rmi.RemoteException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |