Java Reference
In-Depth Information
@PostConstruct
public void init(){
entity = em.find(...);
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@PreDestroy
public void destroy(){
em.flush();
}
}
The following code demonstrates how to control passivation of the stateful bean.
Usually,thesessionbeansareremovedfrommemorytobestoredonthediskafter a
certain time of inactivity. This process requires data to be serialized, but during seri-
alization all transient variables are skipped and restored to the default value of their
data type, which is null for object, zero for int , and so on. To prevent the loss of
this type of data, you can simply disable the passivation of stateful session beans by
passing the false value to the passivationCapable attribute of the @Stateful
annotation.
@Stateful(passivationCapable = false)
public class StatefulBeanNewFeatures {
//...
}
For the sake of simplicity, EJB 3.2 has relaxed the rules to define the default local
or remote business interface of a session bean. The following code shows how a
simple interface can be considered as local or remote depending on the case:
//In this example, yellow and green are local
interfaces
public interface yellow { ... }
public interface green { ... }
Search WWH ::




Custom Search