private field in a stateless session EJB - Weblogic

This is a discussion on private field in a stateless session EJB - Weblogic ; Hi guys, I have a question about the design of a stateless session EJB. I would like to know : Does it make sense to put a private field in a stateless session bean??? Imagine the following sitiation: I have ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: private field in a stateless session EJB

  1. private field in a stateless session EJB


    Hi guys,
    I have a question about the design of a stateless session EJB.
    I would like to know :

    Does it make sense to put a private field in a stateless session bean???

    Imagine the following sitiation:
    I have a stateless session bean.
    Its job is to delegate the clients calls to some services (Java objects).
    These services are held in the private field and instatiated when WebLogic invokes
    the ejbCreate method.

    So I would like these services (Java objects) be instantiated before the clients
    invoke the bean's method for delegation - I mean, when WebLogic
    decides to create beans and put it in the pool (on the server startup for example).

    But what happens when the same bean once having finished its job is used by a
    different client???

    Are the services once instatiated available to the new client or WebLogic invokes
    the ejbCreate() method and the services are instatiated one more time???(which
    would be a performence killer)

    I must mention that in order to make the instatiation of the services possible,
    I presume I must implement the ejbCreate() method on the bean implementation class
    which invokes a private method doing the instatiation.

    So, do you think these design is a good design and what is its impact on the performence
    of the stateless session EJB ???

    Thank you.
    Freddy

  2. Re: private field in a stateless session EJB

    Freddy wrote:
    > Hi guys,
    > I have a question about the design of a stateless session EJB.
    > I would like to know :
    >
    > Does it make sense to put a private field in a stateless session bean???
    >


    Sure


    > Imagine the following sitiation:
    > I have a stateless session bean.
    > Its job is to delegate the clients calls to some services (Java objects).
    > These services are held in the private field and instatiated when WebLogic invokes
    > the ejbCreate method.
    >
    > So I would like these services (Java objects) be instantiated before the clients
    > invoke the bean's method for delegation - I mean, when WebLogic
    > decides to create beans and put it in the pool (on the server startup for example).
    >
    > But what happens when the same bean once having finished its job is used by a
    > different client???
    >
    > Are the services once instatiated available to the new client or WebLogic invokes
    > the ejbCreate() method and the services are instatiated one more time???(which
    > would be a performence killer)
    >


    WLS keeps the bean instances around in a pool. See
    http://edocs.bea.com/wls/docs81/ejb/...n.html#1118700

    > I must mention that in order to make the instatiation of the services possible,
    > I presume I must implement the ejbCreate() method on the bean implementation class
    > which invokes a private method doing the instatiation.
    >
    > So, do you think these design is a good design and what is its impact on the performence
    > of the stateless session EJB ???


    It's fine and a pretty common pattern.

    -- Rob

    >
    > Thank you.
    > Freddy



  3. Re: private field in a stateless session EJB


    Rob Woollen wrote:
    >Freddy wrote:
    >> Hi guys,
    >> I have a question about the design of a stateless session EJB.
    >> I would like to know :
    >>
    >> Does it make sense to put a private field in a stateless session bean???
    >>

    >
    >Sure
    >
    >
    >> Imagine the following sitiation:
    >> I have a stateless session bean.
    >> Its job is to delegate the clients calls to some services (Java objects).
    >> These services are held in the private field and instatiated when WebLogic

    >invokes
    >> the ejbCreate method.
    >>
    >> So I would like these services (Java objects) be instantiated before

    >the clients
    >> invoke the bean's method for delegation - I mean, when WebLogic
    >> decides to create beans and put it in the pool (on the server startup

    >for example).
    >>
    >> But what happens when the same bean once having finished its job is

    >used by a
    >> different client???
    >>
    >> Are the services once instatiated available to the new client or WebLogic

    >invokes
    >> the ejbCreate() method and the services are instatiated one more time???(which
    >> would be a performence killer)
    >>

    >
    >WLS keeps the bean instances around in a pool. See
    >http://edocs.bea.com/wls/docs81/ejb/...n.html#1118700
    >
    >> I must mention that in order to make the instatiation of the services

    >possible,
    >> I presume I must implement the ejbCreate() method on the bean implementation

    >class
    >> which invokes a private method doing the instatiation.
    >>
    >> So, do you think these design is a good design and what is its impact

    >on the performence
    >> of the stateless session EJB ???

    >
    >It's fine and a pretty common pattern.
    >
    >-- Rob
    >
    >>
    >> Thank you.
    >> Freddy

    >

    Thank you very much Rob.
    Freddy

+ Reply to Thread