com.sap.conn.jco.ext
Interface JCoSessionReference


public interface JCoSessionReference

A JCoSessionReference is a simple reference to a session or scope in a runtime environment that implemented and registered a SessionReferenceProvider. A session or scope is identified by JCo by its ID(getID()).
A session is not necessarily the local user session, but could also be some nested sub-session or scope. It shall be a unit that has its own local state, and keeps this somewhere in that scope or session. In complex environments, there could be a session-tree, and scopeTypes could identify each level of the hierarchy. In simple environments, there might be only the user session. What fits best to your needs, depends on your use cases. The fewer complexity, the simpler are the scenarios that are possible.
The following short sequence shall illustrate, when the two event methods will be invoked that signal to session management that the business application now wants to establish a context on the remote side. It is assumed that the complete example code is run within the same scope:

 JCoContext.begin(destination1);
 //--> contextStarted() will be invoked on the current session reference
 ...
 JCoContext.begin(destination2);
 ...
 JCoContext.end(destination1);
 ...
 JCoContext.end(destination2);
 //--> contextFinished() will be invoked on the current session reference 
 
As soon as a context has been started, JCo expects that this scope is no longer used concurrently in different threads for all destinations, for which the JCoContext is still open. If a scope is used concurrently, it might end up in a JCoException of group JCO_ERROR_CONCURRENT_CALL being thrown, when trying to execute a function module on a destination set to stateful in this scope. The reasoning behind that is the fact that concurrent execution would end up in random results as the order is not clearly defined. Backend state is associated with the connection. Hence, for a given scope and destination, there is only a single connection allowed.


Method Summary
 void contextFinished()
          This method will be executed when the last connection is released in a stateful sequence within a session.
 void contextStarted()
          This method will be executed when the first call is executed in a stateful sequence within a session.
 java.lang.String getID()
          This method must return a session ID that uniquely identifies the referenced JCoSessionReference in the runtime environment, in which JCo is running.
 

Method Detail

getID

java.lang.String getID()
This method must return a session ID that uniquely identifies the referenced JCoSessionReference in the runtime environment, in which JCo is running. This session ID is used by JCo internally, whenever it is required to identify a specific session or scope context. In particular, JCo is using the ID in order to find out, whether there exists a stateful connection for a certain destination. This happens always when executing a function module or committing a function unit.
Note: JCo is tracing this session ID for supportability reasons. Therefore, you should make sure that you only pass internal IDs to JCo, not external session IDs that could be used for taking over a session of your application.

Returns:
the session ID for the current scope

contextStarted

void contextStarted()
This method will be executed when the first call is executed in a stateful sequence within a session. This is independent from the destination, it simply shows that from now on stateful JCo connections are associated with the referenced session.


contextFinished

void contextFinished()
This method will be executed when the last connection is released in a stateful sequence within a session. This is independent from the destination, it simply shows that from now there is no longer any JCo connection associated with the referenced session.



Copyright © 2008-2014 SAP AG. All Rights Reserved.