Hi all,
"Narinder Singh" wrote:
> Hi
> I need to call methods of a
stateless (???)
> Session Bean from another bean.
> ...
Might be, you don't need the called Session Bean at all.
Not every class on the server side is some sort of bean,
in fact most of them are normal classes providing services
of all sorts to beans. Consider some calculation helper class,
that does not qualify for a bean:
- will not be used from remote clients
- does not access resources managed by the EJB server/container
- has no transactional state
then you should implement a simple class. For calculation
services the singleton pattern comes into mind, thus avoiding
frequent recreation of objects just to call one method on them.
Even when remote clients should be able to use that calculation
services you still could implement a simple class doing the work
accompanied by a simple 'facade type' stateless session bean
providing the remote access and delegating the calls to the
simple class. So only remote clients need to access the
services 'the expensive' way, all classes in the same VM
call the simple service class directly.
Bye
Georg
___ ___
| + | |__ Georg Rehfeld Woltmanstr. 12 20097 Hamburg
|_|_\ |___ [EMAIL PROTECTED] +49 (40) 23 53 27 10
----- Original Message -----
From: "Narinder Singh" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 13, 2001 7:10 AM
Subject: [jBoss-User] Calling methods of a Bean from another Session Bean.
> Hi
> I need to call methods of a Session Bean from another bean.
> I was previously using the following method for this.
> Context jndiContext = new InitialContext();
> InterestHome interestHome = (InterestHome
> )jndiContext.lookup("InterestBean");
> Interest interest = ((InterestHome)interestHome).create();
> interest.calculateInterest();
> I have found that this can be done in another way also.
> InterestBean interest = new InterestBean();
> interest.calculateInterest();
> I have tested both implementations on jboss.
> The second method is much faster than the first one. but I doubt whether
it
> is ok to use the second method.
> Can anyone tell me if I can use the second method without any problems
(such
> as transaction handling),
> or what are the problems in using the second method.
> Regards
> Narinder.
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]