Hi

Yes we have done this no problem.

We

1) Define a "GenericRemote", and a "GenericHome"
2) Define two (or more implementations) "Impl1EJB" and "Impl2EJB" that  have
methods to realize "GenericRemote" and "GenericHome"
3) In the deployment descriptor define entries such as

<session>
    <description>Implementation 1</description>
    <ejb-name>Impl1</ejb-name>
    <home>...GenericHome<./home>
    <remote>...GenericRemote</remote>
    <ejb-class>...Impl1EJB</ejb-class>
    ....
</session>
<session>
    <description>Implementation 2</description>
    <ejb-name>Impl2</ejb-name>
    <home>...GenericHome<./home>
    <remote>...GenericRemote</remote>
    <ejb-class>...Impl2EJB</ejb-class>
    ....
</session>

Then use code such as the following

    String implName = "Impl1" // or "Impl2 if that is what you want
    InitialContext ic - new InitialContext();
    GenericHome gh = (GenericHome)PortableRemoteObject.narrow(
        ic.lookup(implName), GenericHome.class);
    GenericRemote gr = gh.create() // for example

Now you have remote reference gr to either Impl1EJB or Impl2EJB depending
on the JNDI name of the EJB.

Cheers

Lawrence


> ----------
> From:         Bas Eefting[SMTP:[EMAIL PROTECTED]]
> Reply To:     Bas Eefting
> Sent:         09 May 2001 14:13
> To:   [EMAIL PROTECTED]
> Subject:      Generic Approach of EJB's
>
> Hi,
>
> we want to talk to EJB's in a generic way. This means we have a set of
> EJB's
> (the set may be expanded), all with the same functions, only difference is
> their implementation.
> Take a "public void send(String message)" method for example.
>
> Is it possible to look up these different beans with only a difference in
> the JNDI name?
> I tried but could not succeed, but that's not surprising me being fairly
> new
> to EJB's.
>
> In the code we see this:
>                 Context context = new InitialContext(env);
>                 Object obj = context.lookup(jndi);
>
>                         //specific code
>                 Prot_AHome home =
> (Prot_AHome)PortableRemoteObject.narrow(obj, Prot_AHome.class);
>                 Prot_A bean = home.create();
>                 bean.send(message);
>
> With Prot_A being the class of one of the EJB's. We want to add Prot_B,
> Prot_B,etc. Is there any way we can use an interface for this? So the code
> would be:
>                 ProtHome home = (ProtHome)PortableRemoteObject.narrow(obj,
> ProtHome.class);
>                 Prot bean = home.create();
>                 bean.send(message);
> and the only difference would be in the JNDI name. Someone said it could
> not
> be done 'cause of a not really Object Oriented Design of EJB's home
> interface or something.
> Is this true? And if so, why was this design decision taken?
>
> Any help would be welcome,
> regards
> Bas Eefting
>
>
>
> ***********************************************************************
> 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".
>


Visit us at http://www.clearstream.com

IMPORTANT MESSAGE

Internet communications are not secure and therefore Clearstream International does not
accept legal responsibility for the contents of this message.

The information contained in this e-mail is confidential and may be legally 
privileged. It is
intended solely for the addressee. If you are not the intended recipient, any 
disclosure,
copying, distribution or any action taken or omitted to be taken in reliance on it, is
prohibited and may be unlawful. Any views expressed in this e-mail are those of the
individual sender, except where the sender specifically states them to be the views of
Clearstream International or of any of its affiliates or subsidiaries.

END OF DISCLAIMER

===========================================================================
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".

Reply via email to