Created
November 24, 2015 08:14
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Es también un buen ejemplo de que los beans gestionados se obtienen en el momento de la invocación de sus métodos.