Home Interview Questions and AnswersTechnical Interview Questions and AnswersEJB EJB Interview Questions and Answers For Freshers Part-2

 

ejb11.Explain @javax.ejb.Stateless annotation.

@javax.ejb.Stateless annotation specifies that a given ejb class is a stateless session bean.Following are its 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.

12.Explain @javax.ejb.Stateful annotation.
@javax.ejb.Stateful annotation specifies that a given ejb class is a stateful session bean.Following are its 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.

13.Explain @javax.ejb.MessageDrivenBean annotation.
@javax.ejb.MessageDrivenBean annotation specifies that a given ejb class is a message driven bean. Following are its 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 operational environment of the message driven bean. mappedName – Used to specify the JNDI name of the message driven bean. description – Used to provide description of the message driven bean.

14.Explain @javax.ejb.EJB annotation.
@javax.ejb.EJB annotation is used to specify or inject a dependency as ejb instance into another ejb. Following are its attributes:

name – Used to specify name which will be used to locate the referenced bean in 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.

15.Explain @javax.ejb.Local annotation.
@javax.ejb.Local annotation is 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 same deployment/application as EJB.

Following are its attributes:

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

16.Explain @javax.ejb.Remote annotation.
@javax.ejb.Remote annotation is 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.

Following are its attributes:

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

17.Explain @javax.ejb.ActivationConfigProperty annotation.
@javax.ejb.ActivationConfigProperty annotation is 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. Following are its attributes:

propertyName – name of the property.

propertyValue – value of the property.

18.Explain @javax.ejb.PostActivate annotation.
@javax.ejb.PostActivate annotation is 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.

19.What are the key components of persistence API in EJB?
Following are the key components of persistence API in EJB:

Entity – A persistent object representing the data-store record. It is good to be serializable.

EntityManager – Persistence interface to do data operations like add/delete/update/find on persistent object(entity). It also helps to execute queries using Query interface.

Persistence unit (persistence.xml) – Persistence unit describes the properties of persistence mechanism.

Data Source (*ds.xml) – Data Source describes the data-store related properties like connection url. user-name,password etc.

20.Is Message Driven bean a stateless bean?
Message driven bean is a stateless bean and is used to do task asynchronously.

You may also like

Leave a Comment