Discussions

EJB design: EJB Home Factory

  1. EJB Home Factory (4 messages)

    I just read the EJB Patterns article on the EJB Home Factory. It suggests using a singelton to retrive EJB Home Interfaces. I like this solution on the surface, but am hesitant to put it tpo use on my large internet application. I am worried that the advantages gained by looking up and instantiating the Home interface once will be negated by contention among multiple users for the EJB Home. I would love to hear everyone's thought on the subject.

    Thanks in Advnace,
    Ken

    Threaded Messages (4)

  2. EJB Home Factory[ Go to top ]

    One way to avoid contention will be to create all the home objects and cache them on server startup. From then on, the singleton will be read only and no thread synchrization will be necessary.

    Pranab
  3. EJB Home Factory[ Go to top ]

    Not sure I follow how this resolves the issue. If two or more users request the same home interface at the same time, will there not be contention? Will the other's not have to wait until the first user is done?

    Thanks,
    Ken
  4. EJB Home Factory[ Go to top ]

    What contention? What the first user is supposed to occupy the system with? It's like parallel calls to any object - if they are not synchronized, there's no delay...
  5. EJB Home Factory[ Go to top ]

    There's no issue with locks if you "initialize" things using a startup class.

    If you do that then you are sure that initialization occurs in a single threaded manner. THereafter you don't need synchronization in any case.

    The only problem is if home interfaces die (how do you re-create them in a thread safe manner.)

    In that case, use the read/write lock pattern. That way, many many threads are allowed to read at once, but only one may write. Requests get queued up and all is well.

    There are discussions and links on the Reader/Writer lock pattern on this site. Take a look.

    Chz

    Tony