Can you copy/paste the WebLogic complaint into an email back to this 
list?  I'm curious; I don't remember that in the spec and even if it 
was, would argue why they would allow free-form text in the ejb-jar.xml 
for <home> and <remote> if we couldn't re-use valid interfaces in them. 
  What exact version (and service pack) of WebLogic?  I'd like to give 
it a go...

--

[EMAIL PROTECTED] wrote:

> That's an interesting topic, if I might butt in :)  The technique you
> mentioned below works great in jBoss, but when I tried to port the same code
> to another server running Darth WebLogic, it complained about some obscure
> j2ee specification requiring the home and remote interfaces being *unique*
> or having the same name as the EJB.
> 
> The technique you use below is very powerful, as it allows a layer of
> abstraction.  My question then is the technique below legal?
> 
> Wes
> 
> -----Original Message-----
> From: David Ward [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 02, 2001 10:18 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [JBoss-user] Casting home interface to correct bean type
> 
> 
> Chris,
> 
> You shouldn't have to cast your home interfaces; in fact, you can share 
> the same remote and home interface for all your "Form" EJB 
> implementations.  Try this, for example:
> 
> // interfaces/beans
> 
> public interface Form extends EJBObject;
> public interface FormHome extends EJBHome;
> public class FooForm implements SessionBean;
> public class BarForm implements SessionBean;
> 
> // inside servlet (bad code for ease of example)...
> 
> public void service(HttpRequest req, HttpResponse res) {
>       String formName = req.getParameter("formName");
>       try {
>               InitialContext ctx = new InitialContext();
>               Object ref;
>               if ( formName.equals("foo") )
>                       ref = ctx.lookup("java:comp/env/ejb/FooForm");
>               else if ( formName.equals("bar") )
>                       ref = ctx.lookup("java:comp/env/ejb/BarForm");
>               else
>                       // do something...
>               FormHome home = (FormHome)PortableRemoteObject.narrow(ref,
> FormHome.class);
>               Form form = home.create();
>               // now use the generic form interface...
>       } catch (Exception e) {
>               throw new ServletException(e);
>       }
> }
> 
> Basically, your deployment descriptor will specifcy the same <remote> 
> and <home> interfaces for both FooForm and BarForm, but will obviously 
> have different <ejb-class>'s bound to different JNDI names.  Your 
> implementations of FooForm and BarForm can be radically different, but 
> since you said they will have the same method signatures, the client 
> code can just use the "Form" interface.
> 
> Hope this helps,
> David
> 
> --
> 
> Chris Adams wrote:
> 
> 
>>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
>>
>>
> 
> 


-- 

-----------------------------------------------------------------------
David Ward                                        [EMAIL PROTECTED]
Senior Software Engineer                          http://www.dotech.com
Distributed Object Technologies, Inc.             716-381-8320 (phone)
500 Linden Oaks, Rochester, NY 14625              716-381-0598 (fax)


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

Reply via email to