Play and learn 300 000+ tabs online

Saturday, January 23, 2010

Enterprise JavaBeans -Part1

1)What are the design goals of the Enterprise JavaBeansTM architecture?
The Enterprise JavaBeans specification defines a standard architecture for implementing the business logic of multi-tier applications as reusable components

In addition to Enterprise JavaBeans components, the architecture defines three other entities:servers,containers, and clients.

This architecture incorporates several design goals: Enterprise JavaBeans servers are designed to wrap around legacy systems to provide fundamental services for “containers and the components they contain”

Enterprise JavaBeans containers are designed to handle details of “component” life-cycle, transaction, and security management Component developers are free to focus on business logic, since containers provide services automatically by interceding in component method calls. A simple set of callback interfaces are all that a developer needs to implement to participate in container provided services.  A client’s view of an Enterprise JavaBean remains the same regardless of the container it is deployed in. Any container in which an Enterprise JavaBean is deployed presents the same interfaces to the client. This extends to containers from different vendors, running against different servers and different databases, on diverse systems on a network. This client transparency ensures wide scalability for multi-tier applications.



1)What is Enterprise JavaBeans?

a)EJB architecture is component architecture for the develeopment and deployment of component-based distributed business applications.EJB the widely adopted serverside component architecture for Java2 platform,Enterprise ediition(J2EE),versatile,reusable and portable across middleware.

2)Is Ejb a product?

a)No, Ejb is a specification,Enterprise JavBeans defines the EJB component architecture and the interfaces between the EJB enabled server and the component.

3)who are ejb product owners?

a)EJB is not a product it is a  specification implemented by Sun with participation from many key vendors in the industry.Vendors like IBM,BEA,Sun and Oracle  etc., are providing products that implement the EJB specification.

4)what are the main features in EJB?

a)     EJB architecture is inherently transactional,distributed,portable,multiered and secure.

EJB components are serverside components written entirely in the java.

EJB components contain business logic only no system level programing.

    System level services such as transactions,security,Life cycle,threading,persistence,etc are    automatically managed by the EJB Component by the EJB server.

    EJB architecture is wire-protocol neutral Any protocol can be utilized:HTTP,IIOP,DCOM etc.


5)what is current EJB version?

a)EJB2.0 is currently int he Expert Group phase of the JCP(Java Community process) specification development.

6)what are the key features to be included in EJB 2.0?

a)Integration with JMS.Message Driven bean has been introduced.

b)CMP for Entity bean was replaced with CMR.

c)Integration with Corba Interoperability protocol.


7)What about RMI/IIOP?



8)How Client  contact  the Bean?

a)The Client view is provided through two interface—the home interface and the remote interface.These interfaces

are provided by classes constructed by the container when a bean is deployed, based on information provided by the bean

9)why doesn’t the client interact with an EnterPrise JavaBean directly?

a)To the client. there appears to be direct interaction with an EnterPrise JavaBean through the home and remote interface.The Container interacts between client and component,Completely concealing both bean instance and its own actions from the clients.

10)What methods are developers required to implement the Enterprise JavaBeans  Architecture?

a)There are three categoriesof EJB methods.First, the bean implements methods to those in its home interface containeing methods,second abean implements business logic methods corresponding to those prvided by its remote interface.Finally a bean implements methods for interacting with the container.But these methods are not intended for client access, they are hidden by the container.

11)What are the basic types of Enterprise JavaBeans?

a)There are two types of Enterprise beans- session beans and entity beans represending different types of business logic abstactions.

Sesssion beans represent behaviors associated with client sessions,they are generally implemented to perform a sequence of tasks with in the context of a transaction.A Session bean is a logical extension of the client program, running process on the Clients behalf remotely on the server.

Entity beans reprsent specific  data or collection of data, such as a row

in a relatiopnal database. Entity bean methods provided operations for action on the data represented by the bean.An entity bean is persistent,it servives as long as its data remains in the database.


12)How does a Client find and connect to a specific enterprise bean?

a)A client accesses an  Enterprise JavaBean by looking up the class implemnting its home interface by name through JNDI.It then uses methods of the home interface to acquire access to an instance of the class implementing the remote interface.

13)How does a Client find and connect to a specific enterprise bean write the coding?

a)     Context ct=new InitialContext();

HaiHome home=(HaiHome)ct.lookup(“hai”);

HaiRemote remote=home.create();


then remote.Business methods..

14)What general services does a container  provide for an Enterprise JavaBean component?

a)     A Container provides Enterprise JavaBeans Components with services of several types First it provides services for lifecycle management and instance pooling/cache Pooling(SFSB), including creation,activation,passvation, and destroy.Secod it interacts methods in a bean to enforce transction and security constraints.It enforce policies and restrictions on bean instances, such as reentrance rules security polices , and some others.


15)What classes and interfaces does a session bean developer define?

a)The Session bean developer defines the home and remote interfce that represent the client views of the bean.Developers also create a class that implements both SessionBean and SessionSynchronization interfaces , as well as methods corresponding to those in the beans home and remote interfaces.

16)what are main interfaces in EJB required ?

a)javax.ejb pacakage contains mainly SessionBean,EntityBean Interfaces

17)What are abstract methods in SessionBean ?


public void setSessionContext(SessionContext ct)

public void ejbActivate()

public void ejbPassivate()

public void ejbRemove()


18)What are the abstract methods in EntityBean ?


public void setEntityContext(EntityContext ct)

public void unSetEntityContext()

public void ejbActivate()

public void ejbPassivate()

public void ejbRemove()

public void ejbLoad()

public void ejbStore()


19)What are types in SessionBeans?

a)     SessionBeans are mainly  two types Stateless and Stateful


20)what are distinction between a stateless and stateful?

a)     Stateless beans are beans that don’t maintain state across method  calls.They are generally intended to perform individual operations  automatically.Any instance of stateless bean can be used by any client at any timeStateful session beans maintain state within and between transactions   Each Stateful session bean is associated with a specific  client.Containers can automatically save and retrieve a beans state in the process of managing instance pools of stateful beans.

21)How do Stateful Session beans maintain consistency across transaction updates?

a)     Stateful session beans maintain data consistency by updating their fields each time a transaction is committed.To keep informed of changes in transation status, a stateful session bean implements the SessionSynchronization interface.The Container then calls methods of this interface as it initiates and completes transactions involving the bean.

22)Can’t stateful session beans persistent?

a)Session beans are not designed to be persistent, whether stateful or stateless.A stateful session bean instance typically can’t survive system failures and other destructive events.

23) Is it possible to maintain persistence temporarly in stateful sessiionbeans?

a)yes,it is possible using Handle

24)What Classes and interfaces does an entity bean developer provide?

a)     The Entity bean developer defines the home and remote interfaces that represent the cleint view of the bean.Developers also create a class that implements the EntityBean interface, as well as methods corresponding to those in the bean’s home and remote interface.

In addition to defininf create methods in the EJBHome interface,  the entity bean develpoers must also implement finder methods.

25)What are types in EntityBeans?

a)     EntityBeans are mainly  two types BeanManaged and ContainerMAnaged

26)what’s a finder method?

a)A finder method provides a way to access an  entity bean by its contents.

  Finder methods are designed to be  introspected and displayed by   devleopment and deployment tools.  The principal finder method that must be implement by all entity  bean is finderByPrimaryKey.In addition to this method the developer must also implement a   primaryKey class to provide each entity bean with a unique,serializable identity.


27)What is the difference between container-managed and beanmanaged persistence?

a)In bean managed persistenece, the bean is entirely responsible for storing and retriving its instance data.The EntityBean interface provides methods for the container to notify an instance when it needs to store or retrieve its data.

  In container managed persistence, entity bean data is automatically maintained by the container using a mechanism of its choosing.


28)How is an entity bean created?

a)An entity bean can be created in two ways: by direct action of the client in which a create method is called on the bean’s home interfce or some other action that adds data to the database that the bean type represents.

29)How does the clent get a reference to an existing entitybean?

a)A client can get a reference to an existiing entity bean in several ways:

   Receiving the bean as paramater in a method call

   Looking the bean uo through a finder method of hte home interface

30) How does a container manages access from multiple transactions on an entiy bean?

a)Container can acquire an exclusive lock on the instances’s sate in the database and serializable acess from multiple transaction to this instance.


31)How do u determine whether two entity beans are the same?

a)By invoking the EntityBen.isIdentical method.This method should be  implemented by the entitybean developer to determine when two reference are to the same object.


32)What are the transaction management benefits of the Enterprise JavaBeans architectur?

a)The Enterprise JavaBeans architecture provides automatic support for distributed transations in component based applications.Such distributed transactions can automatically update data in multiple databases.


33) Does Enterprise JavaBeans allow alternatives to container-manged transactions?

a)In addition to container-managed transactions, an Enterprise JavaBeans can participate in client-managed and bean-manged transactions.


34)What transaction attributes do Enterprise JavaBean containers support?

a)     A container supports the following value for the transaction attribute of an Enterprise JavaBean.









35)Explaine the Transaction attributed?

a)A container supports the following value for the transaction attribute of an Enterprise JavaBean.


