|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sap.tc.mobile.session.api.Session
public abstract class Session
Application session. Each user session (e.g., application or background process) holds a Session object, which manages used services in this session. Generally, there is 1:1 mapping of threads and Session instances, but more precisely, each thread of control (may be composed of several alternating threads, e.g., for Tomcat-based applications) is associated with one session.
For example, persistence manager is one service, synchronization another. Instances of these services will be created on-demand on this session and destroyed after session ends.
It is important to get handles to other services from session in session service initializer. This causes building up a unidirectional dependency graph, which is used to commit/rollback/release services in proper order (e.g., first we call commit on synchronization service and at the very last on persistence manager). Handles to sibling services (e.g., sync service called from some kind of application service) don't need to and should not be be obtained at service initialization time to allow for lazy loading.
Each session service implementation must implement
SessionService interface.
Sessions are transactional. Each service should use persistence facilities of underlying data store service (i.e., persistency service) and not persist data by itself. Persistence manager can and should be obtained using standardized means in session service initialization. Please see configuration session service implementation for an example of how to get persistence manager.
Please use SessionSPI.createSession()
(SPI) to instantiate sessions.
SessionService,
SessionSPI,
More information about sessions| Field Summary | |
|---|---|
protected boolean |
invalid
Invalid flag on current session's transaction. |
| Constructor Summary | |
|---|---|
Session()
|
|
| Method Summary | |
|---|---|
abstract void |
assertValid()
Assert that current session is still valid. |
abstract java.lang.Object |
clone()
|
abstract Session |
cloneSession()
Clone a session. |
abstract void |
commit()
Commit session's changes. |
abstract void |
commit(boolean toPassive)
|
abstract void |
flushCache()
Flush caches |
abstract java.lang.String |
getProperty(java.lang.String key,
java.lang.String defValue)
Get user-defined session property. |
abstract long |
getTimeout()
Get timeout for this session. |
abstract boolean |
hasChanged()
|
void |
invalidate()
Invalidate current (sub-)transaction running in the session. |
void |
invalidateCond(boolean doInvalidate)
Invalidate current (sub-)transaction running in the session conditionally. |
boolean |
isInvalidated()
Check whether the (sub-)transaction has been invalidated. |
abstract Subtransaction |
openSubtrans()
Creates a new subtransaction. |
abstract void |
release()
Release the session and all registered services. |
abstract void |
rollback()
Roll back session's changes. |
abstract void |
setProperty(java.lang.String key,
java.lang.String value)
Set user-defined session property. |
abstract void |
setTimeout(long ms)
Set timeout for this session. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean invalid
| Constructor Detail |
|---|
public Session()
| Method Detail |
|---|
public abstract void setTimeout(long ms)
ms - timeout in milliseconds.public abstract long getTimeout()
public abstract void commit()
java.lang.RuntimeException - subclass of RuntimeException is throws, when
commit fails from some reason. In this case, rollback() is
executed instead of commit. If more than one exception occurs, all
exceptions are chained into one exception to have all stack traces
available.invalidate(),
invalidateCond(boolean),
isInvalidated()public abstract void commit(boolean toPassive)
public abstract void flushCache()
public abstract void rollback()
java.lang.RuntimeException - subclass of RuntimeException is thrown, when
rollback fails from some reason. If more than one exception occurs, all
exceptions are chained into one exception to have all stack traces
available.invalidate(),
invalidateCond(boolean),
isInvalidated()public abstract Subtransaction openSubtrans()
Subtransactionpublic abstract void release()
java.lang.RuntimeException - subclass of RuntimeException is thrown, when release fails
for some reason. If release of one module fails, other
modules are released nevertheless. If more than one exception
occurs, all exceptions are chained into one exception to have
all stack traces available.public abstract Session cloneSession()
java.lang.RuntimeException - subclass of RuntimeException is thrown, when
clone fails from some reason.
public abstract void setProperty(java.lang.String key,
java.lang.String value)
key - property key.value - property value.
public abstract java.lang.String getProperty(java.lang.String key,
java.lang.String defValue)
key - property key.defValue - default value.
public final void invalidate()
invalidateCond(boolean),
isInvalidated()public final void invalidateCond(boolean doInvalidate)
closeSubtrans(boolean error).
doInvalidate - if true, do the invalidation.invalidate(),
isInvalidated()public final boolean isInvalidated()
invalidate(),
invalidateCond(boolean)public abstract void assertValid()
java.lang.RuntimeException - if the session is not valid anymore.public abstract java.lang.Object clone()
clone in class java.lang.Objectpublic abstract boolean hasChanged()
true anything has changed in persistency.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||