Skip to content

Instantly share code, notes, and snippets.

@domingogallardo
Created November 24, 2015 08:14
Show Gist options
  • Save domingogallardo/7d79d00fe50b22306985 to your computer and use it in GitHub Desktop.
Save domingogallardo/7d79d00fe50b22306985 to your computer and use it in GitHub Desktop.
Uso de @TransactionScoped en un bean gestionado (https://en.wikipedia.org/wiki/Java_Transaction_API)
@TransactionScoped
public class TxScopedBean {
public int number;
public int getNumber() {return number;}
public void setNumber(int number) {this.number = number;}
}
@RequestScoped
public class ExampleBean {
@Inject
private TxScopedBean tXscopedBean;
@Transactional
public void foo() {
tXscopedBean.setNumber(1);
}
@Transactional
public void bar() {
System.out.print(tXscopedBean.getNumber());
}
}
@domingogallardo
Copy link
Author

Es también un buen ejemplo de que los beans gestionados se obtienen en el momento de la invocación de sus métodos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment