Discussions

EJB design: EJBs and Thread management

  1. EJBs and Thread management (4 messages)

    I know that the EJB specification forbids an EJB from creating or managing threads, but what about blocking? For example, I have a bean that needs to add an item to a shared Queue. The custom add method for the queue is synchronized, so is this okay for the bean to call?

    Thanks.

    Threaded Messages (4)

  2. EJBs and Thread management[ Go to top ]

    The answer to your question lies in the question :
    Can I use java.util.vector in EJBs . All its methods are synchronized .

    J2EE spec does not prohibit from accessing sync. methods. It only prohibits starting , susoending threads from the ejb methods .

    hope it helps
    thanx and regards
    Prajakt
  3. EJBs and Thread management[ Go to top ]

    Prajakt,

    I agree with your bottom line. However, this:
    <prajakt>
    J2EE spec does not prohibit from accessing sync. methods. It only prohibits starting , susoending threads from the ejb methods.
    </prajakt>

    Is not completely true. Except for the rule forbidding EJBs from doing thread management, there is also a rule that sais:
    <spec>
    An enterprise Bean must not use thread synchronization primitives to synchronize execution of multiple instances.
    </spec>

    This rule is somewhat open for interpretation. For a discussion of this issue see:
    http://www.theserverside.com/discussion/thread.jsp?thread_id=17449
  4. EJBs and Thread management[ Go to top ]

    yes , synchronizing (ejb) methods is alos not allowed .
  5. EJBs and Thread management[ Go to top ]

    Parjakt,

    I disagree with your interpretation of the spec. The link I posted contains a pretty broad explanation of that, so I won't repeat it here.

    Gal