>I've tried creating standard interfaces, which all form beans could
inheret
>from, but came up with all sort of problems.

What are your "all sorts of problems"? This seems like a standard way to do
it. Each of the bean's home and remote interfaces would inherit from some
standard base interface (let's call that IBaseHome and IBaseRemote). Then
your servlet code would have something like:

String homeInterfaceName = properties.getProperty(thisFormNameHome);
//assume this get's the name of your home interface
String remoteInterfaceName = properties.getProperty(thisFormNameRemote);
//assume this get's the name of you remote interface
String jndiLocation = properties.getProperty(thisFormNameJNDILocation);
//get's the jndi location of the home interface

Context jndiCtx = new InitialContext();
Object ref = jndiCtx.lookup(jndiLocation);
IBaseHome home = (IBaseHome) PortableRemoteObject.narrow(ref,
Class.forName(homeInterfaceName));
IBaseRemote remote = home.create();

//you could then call all of the standard IBaseRemote methods - if you wish
to call any ones that are
//specific to the sub-interface, you have to use reflection.

Alex Devine
Trilogy Development
office: 512-532-5186  |  cell: 512-736-6612  |  ICQ: 62256371



|--------+-------------------------------------->
|        |          Chris Adams                 |
|        |          <[EMAIL PROTECTED]>      |
|        |          Sent by:                    |
|        |          [EMAIL PROTECTED]|
|        |          eforge.net                  |
|        |                                      |
|        |                                      |
|        |          07/02/01 08:17 AM           |
|        |          Please respond to jboss-user|
|        |                                      |
|--------+-------------------------------------->
  
>-----------------------------------------------------------------------------------------------------------|
  |                                                                                    
                       |
  |       To:     [EMAIL PROTECTED]                                     
                       |
  |       cc:                                                                          
                       |
  |       Subject:     [JBoss-user] Casting home interface to correct bean type        
                       |
  
>-----------------------------------------------------------------------------------------------------------|




Hi,

Need some help with remote casting objects when using ejb's

I'm going to have a set of bean which each represent a form. Each for has
the same set of methods, but they need to be independent ejb's because each
has different details.

The client is a servlet, which will receive a parameter
the type of form to return. This then needs to get the home interface of
the bean. I am going to have a properties file which pairs the form name to
it's home interface class name.

My problem is that the lookup method just returns an object, so how can I
cast this object to the correct home interface, as the type of form is not
know until the servlet is called.

I've tried creating standard interfaces, which all form beans could inheret
from, but came up with all sort of problems.

I could use relfection to call the methods, but would prefer not to. Any
ideas.

Many Thanks

Chris Adams




Chris Adams
==============================
Regus Computer Services Ltd
Direct Line: 01279 712010
ESN: 6-741-2010
Switchboard ESN: 6-741-2000
Tel: +44 (0)1279 507988
Fax: +44 (0)1279 507783
E-mail: [EMAIL PROTECTED]
<http://47.137.128.160/regus>
<http://www.regus-cs.co.uk/>
==============================




Regus Computer Services Ltd.
The information transmitted is intended solely for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any retention, review, retransmission, dissemination, other use,
or taking any action relying on this information by persons or entities,
other than the intended recipient is prohibited. If you received this in
error, please contact the sender and delete the material from any computer.
We will not be liable for direct, indirect or consequential damages arising
from the alteration of the contents of this e-mail by a third party or as a
result of any virus.

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user





_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to