EJB FAQs
Home -- FAQs Home
A D V E R T I S E M E N T
1. What are EJBs?
Ans:
EJBs are reusable business components developed in java which are hosted by an application server which provides services to EJBs for lifecycle management, remote access etc.
2. What is the dictionary of EJBs?
Ans:
EJBs : Enterprise Java Beans
EJB container- the middle ware, that provides standard services to the EJBs.
Session EJB : A type of EJB containing business logic
Stateless Session Beans - a type of EJB that doesn�t need session management service
State full Session Beans - a type of EJB that needs session management service from the EJB container
Entity EJBs - a type of EJBS which acts as object representation of the business data that is stored/to be stored in the database
CMP Entity Beans - a type of Entity beans that receive persistence service from the EJB container. Because of this service CMP beans need not use JDBC statements but the container will manage the persistence.
BMP Entity Beans - a type of entity bean where the developer of the entity beans makes JDBC calls to persist the data in the entity bean
EJB QL - a language used to write queries for searching a set of entity bean instances that follow particular criteria.
Message Driven Beans - a type of EJB, which uses JMS API for listening to the incoming messages and application server as a JMS provider.
JNDI - Java Naming and Directory interface. ( a naming service)
IDEs - Integrated Development environments.
3. What is middleware?
Ans:
Is connectivity software that Provides set of services to enable multiple processes on different machines to communicate.
4. Is application server a middleware?
Ans:
Yes. It is a special kind of middleware, which can host containers for web components like servlet/jsp or enterprise components like EJBS. If it hosts web container as well as EJB container, it is called as Web-App server preferably.
5. What are the services offered by generic middleware to the components that it hosts?
Ans:
To locate transparently another application across the network providing the required interaction
To be independent from network services
To be reliable and available
Scale up in capacity without loosing function
6. What's the difference between the Object and the component?
Ans:
Objects
Reuse is not easy for business process
Reuse of object is limited to inheritance of a class
Classes are developed in a particular context
Lifecycle management is not automatic
Hard core programming
Components
Related classes are clustered together
Mechanism to assemble and configure systems without hard-core programming
7. What is the format in which EJBs are present in the app server?
Ans:
Every EJB code will consists of interface, the implementation of the interface, helper classes, stub, skeleton etc.
So the EJB is usually archived in some format like jar(java archive). It can be Java archive (.jar file) or enterprise archive (.ear file) or some other archived format.
This ejb jar file will be registered with the app server. Afterwards the app server will redirect any request coming from the client for the ejb to the EJB.
8. What are types of EJBs?
Ans:
Session EJB
Entity EJB
Message Driven EJB
Timer EJB
Session EJBs contain the business logic, which is complex and specific to the domain. For ex: Calculating interest
While as Entity beans always represent a business entity like account/customer.
Because these entities need a permanent existence, every entity bean will be corresponding to one or more tables in database as well. For ex: Account bean will have an account table mapped to it. Every instance of account bean will map to one record of account table and the updation in the bean will update the table as well.
9. Does an EJB always need remote interface?
Ans:
Any java component that needs or might need remote access should have a remote interface but if a local client always accesses the EJB then one can develop local interface for this EJB, which exposes the business functionality of the EJB.
10. What are the minimum program requirements for the EJB?
Ans:
Remote Interface/ Local Interface
Home Interface
Bean class
Client
11. What is home interface and what are differences in remote interface and home interface?
Ans:
Life cycle management is a service that one must take from application server for the EJB components.
That�s why the programmer will never define any method related to life cycle management of the EJBs. But then he/she has to declare those methods and let the ejb container implement the same. Home interface is used for declaring such methods. Ex: crate, find, remove etc. The reason that we need to declare these methods is to specify the list of input and output parameters.
Business methods cannot be part of and this home interface.
12. Why do we need to get handle to Home interface before calling business methods?
Ans:
Home interface exposes the create method to the client. The create method creates/locates actual EJB instance. Unless you call create method you cannot get handle to EJB instance. And for the purpose of calling create method we need handle to Home interface first of all.
13. What could be the role of JNDI in EJBs?
Ans:
JNDI is a naming service. Naming service products are used to help is in locating a remote object uniquely. Naming service software runs on the server side where the remote object is created. Each remote object registers itself with the naming service. The client contacts the naming service, which in turn finds out the reference of the object required by the client.
14. Is it must to use JNDI product as a naming service for EJBs?
Ans:
No. Many other naming service products can be used to locate EJBs.
15. Which all application severs can support EJBs?
Ans:
A J2EE compatible applications sever must have an EJB container that provides service to EJBs. That�s why all J2EE servers have to support EJBs. Some of the examples are � Weblogic from Bea Company, Websphere from IBM, Iplanet from Sun and Netscape, Oracle9i app server from Oracle Corporation and JBOSS, which is open source freeware.
16. What is the meaning of contracts, negotiable contracts and non-negotiable contracts in terms of EJBs?
Ans:
EJBS are to be developed and deployed according to the EJB specification (latest release 2.0 as of 8 Feb 2002) published on Sun�s site. The rules mentioned in this specification are called as contracts but some rules are mandatory for the creating a working EJB and some rules are given as a guideline, which can be followed for a better maintainable EJB. The thumb rules are called as non-negotiable contracts and the other ones are negotiable contracts. Example of non-negotiable contract is having a home interface for the EJB. Example of negotiable contract is that Session EJBs should not make JDBC calls and Entity beans should not contain business logic.
17. Can I schedule business using EJBs?
Ans:
Yes. With the new type of EJB named Timer EJB you can schedule the business logic to run at particular intervals
18. Can I receive asynchronous messages using EJBs?
Ans:
Yes. With a special type of EJB named Message Driven Beans (MDB) you can create asynchronous message listeners.
19. What is the future development expected in EJBs?
Ans:
Quite Bright!! Whenever there are new requirements/change requirements for EJB specifications, Sun is coming up with new version of the specification. Whenever Sun comes up with specification for EJB development, the vendor companies, which develop application server, are coming up with new version of their application server to be compatible with the new specification. But yet the deployment and management is not standard across application servers. Sun us coming
20. What are stories related to the earlier specification versions of EJBs?
Ans:
EJB 1.1 was widely used specification but it was said be little premature about the entity beans specification for receiving the persistence service from the app server. Developers have observed performance problems related to Container Managed persistence. Container managed Relationships (CMR) were implicit part of EJB 1.1. With the new concepts of Local interfaces, CMR, Timer beans etc EJB 2.0 has become quite popular specification.
21. Are there any IDEs for developing and deploying EJBs.
Ans:
Yes. Few examples are IBM Visual Age for Java, Visual Caf� and Pramati Studio is the upcoming IDE from an Indian company named Pramati. Once can find the BOKS on KShop related to the usage of these IDEs.