|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sap.conn.jco.JCoContext
public abstract class JCoContext
The JCoContext class allows the execution of stateful function call sequences with JCo.
It provides methods for notifying the JCo runtime about starting and ending
stateful call sequences for a specific destination. The same connection will be used
for all remote function calls between invoking the start() and end() methods. This is
typically used for multi-step logical units of work (LUWs), in which several
function modules are executed in a row and are committed afterwards.
In case an error occurs during the communication and the connection is broken or
closed, an exception will be thrown and the application should take care of this.
Depending on the application it might be necessary to repeat all function calls of
the failed sequence as the back-end will do an automatic rollback of all previous
operations that have not been committed yet.
JCoDestination destination = JCoDestinationManager.getDestination("<destination>"); try { JCoContext.begin(destination); function1.execute(destination); function2.execute(destination); functionBapiTransactionCommit.execute(destination); } catch (AbapException ex) { ... } catch (JCoException ex) { ... } catch (Exception ex) { ... } finally { JCoContext.end(destination); }Internally, the JCo runtime considers all calls executed in the current session and scope between begin() and end() as coherent and sends the calls over the same connection. Stateful contexts can be nested. The respective connection will be released only after the root context is ended, i.e. end() needs to be called as many times as begin() was called before for a specific destination.
Constructor Summary | |
---|---|
protected |
JCoContext()
Only used internally. |
Method Summary | |
---|---|
static void |
begin(JCoDestination destination)
Begins a stateful call sequence for calls to the specified destination. |
static void |
end(JCoDestination destination)
Ends a stateful call sequence for calls to the specified destination. |
static boolean |
isStateful(JCoDestination destination)
Returns true if a stateful call sequence has been started in the current session and is not finished yet, i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected JCoContext()
Method Detail |
---|
public static void begin(JCoDestination destination)
begin(JCoDestination)
and end(JCoDestination)
will not be reset or closed. As a consequence
the user context in the ABAP back-end will be kept.JCoContext.begin()
reserves a connection for exclusive
usage, you should only switch to the stateful context if this is really required.
Stateless processing should be preferred wherever possible, i.e. avoid using
JCoContext.begin()
/JCoContext.end()
sequences if the used
function modules do not store any state in the ABAP system.
destination
- The destination for which to start a back-end context for processing
stateful call sequencespublic static void end(JCoDestination destination) throws JCoException
destination
- The destination for which the back-end context should be ended.
JCoException
- in case releasing/closing the connection runs into an issuepublic static boolean isStateful(JCoDestination destination)
destination
- for which the stateful context will be checked
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |