2 Replies Latest reply on Mar 10, 2004 11:37 AM by olegsafonov

    Access to bean from another bean

    olegsafonov

      Hello.
      I have a small example

      //client code
      ...
      mystatefulbean = statefulhome.create();
      mystatelessbean = statelesshome.create();

      mystatefulbean.setFoo("Foo");

      mystatelessbean.foo();
      ...
      how I can get access in method foo() to instance mystatefulbean on server? i.e. how store reference or handle on my stateful bean on server side, so as to I can get to this handle from method of my stateless bean. Practically create session mechanism like http session.

      Thanks for any help.

        • 1. Re: Access to bean from another bean

          Stateless beans are not allowed to have state from the client, hence the name.
          You will have to pass it as a parameter.

          Regards,
          Adrian

          • 2. Re: Access to bean from another bean
            olegsafonov

            Thanks Adrian,
            But if I have hundreds of objects with many methods, in each I must pass reference on my stateful bean, but this is not good. We do not pass transaction context to each method, the server has mechanism for it (by the way, in IIOP protocol implementation transaction and security contexts are not passed, we have implemented it). Of course I can create interceptor for my client session's pass from client to server implicitly. My question was if there are any ways to store client session in server. Haven't it been needed by anyone so far? :-)

            Thanks again.