How to access OUT/INOUT parameters of Stateless Session Bean

Discussions

EJB programming & troubleshooting: How to access OUT/INOUT parameters of Stateless Session Bean

  1. Hello,
    I am having simple 'java client' to access my 'stateless session bean' deployed in weblogic 6.1. I want pass a parameter to a method of bean, and want modified value back in client in 'same' parameter.
    How do I do this?

    The summary is: Is there any support for OUT/INOUT parameters in stateless session beans?


    Thanks in advance for any clue...
    -sanjay
  2. Hello,

    > I am having simple 'java client' to access my 'stateless session bean' deployed in weblogic 6.1. I want pass a parameter to a method of bean, and want modified value back in client in 'same' parameter.
    > How do I do this?
    >
    > The summary is: Is there any support for OUT/INOUT parameters in stateless session beans?
    >
    >
    > Thanks in advance for any clue...
    > -sanjay

    just create a standard method make sure the parameter you pass implements java.io.Serializable or if its a primitive type use the wrapper ie int->Integer
  3. re:wrapper classes[ Go to top ]

    Did you try to update int value in Integer object, for example ? ;-)
    All wrapper classes are immutable.
  4. The summary is: Is there any support for OUT/INOUT parameters in stateless session beans?

    just create a standard method make sure the parameter you pass implements java.io.Serializable

    :-)))
    ...and your parameters will be successfully serialized when they are passed in forward (Client -> SLSB) direction. BTW, requirement of Remote interfaces. And now what kind of magic serializes them back?

    or if its a primitive type use the wrapper ie int->Integer
    No comments. Mutable java.lang.Integer? Or you have your own wrapper?

    VS
  5. VS,
    I tried both the things (Integer wrapper for primitive datatype and serialized object as well), But It does not work.
    I think EJB does not support the concept of OUT/INOUT for remotely deployed beans, because parameters are passed by value NOT by reference ( as in the case of local deployed beans). This is described in EJB 2.0 SPEC sec 5, as replied by one of my folks.
  6. sanjay prasad

    VS,
    I tried both the things (Integer wrapper for primitive datatype and serialized object as well), But It does not work.


    You did not notice "smile" in my message. I mean exactly what you are saying -- the proposed "solution" will NOT work.


    I think EJB does not support the concept of OUT/INOUT for remotely deployed beans, because parameters are passed by value NOT by reference ( as in the case of local deployed beans). This is described in EJB 2.0 SPEC sec 5, as replied by one of my folks.


    Exactly. This is what I sayed about serialization. In remote calls parameters passed by client are serialized and transfered to server. But there is no magic that passes modified parameters back to client.

    VS
  7. Hi!

    If a "normal" Java process accesses an EJB, all parameters are passes by value. This means the EJB will get a copy of the object. If that object is changed within the EJB code, the client will still keep it's original copy. The only way to return a value from an EJB to the client (outside the EJB container) is to use a return value (or an exception).

    See chapter 5 in the EJB 2.1 spec. for details. The list in section 5.4 gives a good description on this.

    /Tomas