Services
Getting direct access to a service from within the workflow can be done via the following
tb.getService("urlStore");
Session Management
Basic Session management in Trustbuilder can be enabled by adding the following property in trustbuilder.properties in the TB_HOME folder. This will delegate the storage of the session attributes into the container session.
sessionService=true
The sessions can be stored in third-party storage services too. For this, you should set the property to the id of the service handling the storing/retrieval. Currently 3 other backends are available: Database, Memcached and Redis (For configuration see the services section). But it's pretty trivial to write your own, provided that this service implements TrustBuilderCacheService.
In order to use the session service in the workflow 4 functions were created:
// Get a session variable by it's key
getSessionVariable(key)
// Set a session variable with a specific key/value pair
setSessionVariable(key,value)
// Set the timeout of a session in case of a servlet backed session
setSessionTimeoutInSec(sec)
// InvalidateSession Invalidate the session in case of a servlet backed session
invalidateSession()
For example an in-memory store.
<stb:Service stb:id="urlStore" stb:type="be.securit.trustbuilder.util.TimedBlockingHashMap" stb:singleton="true">
<stb:property stb:name="ttl">30000</stb:property>
</stb:Service>
<stb:Service stb:id="objectStore" stb:type="be.securit.trustbuilder.util.TimedBlockingHashMap" stb:singleton="true">
<stb:property stb:name="ttl">30000</stb:property>
</stb:Service>
In this example we configure 2 memory stores, this can be used to store a session, send information between threads and so on. The ttl property specifies how long a key exists in the store in milliseconds.
AVAILABLE SERVICES: