EJB Annotations: Difference between revisions
(11 intermediate revisions by the same user not shown) | |||
Line 16: | Line 16: | ||
=@javax.ejb.Remote= | =@javax.ejb.Remote= | ||
See {{Internal|EJB_Concepts#Local_and_Remote_Interfaces|EJB Concepts - Local and Remote Interfaces}} | |||
=@javax.ejb.Local= | =@javax.ejb.Local= | ||
See {{Internal|EJB_Concepts#Local_and_Remote_Interfaces|EJB Concepts - Local and Remote Interfaces}} | |||
=@javax.annotation.PostConstruct= | =@javax.annotation.PostConstruct= | ||
The @PostConstruct annotation is used on a method that needs to be executed after dependency injection is done into the component. The method such annotated is understood to perform initialization of the component. Only one method per component can be annotated with this annotation. The annotated method must not have any parameters (except in the case of interceptors in which case it takes an <tt>InvocationContext</tt> instance. The method may be public, protected, package private or private, but not static. It can be declared final. If the method throws an unchecked exception, the component must not be put into service except in the case of EJBs where the EJB can handle exceptions. | The @PostConstruct annotation is used on a method that needs to be executed after dependency injection is done into the component. The method such annotated is understood to perform initialization of the component. Only one method per component can be annotated with this annotation. The annotated method must not have any parameters (except in the case of interceptors in which case it takes an <tt>InvocationContext</tt> instance. The method may be public, protected, package private or private, but not static. It can be declared final. If the method throws an unchecked exception, the component must not be put into service except in the case of EJBs where the EJB can handle exceptions. | ||
Used by: | |||
* [[MDB#.40PostConstruct|MDBs]] | |||
* [[Singleton_Session_EJB#Lifecycle|Singleton sesion beans]] | |||
=@javax.annotation.PreDestroy= | =@javax.annotation.PreDestroy= | ||
Line 27: | Line 35: | ||
The @PreDestroy annotation is used on a method to be invoked by the container when it intents the remove the component instance. Such methods are typically used to release resources that the component has been holding. This annotation must be supported by all container managed components that support [[#.40javax.annotation.PostConstruct|@PostConstruct]]. The annotated method must not have any parameters (except in the case of interceptors in which case it takes an <tt>InvocationContext</tt> instance. The method may be public, protected, package private or private, but not static. | The @PreDestroy annotation is used on a method to be invoked by the container when it intents the remove the component instance. Such methods are typically used to release resources that the component has been holding. This annotation must be supported by all container managed components that support [[#.40javax.annotation.PostConstruct|@PostConstruct]]. The annotated method must not have any parameters (except in the case of interceptors in which case it takes an <tt>InvocationContext</tt> instance. The method may be public, protected, package private or private, but not static. | ||
Used by: | |||
* [[MDB#.40PreDestroy|MDBs]] | |||
* [[Singleton_Session_EJB#Lifecycle|Singleton sesion beans]] | |||
=Annotations= | =Annotations= | ||
Line 32: | Line 43: | ||
* [[@javax.persistence.PersistenceUnit|@javax.persistence.PersistenceUnit]] | * [[@javax.persistence.PersistenceUnit|@javax.persistence.PersistenceUnit]] | ||
* [[@javax.persistence.PersistenceContext|@javax.persistence.PersistenceContext]] | * [[@javax.persistence.PersistenceContext|@javax.persistence.PersistenceContext]] | ||
* [[@javax.ejb.TransactionAttribute|@javax.ejb.TransactionAttribute]] | |||
* [[@javax.ejb.ApplicationException|@javax.ejb.ApplicationException]] | |||
* [[@javax.ejb.Startup|@javax.ejb.Startup]] | |||
* [[@javax.ejb.DependsOn|@javax.ejb.DependsOn]] | |||
* [[@javax.ejb.Lock|@javax.ejb.Lock]] | |||
* [[@javax.inject.Inject|@javax.inject.Inject]] | |||
* [[@javax.ejb.Schedule|@javax.ejb.Schedule]] | |||
* [[@javax.ejb.Schedules|@javax.ejb.Schedules]] | |||
* [[@javax.ejb.Timeout|@javax.ejb.Timeout]] |
Latest revision as of 15:07, 28 September 2017
Internal
Overview
If an XML deployment descriptor containing the same semantics exists, the XML content overrides the annotation.
@javax.ejb.EJB
@javax.annotation.Resource
@javax.ejb.Remote
See
@javax.ejb.Local
See
@javax.annotation.PostConstruct
The @PostConstruct annotation is used on a method that needs to be executed after dependency injection is done into the component. The method such annotated is understood to perform initialization of the component. Only one method per component can be annotated with this annotation. The annotated method must not have any parameters (except in the case of interceptors in which case it takes an InvocationContext instance. The method may be public, protected, package private or private, but not static. It can be declared final. If the method throws an unchecked exception, the component must not be put into service except in the case of EJBs where the EJB can handle exceptions.
Used by:
@javax.annotation.PreDestroy
The @PreDestroy annotation is used on a method to be invoked by the container when it intents the remove the component instance. Such methods are typically used to release resources that the component has been holding. This annotation must be supported by all container managed components that support @PostConstruct. The annotated method must not have any parameters (except in the case of interceptors in which case it takes an InvocationContext instance. The method may be public, protected, package private or private, but not static.
Used by: