-
1. Re: Accessing stateful session beans from stateless session
keyurva Mar 31, 2005 1:20 PM (in response to winterer)Casting a local interface to a remote one might not work... May be you can define your local interface like this:
@Local public interface StatefulResultLocal { StatefulResultRemote getRemote(); .... }
and in the EJB return it as such:@Stateful public class StatefulResultBean implements StatefulResultLocal, StatefulResultRemote { public StatefulResultRemote getRemote() { return (StatefulResultRemote)ctx.getEJBObject(); //@NOTE } ... }
@NOTE: But as per my other post (http://jboss.com/index.html?module=bb&op=viewtopic&t=62006) this method does not work for EJB 3.0... Is there another way to be able to do this? -
2. Re: Accessing stateful session beans from stateless session
winterer Apr 1, 2005 5:30 AM (in response to winterer)Thanks for your reply! I think this is the recommended way to do what I want - if it worked...
I think there are two reasons why your approach does not work with EJB 3.0:
This feature is not implemented yet but will be in further previews.
This feature is not supported any more.
But I don't think that EJB 3.0 does not support this feature any more. Maybe it is now possible to do a simple cast (as I did in my posting) - but as long as the spec doesn't say anything about this, we cannot be sure (even if it works with JBoss).
I'll do some tests... -
3. Re: Accessing stateful session beans from stateless session
winterer Jul 3, 2007 8:07 AM (in response to winterer)(At least) since JBoss 4.2.0.GA, it is possible to query and return the remote interface of an existing (stateful) session bean:
@Stateful @Remote( { MyRemoteInterface.class }) public class MyStatefulSessionBean implements MyRemoteInterface, MyLocalInterface { //... any remote/local methods ... // method defined in MyLocalInterface: public MyRemoteInterface getRemoteInterface() { Object obj = ctx.getBusinessObject(MyRemoteInterface.class); return (MyRemoteInterface)obj; } }