J2EE.5.5 UserTransaction ReferencesMany J2EE application component types are allowed to use the JTA UserTransaction interface to start, commit, and abort transactions. Such application components can find an appropriate object implementing the UserTransaction interface by looking up the JNDI name java:comp/UserTransaction . The container is required to provide java:comp/UserTransaction only for those components that can validly make use of it. Any such UserTransaction object is valid only within the component instance that performed the lookup. See the individual component definitions for further information. The following example illustrates how an application component acquires and uses a UserTransaction object. public void updateData(...) { ... // Obtain the default initial JNDI context. Context initCtx = new InitialContext(); // Look up the UserTransaction object. UserTransaction tx = (UserTransaction)initCtx.lookup( "java:comp/UserTransaction"); // Start a transaction. tx.begin(); ... // Perform transactional operations on data. ... // Commit the transaction. tx.commit(); ... } J2EE.5.5.1 Application Component Provider's ResponsibilitiesThe application component provider is responsible for using the defined name to look up the UserTransaction object. Only some application component types are required to have access to a UserTransaction object; see Table J2EE.6-1 in this specification and the EJB 1.1 specification for details. J2EE.5.5.2 Deployer's ResponsibilitiesThe deployer has no specific responsibilities associated with the UserTransaction object. J2EE.5.5.3 J2EE Product Provider's ResponsibilitiesThe J2EE product provider is responsible for providing an appropriate UserTransaction object as required by this specification. J2EE.5.5.4 System Administrator's ResponsibilitiesThe system administrator has no specific responsibilities associated with the User Transaction object. |