Hi,
I am trying to understand in what way XML is helping you achieve
polymorphism?
You can achieve the exact same result by having a method on a
BeanFactory that uses reflection and creates an appropriate type of
bean. Something along the lines:
createBean(String homeInterface, String acct_id)
Harish Prabandham
J2EE Reference Implementation
Java Software Division
Sun Microsystems Inc.
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED]]On Behalf Of Le, Thong C, NCIO
> Sent: Tuesday, September 07, 1999 10:07 AM
> To: [EMAIL PROTECTED]
> Subject: Dynamic lookup
>
>
> Hello members,
>
> I hope you can provide me a solution to my question. We are using XML to
> support client conversation with EJB (via IIOP). The client would pass an
> XML string containing the class name and method invocation parameters. A
> singleton Session Bean (Factory bean) will parse the XML string
> and extract
> the class name and invocation parameters and call the appropriate
> EJBean(the
> EJBean does whatever and returns the result back to the Factory Bean as an
> XML string which then passes to the client). There are many
> EJBeans register
> in the same container. My question is how to invoke the appropriate EJBean
> dynamically. An example will explain what I mean:
>
> Client will pass the following XML to the Factory Bean:
>
> <QUERY>
> <APPHOME>Jndi_CheckingAcct</APPHOME>
> <USERINPUT>
> <account_id>1002</account_id>
> </USERINPUT>
> </QUERY>
>
> The Factory bean will parse the XML string to get the Home interface and
> would like to do the following (somewhat achieving polymorphism):
>
> String home_str = Parser().getHomeStr;
> // home_str = "Jndi_CheckingAcct"
> BaseAccount acctHome = jndiContext.lookup(home_str);
>
> String acct_id = Parser().getAcctId;
> // invoke the appropriate bean, in this case the
> // CheckingAcct bean
> acctHome.create(acct_id);
>
> We don't want to have to do this:
>
> if (home_str == "Jndi_CheckingAcct") {
> CheckingAcct acctHome =
> (CheckingAcct)jndiContext.lookup(home_str);
> acctHome.create(acct_id);
> }
> if (home_str == "Jndi_SavingAcct") {
> SavingAcct acctHome =
> (SavingAcct)jndiContext.lookup(home_str);
> acctHome.create(acct_id);
> }
> if (...) // you get the idea
>
> Using XML between client/server shields us from interface changes in the
> future. So later if we decide to add dirrerent account beans
> later we don't
> have to change the interface. The client can't call the
> CheckingAcctHome to
> get the reference directly because everthing is funnel through the Factory
> bean (thus, using XML).
>
> I know the CORBA services provide the interface repository where
> you can do
> dynamic lookup and construction of a server object and its methods. I'm
> looking for something similar in EJB. How do I achieve this?
>
> Please comment.
>
> Thanks,
>
> Thong Le
>
> ==================================================================
> =========
> 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".
>
===========================================================================
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".