| |||||||||||||||||||||||||||
| Using Tyrex Transaction Domains Resources The Runtime Context JTA Extended Interfaces Transaction DomainsA The application server obtains the transaction manager, user transaction and transaction factory from the transaction domain. It also uses the transaction domain to obtain connection factories and place them in the JNDI Environment Naming Context. Transaction domains are created from domain configuration files. The structure and values of the domain configuration file is specified in Tyrex Configuration. The following example illustrates how to create a new transaction domain from the
domain configuration file domain.xml located in the current directory:
ResourcesThe object Each resource manager is represented by an object of type An installed resource has a client factory that is exposed to the application from the JNDI Environment Naming Context. The client factory type depends on the resource type, e.g. a JDBC DataSource, a JCA CCI ConnectionFactory, etc. An installed resource has a connection pool that manages utilization of connections.
The connection pool is not directly accessible to the application, but the usage
metrics are accessible from The Runtime ContextThe runtime context keeps track of open transactions, JNDI Environment Naming Context, security subject, resource managers and open connector. It is managed for a given component or client, and can be preserved across method calls in different threads, by associating and dissociating it from the current thread. Each thread is associated with one runtime context at any given time. A new runtime context can be created using one of the newRuntimeContext() methods, and populated with JNDI bindings and a security context. The runtime context is then associated/dissociated with the current thread across method invocations using the setRuntimeContext() and unsetRuntimeContext() methods. The runtime context association works like a stack. Calling setRuntimeContext() pushes the current runtime context up the stack, and associates the thread with the current runtime context. Calling unsetRuntimeContext() pops the previous runtime context from the stack and associates it with the thread. A thread will always have a runtime context created on demand, if setRuntimeContext() was not called explicitly. The runtime context keeps track of the current open transaction. When the runtime context is associated with the current thread, this is the same transaction on which the transaction manager operates. The runtime context keeps track of the JNDI Environment Naming Context. When the runtime context is associated with the current thread, the same bindings will be accessible to the application from the java: URL. The runtime context keeps track of the security subject used for authentication and authorization. When the runtime context is associated with the current thread, this subject is used to authenticate the caller against resource managers and other services. The runtime context keeps track of all connections opened from connection pools obtained from the JNDI Environment Naming Context. Open connections and their transaction association is maintained across method invocations through the runtime context. The following example illustrates how the application server will create and use a runtime
context:
The following example illustrates how the application obtains a new JDBC connection
from the data source previously listed in the JNDI context: JTA Extended InterfacesAll Tyrex transactions implement the extended interface The Tyrex transaction manager implements the extended interface Interceptors allow an external engine to hook up into the transaction monitor and either record the outcome of transactions or affect them. The interceptor is notified when transactions are created, attempt to commit, rolled back, and when they are resumed or suspended from threads. | ||||||||||||||||||||||||||