📜  EJB-注释

📅  最后修改于: 2020-11-16 06:17:11             🧑  作者: Mango


Java 5.0中引入了注释。具有注释的目的是在类中或在其源代码内的类的元数据中附加附加信息。在EJB 3.0中,注释用于描述EJB类中的配置元数据。通过这种方式,EJB 3.0消除了在配置XML文件中描述配置数据的需要。

EJB容器使用编译器工具通过读取那些注释来生成所需的工件,例如接口,部署描述符。以下是常用注释的列表。

Sr.no Name Description
1

javax.ejb.Stateless

Specifies that a given EJB class is a stateless session bean.

Attributes

  • name − Used to specify name of the session bean.

  • mappedName − Used to specify the JNDI name of the session bean.

  • description − Used to provide description of the session bean.

2

javax.ejb.Stateful

Specifies that a given EJB class is a stateful session bean.

Attributes

  • name − Used to specify name of the session bean.

  • mappedName − Used to specify the JNDI name of the session bean.

  • description − Used to provide description of the session bean.

3

javax.ejb.MessageDrivenBean

Specifies that a given EJB class is a message driven bean.

Attributes

  • name − Used to specify name of the message driven bean.

  • messageListenerInterface − Used to specify message listener interface for the message driven bean.

  • activationConfig − Used to specify the configuration details of the message-driven bean in an operational environment of the message driven bean.

  • mappedName − Used to specify the JNDI name of the session bean.

  • description − Used to provide description of the session bean.

4

javax.ejb.EJB

Used to specify or inject a dependency as EJB instance into another EJB.

Attributes

  • name − Used to specify name, which will be used to locate the referenced bean in the environment.

  • beanInterface − Used to specify the interface type of the referenced bean.

  • beanName − Used to provide name of the referenced bean.

  • mappedName − Used to specify the JNDI name of the referenced bean.

  • description − Used to provide description of the referenced bean.

5

javax.ejb.Local

Used to specify Local interface(s) of a session bean. This local interface states the business methods of the session bean (which can be stateless or stateful).

This interface is used to expose the business methods to local clients, which are running in the same deployment/application as EJB.

Attributes

  • value − Used to specify the list of local interfaces as an array of interfaces.

6

javax.ejb.Remote

Used to specify Remote interface(s) of a session bean. This remote interface states the business methods of the session bean (which can be stateless or stateful).

This interface is used to expose the business methods to remote clients, which are running in different deployment/application as EJB.

Attributes

  • value − Used to specify the list of remote interfaces as an array of interfaces.

7

javax.ejb.Activation ConfigProperty

Used to specify properties required for a message driven bean. For example, end point, destination, message selector etc.

This annotation is passed as a parameter to activationConfig attribute of javax.ejb.MessageDrivenBean annotation.

Attributes

  • propertyName − name of the property.

  • propertyValue − value of the property.

8

javax.ejb.PostActivate

Used to specify callback method of EJB lifecycle. This method will be called when EJB container just activated/reactivated the bean instance.

This interface is used to expose the business methods to local clients, which are running in same deployment/application as EJB.