[jboss-user] [EJB 3.0] - Re: How to look up one of the many interfaces that a bean im

ALRubinger do-not-reply at jboss.com
Thu Feb 22 17:40:25 EST 2007


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020840#4020840

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020840



More information about the jboss-user mailing list