Class LockTemplate

  • All Implemented Interfaces:
    TemplateInterface

    public class LockTemplate
    extends Template
    Template to lock a resource. <lock name=xxx> ... </lock> Claim exclusive access to the lock named "xxx". Locks are used to serialize access to sections of markup, thus insuring the integrity of data structures. Traditionally, this was done by managing sessions: since only one template may be active per session, forcing all access to serialized regions into the same session has the desired effect. However, since sessions are typically managed on a per URL basis, each serialized piece of markup needs to be in its own URL, and a pair of SimpleSessionHandler/UrlMapperHandler needs to be configured for each named serialized region.

    Only one lock may be held at a time. The current lock (if any) is automatically released at the end of the template. Care should be taken not to acquire a lock then invoke a blocking operation (such as with the QueueTemplate) or deadlock may occur.

    Example:

     <lock name="server">
       <set namespace="server" name=.....>
       ...
       <set namespace="server" name=.....>
     </lock>
     
    This insures that no other session may access the code protected by the "server" lock, either from this or any other template.
    Version:
    Author:
    Stephen Uhler
    • Field Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      LockTemplate()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean done​(RewriteContext hr)
      Called after all tags have been processed, one final chance.
      void tag_lock​(RewriteContext hr)
      Acquire a lock, preventing any other session from accessing the same locked section of markup.
      void tag_slash_lock​(RewriteContext hr)
      Release the previosly named lock.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LockTemplate

        public LockTemplate()
    • Method Detail

      • tag_lock

        public void tag_lock​(RewriteContext hr)
        Acquire a lock, preventing any other session from accessing the same locked section of markup.
      • tag_slash_lock

        public void tag_slash_lock​(RewriteContext hr)
        Release the previosly named lock.