Class ThreadingSynchronization

java.lang.Object
org.eclnt.jsfserver.util.ThreadingSynchronization

public class ThreadingSynchronization extends Object
This class provides synchonization objects which are applied when UI requests are processed and access data that is bound to the dialog processing. Per dialog session a corresponding object is managed.

Example: the central ThreadingFilter performas in the following way:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain, IExternalRequestProcessing externalChainProcessing)
{
    ...
    Object synchObject = ThreadingSynchronization.getSynchObject(...);
    synchronized(synchObject)
    {
    ...
    ...all internal processing of the CC-processing...
    ...
    }
    ...
}

In case of creating a separate thread and in case of accessing/updating UI-objects from this thread you must ensure to synchronize with the CaptainCasa synchronization! This means, you have to also arrange your functions in a corresponding synchronized-block.
  • Constructor Details

    • ThreadingSynchronization

      public ThreadingSynchronization()
  • Method Details

    • instance

      public static ThreadingSynchronization instance()
    • getSynchObject

      public ReentrantLock getSynchObject(ISessionAbstraction dialogSession)
      Parameters:
      dialogSession - Within the request processing you may use HttpSessionAccess.getCurrentDialogSession() for getting the current dialog session.
      Returns:
      Synchronization object for the corresponding session. If no dialog session is passed then a new Object is passed back.
    • getSynchObject

      public ReentrantLock getSynchObject(String dialogSessionId)
    • unregisterDialogSession

      public void unregisterDialogSession(String subPageId)
      This function is automatically called when a dialog session is closed on server side.
    • checkIfDialogSessionIsLocked

      public boolean checkIfDialogSessionIsLocked(String dialogSessionId)
      Returns true if dialogSession is locked in general.
    • checkIfDialogSessionIsLockedByOtherThread

      public boolean checkIfDialogSessionIsLockedByOtherThread(String dialogSessionId)
      Returns true if dialogSession is locked by an other thread.
    • executeSynchronized

      public void executeSynchronized(String dialogSessionId, Runnable r)
      Executes the Runnable synchronized within the dialog session.
    • executeSynchronizedIfSessionIsAvailable

      public boolean executeSynchronizedIfSessionIsAvailable(String dialogSessionId, Runnable r)
      Executes the Runnable instance if the passed dialogSessionId is not occupied by any other processing. The Runnable is then executed in a synchronized way.
      Returns:
      true: the runnable was executed, false: the runnable was not executed because the dialog session is currently used within an other thread.