@Documented @Inherited @Retention(value=RUNTIME) @Target(value={TYPE,METHOD,FIELD}) @NormalScope(passivating=false) public @interface TransactionScoped
A @TransactionScoped contextual instance will unique for a given
CODI-managed Transaction. The context will get started when the outermost
Transactional method gets invoked and will get closed when
the call chain leaves the outermost Transactional method.
The classic use-case is for producing JPA EntityManagers.
@Dependent
public class EntityManagerProducer
{
private @PersistenceContext(unitName = "test") EntityManager entityManager;
public @Produces @TransactionScoped EntityManager createEntityManager()
{
return entityManager;
}
public void closeEntityManager(@Disposes EntityManager em)
{
em.close();
}
}
TransactionalCopyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.