The bean runs outside the context of a transaction.Existing transactions are suspended for the duration of method calls.


The bean demarks its own transactions boundaries  through the JTA UserTransation interface.


Method calls require a transaction context.If one exists ,it will be used;if none exists,one will be created


Method calls use the current  transaction context if one exists,but don’t create one if none exists.


Continers create new transactions before each method call on the bean, and commit transacions before returing.


Method calls require a transacion context.If none exists, an exception is thrown.

36)What levels of transaction isolation does the Enterprise JavaBeans specification support?

a)The Enterprise JavaBeans specification defines four supported levels of transaction isolation:








37)What is the relationship betwen Enterprise Java

Beans component architecture and XML technology?

a)EJB defines a standard for portable business logic and XML technology defines a standard for portable data.


38)How do you configure a session bean for bean-manged transactions?

a)     By set transaction-type in the xml file.


39)How do you configure a session bean for bean-manged transactions?

a)     By set transaction-attribute in the xml file or int he deployment descriptor.

41)Is is possible for an EJB client to marshall an object of class java.lang.Class to an EJB?

a)Technically yes, spec. compliant NO! “The enterprise bean must not attempt to query a class to


42)Is it possible to write two EJB’s that share the same Remote and Home interfaces, and have different bean classes?

if so, what are the advantages/disadvantages?

a)Sharing interfaces might be possible, but not trivial.

If you deploy with Sun Deployment Tool 1.2.1 you will get a

java.lang.ClassCastException: MyBean2EJB_EJBObjectImpl ...

43)Is it possible to specify multiple JNDI names when deploying an EJB?

a)No. To achieve this you have to deploy your EJB multiple times each specifying a different JNDI name. ..

44)What is the status of the UML-EJB Mapping Specification ?

a)It is currently > in the expert group stage, meaning that the CAll For > Experts (CAFE) was issued and replies were received. ...

45)Is it legal to have static initializer blocks in EJB?

a)Although technically it is legal,static initializer blocks are used to execute some piece of code before executing any constructor or method while instantiating ...

46)In CMP how can I define a finder method equivalent to a ‘SELECT * FROM BANKS ‘

Weblogic 5.1.0 - Define the following Finder syntax in your weblogic-ejb-jar.xml deployment descriptor.



<method-params>  </method-params>



47)Is it possible to access a CORBA object from a EJB?  a)I am using VisiBroker 4.0 for my CORBA objects and J2EE 1.2.1 for my EJB.  then These properties can be set on the commandline (using -Dorg. or using a file named Java:API:EJB, Java:API:CORBA Robert Castaneda ...


48)How can we interact with COM/DCOM components from a EJB component ?

a)A list of tools that integrate Java with the Microsoft platform is

available here. These tools can be used, as long as they stay within

the EJB specification requirements .


49)Is it possible to stop the execution of a method before completion

in a SessionBean?

a)Threads inside an EJB, One possible solution (that requires coding) would be to setting the transaction

50)  What is a major difference SessionBean and EntityBean?

a)     *SB’s state can be shared by only one client at a time. - persistence storage device is .ser file

*EB’s state can be shared by multiple clients, because as its persistence storage device is DB.

*Used to maintain client’s state persistent in the SB’s instance vars

51)   What is the TX operational  difference SessionBean and EntityBean?


a)     SB may or may not be used for TX operational operations,even they are used for TXs bean developer itself responsible to update the bean values into DB.

b)EBs are specially designed for TX operations where bean develope is only responsible for updating bean values,

where the bean values were updated into DB by executing one additional funtion called ejbStore().

52)Who execute TX operation funtion?

a)Container for every regular intervals and  interval time is the refreshMinutes property in JDBC Connection Pool Management.

53)  What is the TX operational  difference SessionBean and EntityBean?

a)     SB may or may not be used for TX operational operations,

even they are used for TXs bean developer itself responsible to update the bean values into DB.

b)EBs are specially designed for TX operations

where bean develope is only responsible for updating bean values,

where the bean values were updated into DB by executing one additional funtion called ejbStore().


54)which beans are TX which are not?


*SB are used for TX & Non Tx operations

*EBs are only used for TX operations.


55)what is the Entitybean flow control?


1)     Client obtains Home object reference.

2)    Client to obtains Remote reference uses h.findByPrimaryKey(Object o)

Note: In place of Object any Object sub class type of reference can be passed as an argument.

3)    The request of client received by HomeImpl class findByPrimaryKey(o)


b)     It then checks the number of instance created in the container with the max beans in cache value,

if instances are less then container creates one new EJB instance

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.