Can entity beans share a data staructure

Discussions

EJB design: Can entity beans share a data staructure

  1. Can entity beans share a data staructure (4 messages)

    Hi all,
    Is there a way for entity beans to share a static data structure?
    Thanks in advance
    -r
  2. Are you talking about something like a Singleton? A configuration cache maybe?
  3. Well some sort of data structure that would be concurrency-safe for multiple clients to access. Also, can I put a whole java object in the configuration cache?
    I thought Singletons are not allowed in the j2ee architecture?!
    Is the configuration cache thread safe?
    I am not anticipating clustered architecture, so singletons would do for now I guess... Well I need an architecture which would allow me to share data among my entity beans in a concurrent-safe manner.
    -r
  4. Hello Rasoul,

         I guess you are targeting following issues.
    1. Shared object.
    2. concurency safe.

         I will suggest you should go for JNDI driven caching mechanism.
    Secondly the java bean that is going to hold the values should be marked synchronous.

        Why cache as if you use singleton then multi server environment will require you to change the code.

        My approach will be to write a controller login in session bean (Hence giving network presence to my Java Bean).

        Use a singleton that will be held in one JVM and accessed only through a session bean.
  5. Please elaborate on;

    Secondly the java bean that is going to hold the values should be marked synchronous.

    My approach will be to write a controller login in session bean (Hence giving network presence to my Java Bean).

    I am not sure I understand what you mean?

    Thanks in advance
    -r