Jerry Simone [
http://community.jboss.org/people/jlsimone] replied to the discussion
"How to initialize the State of an EJB3 Stateful Bean"
To view the discussion, visit:
http://community.jboss.org/message/533579#533579
--------------------------------------------------------------
Wow. I just discovered something. Not only does Carlo's example code initialize the
state of the stateful EJB, I modified it to solve another problem that I was having. Here
is my modified example below.
interface MyLocal { MyRemote create(String state);}
interface MyRemote{ void doWork(); class MyBean implement MyRemote, MyLocal { MyRemote
create(String state) { this.state = state; return
ctx.getBusinessObject(MyRemote.class); } void doWork(){ // do something }}
What I've done here is I have given the local interface the responsibility of creating
the bean. This allows me to create one EJB from another EJB in the same JVM, passing the
state to the second EJB by reference (instead of by value) via the local interface. This
probem is described in a question I posted in another discussion thread. The link is
http://community.jboss.org/thread/147136.
The link, above, describes a problem where I am using EJBx to create EJBy within the same
JVM. After I create EJBy, I pass the remote interface for EJBy to the remote client. My
problem was that I was using the remote interface (pass by value) to initailize the state
of EJBy. But Carlo's modified example allows me to initialize EJBy using the local
interface (pass by reference) and then have the create method return the remote interface
that is needed by the remote client.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/533579#533579]
Start a new discussion in EJB 3.0 at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]