• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Bean Stateless  RSS feed

 
Isaias C. Barroso
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I've read that Session Bean Stateless must have only create/ejbCreate without parameters.
How to create a Session Bean Stateless passing parameters?
Thanks
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use env-entry elements in your deployment descriptor to pass this kind of data.
 
Isaias C. Barroso
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
But if the parameter that need to pass is dinamic?
Example :
home.create("A String");
home.create(10);
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But if the parameter that need to pass is dinamic?

Then you're not talking about a stateless session bean anymore...
 
Isaias C. Barroso
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I understand.
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:

Then you're not talking about a stateless session bean anymore...

Newbie should not automatically abandon stateless just because wants to pass params to the SLSB. Two things to consider...
1. The SLSB can and should get "parameters" upon initialization from sources such as JNDI, and possibly open database connections and so forth.
These should be stored in the SLSB's private variables for subsequent stateless calls to methods of the SLSB.
2. Any of the stateless session bean's method should simply have parameters for everything they need (so what if the bean can't perform the
negligible efficiency of saving a param just to avoid passing it in repeatedly). That's a matter of judgment by the bean developer.
That's my humble opinion.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. The SLSB can and should get "parameters" upon initialization from sources such as JNDI, and possibly open database connections and so forth.
These should be stored in the SLSB's private variables for subsequent stateless calls to methods of the SLSB.
Yes, and when considering this, one should consider resource utilisation. For example, in most cases I wouldn't give each SLSB a JDBC connection but a reference to the DataSource to get them from.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!