In this tutorial you will learn that how to access Enterprise Beans (applicable only to session beans not to message-driven beans)
Enterprise beans are accessed by the client in two ways either through a no-interface view or through a business interface.
In this view the enterprise bean implemented class discloses the public methods to clients. Using this view enterprise bean implemented class's or any super classes of the implementation class's public methods may be accessed by an enterprise bean.
This interface is an interface of Java programming language which keeps the business methods of enterprise bean.
To use a session bean client will have to required either bean's business's interface methods or enterprise bean's public methods which has a no-interface view.
To know before the use of Enterprise Beans in clients let us first know about the clients. The can be Local clients, Remote clients and Web Service clients. To identify these clients they have some characteristic.
Characteristics of Local clients :
Characteristics of Remote clients :
Web Service clients :
Java EE application can be accessed by a web service client in two manner :
Enterprise Beans are the server side component that encapsulates the logic of fulfillment of the purpose of an application. Instance of these Enterprise Beans in clients can be use/get by either the dependency injection or JNDI lookup.
Dependency Injection is a Java programming language annotations using which a instance of an Enterprise Bean can be get in a easy way. It is used when a client run inside the Java EE server-managed environment. Annotation that is used to support the dependency injection to the enterprise beans or the applications (JavaServer Faces web applications, Java EE application clients, JAX-RS web services, or other enterprise beans) which are runs within the Java EE server managed environment is javax.ejb.EJB.
JNDI, Java Naming and Directory Interface syntax is also used to get an instance of an Enterprise Bean. It is used when an application is running outside a Java EE server managed environment must required to perform an explicit lookup. To identify a Java EE components that will be explicitly lookup JNDI provides a global syntax.
Portable JNDI syntax :
There are three JNDI namespaces that are used for portable JNDI lookup :
java:global :- Used to find out the remote enterprise beans.
java:global[/application name]/module name/enterprise bean name[/interface name]
Here application and module names are the by default application and module names minus the file extension. Interface name is need only when more than one business interfaces are implemented by an enterprise bean, and the application names are need only when the application is packaged into an EAR (Enterprise Archieve ).
java:module :- use to find out the local enterprise beans inside the same module.
java:module/enterprise bean name/[interface name]
Here interface is need only when more than one business interfaces are implemented by an enterprise bean.
java:app :- used to find out the local enterprise beans which are packaged inside the same application.
java:app[/module name]/enterprise bean name[/interface name]
Here the module name is optional and the interface is need only when more than one business interfaces are implemented by an enterprise bean.
It is very important in any Java EE application that how to allow a client accessing by the enterprise bean i.e. remote, local or web service.
To allow for a remote or local accessing it is based on the following factors :
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: How to access Enterprise Beans
Post your Comment