When you use the J2EE reference implementation, you won't be able to
deploy multiple EJB's which use the same home and remote interfaces.
Instead, use multiple applications with (of course) different
JNDI-names.
This way, from a client with the below code, you can call all sort of
ejb's that implement the remote interface:
public static void main(java.lang.String[] args)
{
String jndi = "ejb2"; // The JNDI name
String message = "hi";
try
{
Properties env = new Properties();
Context context = new InitialContext();
Object obj = context.lookup(jndi);
--> GenericHome home = (GenericHome)PortableRemoteObject.narrow(obj,
GenericHome.class);
--> GenericRemote bean = home.create();
--> bean.send(message);
}
catch (Exception e)
{}
}//end of main()
GenericRemote then looks like this:
--start of file
public interface GenericRemote extends javax.ejb.EJBObject
{
void send(String message) throws java.rmi.RemoteException;
}
--end of file
It works!
The client can then change the JNDI-name from ejb1 to ebj2 to ejbn, all
of which represent different implementations of the method send (or
convert....)
greetz,
Bas
btw: if you want sample code, mail me....
-----Oorspronkelijk bericht-----
Van: Vaibhav Bhomkar [mailto:[EMAIL PROTECTED]]
Verzonden: dinsdag 4 december 2001 13:00
Aan: [EMAIL PROTECTED]
Onderwerp: Re: all my beans implementing the same interface
Should be possible if all the session beans have remote methods
with same signature.
Only during deployment u need to have different JNDI name for
each session bean
so that, its EJBObjects are not identical.
I don't think EJB complier will complain for common Home and
Remote interface for different Session Bean Class.
Any different opinions on this are welcomed.
-----Original Message-----
From: Marco Mistroni [SMTP:[EMAIL PROTECTED]]
Sent: Tuesday, December 04, 2001 4:37 PM
To: [EMAIL PROTECTED]
Subject: all my beans implementing the same interface
hi all,
i have a set of EJBs that represent converters (between
lira/euro,
lira/dollar, lira/yen etc..)
so each EJB is implementing, other than the SessionBean
interface, the
Converter interface.
Now, i am getting little lost.
shall i define one remote&home interface for each bean,
or shall i keep the
same home/remote for all th beans??
the ejb compiler 'says' the first option.
i am asking u: is htere a way to create just one pair of
home/remote
interface 4 all the session that implements the
converter interface???
hope that u can help me
thanx in advance and regards
marco
========================================================================
===
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body
of the message "signoff EJB-INTEREST". For general help,
send email to
[EMAIL PROTECTED] and include in the body of the
message "help".
Disclaimer http://www.infosupport.com
***********************************************************************
This E-Mail Message is intended exclusively for the addressee. If the
E-Mail was sent to you in error, please notify the sender immediately
by replying to this E-mail. We would then request you to destroy the
E-Mail and neither to use nor disclose the contents in any manner to
third parties, as the message could contain confidential information
which may be protected by the professional secrecy act.
This footnote also confirms that this E-mail message has been swept for
computer viruses.
***********************************************************************
==========================================================================To
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".