aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Invoking remove() methods from Home & Remote interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Invoking remove() methods from Home & Remote interfaces" Watch "Invoking remove() methods from Home & Remote interfaces" New topic
Author

Invoking remove() methods from Home & Remote interfaces

Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,

There are total 4 remove methods.

1. Home.remove(Handle h)
2. Home.remove(Object PK)

3. EJBObject.remove()

4. Bean.ejbRemove()

As the client is exposed to Home and Component interface, he can call either of the first three remove methods.
I am not clear on the difference between the remove() methods given in the Home and Component interface.
What is actually removed when we call the remove method from the home and component interface.

These are my understanding,

1.When Home.remove() mtds are called, it is not that home is removed.
It is to tell the container that a particular bean is done with the home.
To identify a particular bean we have to pass either Handle(session/entity bean) or PK objects (entity bean).

2. When EJBObject.remove() mtd is called then it is to tell the container to remove the bean references.

We have the remove methods in Home and the Component bcoz the LocalClients doesn't have any handles,
so for them EJBObject.remove() is useful.

Now my question is,

What the container will do with the Home.remove() and EJBObject.remove().
Is the bean destroyed or the bean reference is destroyed.

When will bel the ejbRemove() from the bean is called?
As ejbRemvoe() is a container callback method, will it be called when ever the client
call the Home.remove() and EJBObject.remove() methods or any timeout occured ?

If ejbRemove() is called will bean destroyed or the bean references are destroyed.

Please clarify me on these points.


Thanks & Regards,
Parvathi.
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
bean.ejbRemove() is associated with remove calls from the client except in the case of ejbRemove() calls for a stateless bean(where the bean removal is decided by the container depending upon availabilty of resources and other restrictions which the server may put(like some server may say number of beans in bean pool can be <this many> per type etc.)

home.remove() will not be removing the home(even if there are no beans the home need to be there to serve).

home.remove(handle) or home.remove(primary key) is with a argument because with home there may be n number of beans.Which one will have to be removed?
you need to specify to the home by mentioning by primary key(entity beans)
or handle (for stateful and entity).

these home.remove calls ends up in the call of the callback functions ejbRemove() necesarily.(the client can't call directly ejbRemove() form client code).EJBObject is the guard guarding the bean right.


With Regards,<br /> Rajan<br />"Java Rocks"
Parvathi G
Greenhorn

Joined: Dec 17, 2005
Posts: 28
Hi,

So, the remove method in both home and remote interfaces calls the bean.ejbRemove() method to destroy the reference of the bean.
Then which remove() mtd we have to choose, home.remove() or remote.remove()()( apart of statless bean and local clients).

Thanks & Regards,
Parvathi.
Rajan Murugan
Ranch Hand

Joined: Jun 24, 2006
Posts: 182
Originally posted by Parvathi G:
Hi,

So, the remove method in both home and remote interfaces calls the bean.ejbRemove() method to destroy the reference of the bean.
Then which remove() mtd we have to choose, home.remove() or remote.remove()()( apart of statless bean and local clients).

Thanks & Regards,
Parvathi.


both in stateful and entity beans what happens at the back is different things.ejbRemove() itself does not destroy anything.we need to implement code to do the needful like removing/closing references/connections etc.

as for as which remove() depends on what you have.if you just have the remote object reference(EJBobject) then call EJBObject.remove() else if you have home and the handle/primarykey then use the home to remove.

in fact you can use either one to remove the same bean.

Remember the entity remove and stateful remove results in different things happening at the back.
[ November 03, 2006: Message edited by: Rajan Murugan ]
 
Consider Paul's rocket mass heater.
 
subject: Invoking remove() methods from Home & Remote interfaces