Synchronizing Thin Bean Requests

In HTML-client applications, you must make sure that requests that are routed to BI Beans thin beans are synchronized. The thin beans do not manage synchronization internally. If you do not manage synchronization, and two simultaneous requests use the same thin bean, then unpredictable results may occur.

The simplest way to manage synchronization is to associate the thin bean in a single HttpSession and then to synchronize every request to that session. The following code shows how to do this.

 
// fetch the crosstab from the session or put a crosstab in the session HttpSession httpSession = request.getSession(true); // synchronize access to the crosstab synchronized (httpSession) { ThinCrosstab crosstab = (ThinCrosstab)httpSession.getValue("SessionCrosstab"); if (crosstab == null) { crosstab = new ThinCrosstab(); crosstab.setThinBeanName("MyReport"); httpSession.putValue("SessionCrosstab",  crosstab); }// other event handling and rendering code } // end synchronized

Of course, you can use more flexible strategies for synchronization, such as synchronizing access to specific groups of thin beans within a session or synchronizing access to specific thin beans. However, as your strategy becomes more granular, you must be more careful to avoid common synchronization problems, such as deadlock, long queues for objects, or application logic issues.

Note: To provide thread-safe processing for BI JSP tags, JDeveloper automatically inserts a synchronized scriptlet to create a block of code that is synchronized on a session object. All BI JSP tags are contained within this block of code, to prevent unexpected results when multiple requests are processed.