Helper classes or stateless beans

Discussions

EJB design: Helper classes or stateless beans

  1. Helper classes or stateless beans (7 messages)

    We have a requirement in application to record the result of activity to database. There are around 8 activities defined in system ( may grow in future). One client request may ask for around 15 activities recorded in database.

    We could think of two options to model this requirement

    1. Model a Java Helper class for each activity. (total 8 classes) We could use Factory pattern.

       Sub-option 1) Create a new instance of the class for every record activity. Disadvantage: Too many instance will be created which is not necessary, since record is only sa process and no state is required.

        Sub-option 2) Factory will retiurn the same instance of an activity class to all the clients. Advantage: Only one instance in memory. Disadvantage: Will there be a 'wait' time if there are multiple requests for the same class at a single instance?

    2. Model 8 stateless beans for 8 activity types.

    Advantage: Make use of instance pooling provided by the EJB Container.

    Disadvantage: Overhead of RMI calls.

    Any thoughts will be appreciated.

    Thanks
    Jagdish

    Threaded Messages (7)

  2. Helper classes or stateless beans[ Go to top ]

    I am assuming the application you refered is already on
    the server side,e.g. a session bean.
    From what you described, you just want to add some entries
    to the database, then just use the helper class,session bean
    is overkill here.
    Suboption 2) make sense, since the helper class is stateless, don't worry about wait time unless you
    "synchronized" your code, which is also prohibited by EJB.
  3. Helper classes or stateless beans[ Go to top ]

    Hello Qing

    I am wondering what happens to the objects graph (helper classes) instanciated during the Stateless Session Bean (SSB) creation when the SSB is returned to the pool. Does the reference to the objects graph is maintained (We assume here that the helper classes are stateless) or do we need to reinstanciate the graph each time a methode is called on the SSB ?

    TIA for your feedback

    Greetings Laurent
  4. Helper classes or stateless beans[ Go to top ]

    Not necessary,helper classes can be kept through the life cyle of the bean instance, actually somebody wrote a pattern for this in the Pattern section called <Dependent Session Objects>, you can take a look.
  5. Helper classes or stateless beans[ Go to top ]

    Not necessary,helper classes can be kept through the life cyle of the bean instance, actually somebody wrote a pattern for this in the Pattern section called <Dependent Session Objects>, you can take a look.
  6. Helper classes or stateless beans[ Go to top ]

    By saying 'not necessarily' do I have to understand that the container will preserve the reference anyway? I've followed the Gari's discussion about dependent objects but this particular point has not been clearly discussed.

    TIA for your comments Laurent
  7. Helper classes or stateless beans[ Go to top ]

    No..there is no passivation for SLSB..don't worry.
  8. Helper classes or stateless beans[ Go to top ]

    Tank you for your support

    Greetings Laurent