• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Parameters in create method

 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Which type of EJB requires an ejbCreate() method for parameters to be passed?
CMP entity bean
BMP entity bean
Stateful session bean
Stateless session bean
Ramdhan YK
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramdhan Kotamaraja:
Hi,
Which type of EJB requires an ejbCreate() method for parameters to be passed?
CMP entity bean
BMP entity bean
Stateful session bean
Stateless session bean
Ramdhan YK



My choice would be "Stateful Session Bean". Why? "Stateless" does not take any parameter so it is out. Now, Entity beans are not required to have ejbCreate at all so I think they too should
go. This leaves with Stateful Session bean in which ejbCreate can take parameters.
 
Ram Dhan Yadav K
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roshan,
Stateful session bean does not require you to pass parameters, you can have an create method without any parameters in a stateful session bean. So i am just wondering whether it would be CMP. Ya, i agree that it does not need a create method atall. But if atall one is provided, i guess it requires parameters to be passed. AM i making sense or am i missing something.
thanks,
Ramdhan YK
 
Roshan Lal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you make perfect sense. I understand that you dont have to
pass parameters to ejbCreate and ejbCreate create without parameteer is perfectly fine.
I am confused and the question is not clear,
I think the question may not be rightly worded.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

Will the container create a instance of Stateful session bean each time the create method is onvoked on its home interface?

My home interface has a create method declaration as follows..
AuditClaimManager create(java.lang.Integer userID) throws javax.ejb.CreateException, java.rmi.RemoteException, AuditClaimLockException;

My bean has the ejbCreate() has follows..
public void ejbCreate(Integer userID){
this.userID = userID;
}

How many instance will be created if I invoke the creat() method on the home from the client with the same integer value... will the container return me the session bean which is already created or will it create a new instance even thought I passed in the same integer value in the create method..

Thanks...
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Raj,

A statful session bean manages data for a user. A stateful session bean is associated with a user. So in case a AuditClaimManager is created by the home with the same integer, there should be different at least for different clients.

But anyway, that depends on the implmentation of the container.

So that means, Sun, IBM, ... can implement the create method as they want. As long as they take care that different clients have their own client data stored.

That is my opinion. How I understand a stateful session bean.

Lucy

Lucy
 
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Yes container will give you a new instance of the SFSB bean each time the create method is invoked on its home interface.

2. The number of instances created will depend upon the number of times you call create(). This is true even if you pass same integer value to the create() method.

Based on the implementation, the EJB container may not create a physical new instance every time it hands out a new instance of SFSB to the client. It can very well reuse a previously timed out (and passivated) SFSB instance.

But as far as client of SFSB is concerned, it will always receive a fresh instance.

If the client wants to reuse the instance for future invocations that it needs to store the handle to the SFSB in some place.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic