Java Reference
In-Depth Information
Simpliied checked exceptions
Checked exceptions are exceptions that are not a subclass of the java.lang.
RuntimeException . In EJB 2.1, if a bean method performs an operation that results
in a checked exception that the bean method cannot recover, the bean method should
throw the javax.ejb.EJBException that wraps the original exception. In EJB 3.0,
application exceptions that are checked exceptions may be defined as such by being
declared in the throws clause of the methods of the bean's business interface, home
interface, component interface, and web service endpoint. AroundInvoke methods
are allowed to throw checked exceptions that the business methods allow in the
throws clause.
Callback Interfaces
As we discussed in the previous sections, callback interfaces javax.ejb.
SessionBean, and javax.ejb.EntityBean are not implemented by the session
beans and entity beans respectively. The callback methods of these methods are not
implemented by the session and entity beans. Any method may be made a callback
method using the callback annotations such as PostActivate , PrePassivate ,
PreDestroy , and PostConstruct . The callback methods may be specified in a
callback listener class instead of the bean class.
In this chapter, we discussed the new features in EJB 3.0. We compared the EJB 3.0
features with EJB 2.0 features and discussed how EJB 3.0 is different from EJB 2.0.
EJB 3.0 metadata annotations reduce the code required and make the deployment
descriptors redundant. The local/remote and local home/home interfaces are not
required in EJB 3.0 entity beans, and only a POJO class is required for an entity bean.
The Java Persistence API provides an object-relational mapping model. Interceptors,
simplified checked exceptions, and callback interfaces are some of the other new
features in EJB 3.0.
In the next chapter, we shall convert an example EJB 2.x entity bean to an
EJB 3.0 entity bean.
Search WWH ::

Custom Search