Discussions

EJB design: Share Data across EJBs

  1. Share Data across EJBs (2 messages)

    Hi !!!
       How do I share data across EJB's. Like a counter or a status attribute which needs to be checked across EJB's before proceeding.

    We have an application on weblogic which uses EJB's. The number of requests need to be available across EJB's. In other words I would need to have a static (synchronised) variable which can be written/read by any EJB in the application.

    How can I do this.

    ThanX & Rgds
    Nitya

    Threaded Messages (2)

  2. Share Data across EJBs[ Go to top ]

    Put that in a EJB and other EJB can acess it like a normal EJB.

    Things you have to consider is what happens when you deploy ejbs in different servers. Statics wont work then because they are on different VMs

    One thing you can do it put the variable in a java class and acess it via JNDI. That effectively solves your singleton issues.
  3. Share Data across EJBs[ Go to top ]

    If you want to write a ejb which control the number of request, you can write it as an entity bean.

    And other EJB could always lookup the same "primary" key from the container. Same primary key will mapping to same ejb entity bean instance for you. And all ejbs could access it free. If you make sure that all your ejb/application were running under the same VM, then you can use local interface (EJB 2.0 spec) to improve the performance. If you were not sure about that, then remote interface !!

    Nicholas Hsiao