-
1. Re: How to look up one of the many interfaces that a bean im
alrubinger Feb 22, 2007 5:40 PM (in response to forumer)The value stored in JNDI is an object - a proxy object that implements the interfaces you define.
So...no, you can't pull out an object that only implements one of the interfaces you've defined.
However, you should be casting the proxy from JNDI into the interface you want...Interface1 myBean = (Interface1)PortableRemoteObject.narrow( new InitialContext(props).lookup("address"), Interface1.class);
...and that way, you'll have compile-time constraints to only invoke operations defined by Interface1.
(Code above only for remote lookup; local can skip the "PortableRemoteObject.narrow()) step)
S,
ALR -
2. Re: How to look up one of the many interfaces that a bean im
forumer Feb 22, 2007 6:35 PM (in response to forumer)This will do what I want - only easier!
Thank you! -
3. Re: How to look up one of the many interfaces that a bean im
alrubinger Feb 22, 2007 7:53 PM (in response to forumer)Word.
S,
ALR -
4. Re: How to look up one of the many interfaces that a bean im
forumer Feb 24, 2007 7:42 AM (in response to forumer)If I may revisit this again, this is what I am doing:
Interface MyRemoteIF extends Interface1, Interface2 @Remote(MyRemoteIF.class) @RemoteBinding(JndiBinding="MyCompany/MySessionBean/remote") public Class MySessionBean implements MyRemoteIF
At the client:Interface1 myInterface = (Interface1)context.lookup("MyCompany/MySessionBean/remote"));
The problem is that in two of the three cases, I am getting ClassNotFoundException for MyRemoteIF.class! Classes and interfaces are different in each of the three cases. I am trying to locate the cause of this inconsistency.
Does this arrangement require MyRemoteIF.class to be present at the client? I am hoping that only Interface1 is required.
Thanks -
5. Re: How to look up one of the many interfaces that a bean im
alrubinger Feb 24, 2007 6:52 PM (in response to forumer)Right...so the proxy object is going to be created by JBoss and will implement all the interfaces you designate.
When your client does a lookup for this object, it's going to get loaded by the classloader, along with all dependencies it has.
So if the definition in the classfile is something like (I'm making up some JBoss classnames for simplicity's sake) "Proxy$1 extends JbossRemoteProxy implements MyRemoteIF", then your client must have MyRemoteIF on its classpath (even though you just want the functionality defined in the superclass Interface1 at compile time, the actual object you're working with at runtime is what's most important here).
So, I propose you do something like the following:public abstract class MyClassBase { ... all your business logic defined by Interface1 and Interface2... }
@Remote public interface Interface1{}
@Remote public interface Interface2{}
@Stateless @RemoteBinding(JndiBinding="MyCompany/MySessionBean1/remote") public class MyClass1 extends MyClassBase implements Interface1{}
@Stateless @RemoteBinding(JndiBinding="MyCompany/MySessionBean2/remote") public class MyClass2 extends MyClassBase implements Interface2{}
..this way, you'll have centralized your logic into one base class, and deployed the Stateless Beans separately such that one need not have any knowledge of the other.
S,
ALR