About Me

ఏదైనా సబ్జెక్టు లో కి డీప్ గా దిగకుంటే నాకు నిద్ర పట్టదు

Sunday, September 30, 2007

Learn_easy_EJB

This Section of my blog is meant for those who either worked with EJBs or have a little idea about Enterprise Java Beans.
Novice Users need something more to start with rather than diving to this section..
------------------------------>
Let us start.. To simplify the understanding i have used my own terminology to explain the concepts. Please Note that these terms are not part of specifications from Sun..
------------------------------->

For the simplicity of explanation of EJBs let us categorize beans as

Dedicated EJBean and Random EJBean..

B.1.Dedicated EJBean is one which gives services to a specific client,It means that the dedicated EJBean must be a specific one to the client..,

B.1.1.How are dedicated beans created ?

Dedicated are required only for stateful session and entity beans

So They can be taken from pool and initialized or new bean may be created & initialized on demand or something else is passivated and reinitialized to become dedicated to the present client

Examples:

Entity :

a) beans can be taken from pool and initialized (entity beans) to make them dedicated

Stateful :

A)if it’s a new request for the first time and If the limit for the number of stateful beans is not reached yet new stateful bean is instantiated and initialized with client session data

b) not a new request but the dedicated object for that client is not found (might have been passivated) ,one of the in-memory dedicated beans(for diff clients) is passivated and its reused to initialize a new dedicated bean ( stateful session beans)

B.2. Random(non dedicated) EJBean is one which is picked up on demand from a BEAN POOL to service a client request , and sent back to pool againimp .. that means there are certain type of requests for which Dedicate EJBean is not necessary …

#############################################################

Section C :

Which Beans are necessary in different conditions??

a) Stateless Session Beans ???

Methods of stateless session beans don’t depend on client state data Nor need client data to provide service..

So Any Random EJBean(Stateless Session Beans) can provide a service

Thus solution for this ?

Pick up a random bean from POOL , execute method(providng service)

The random bean goes back to pool .(may be picked up to service another client request)

b) Stateful Session Beans ???

There Is no concept of pooling at all.. (virtual Pooling)

No question of Random picking..

Each service method must be executed on a dedicated stateful bean

Check section A.

Do they require any random beans? No

c) Entity Beans ???

Pooling concept is present ..

Because there are certain methods which can be executed on non-dedicated beans.

Eg:

-- findByPrimaryKey(<..>) Is called on a homeobject.

--Container picks a random(non dedicated) bean from pool , executes

--ejbFindByPrimaryKey(<..>) , the method gives back PK class and

--The random bean goes back to pool

--container based on PK , creates a new dedicated bean(picks a random one from pool ), creates EJBObject ,gives back to client

Dedicate beans are needed ? yes

--To service business methods on data like getting setting manipulating etc.,

#######################################################

Section A :

For simplicity let us categorize methods as create,find and service methods

A.1.Create method à for initializing a bean with either a specific client session data/specific business data or none of them

Note : create methods don’t create or instantiate bean instances, they are for initializing an already instantiated bean

ü Whenever a parameterized create is called , then that bean will become dedicated..

ü ejbCreate() doesn’t make a bean dedicated as it has no parameters

ü ejbCreate(<..>) makes the bean dedicated

A.2,Service Method : these methods give services like setting/getting or other business process logic

Note : service methods of stateless session Beans are not specific to any client ,so they don’t depend on client data/session data

A.3.Find methods :

They are not for initializing with the help of parameters ,

They are just for finding ..

You can consider these methods are like service methods of stateless session beans .

After Find methods bean is not dedicated it can be sent back to pool

No comments: