public static EJBThreadData getUserTransactionThreadData ( ) { EJBThreadData threadData = getThreadData ( ) ; BeanO beanO = threadData . getCallbackBeanO ( ) ; if ( beanO == null ) { EJBException ex = new EJBException ( "EJB UserTransaction can only be used from an EJB" ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "getUserTransactionThreadData: " + ex ) ; throw ex ; } try { beanO . getUserTransaction ( ) ; } catch ( IllegalStateException ex ) { EJBException ex2 = new EJBException ( "EJB UserTransaction cannot be used: " + ex , ex ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "getUserTransactionThreadData: " + beanO + ": " + ex2 ) ; throw ex2 ; } return threadData ; }
Returns the EJB thread data if an EJB context is active on the current thread and that EJB may use UserTransaction .