Class LockTemplate

java.lang.Object
sunlabs.brazil.template.Template
sunlabs.brazil.sunlabs.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:
@(#)LockTemplate.java 1.1
Author:
Stephen Uhler
  • Constructor Details

    • LockTemplate

      public LockTemplate()
  • Method Details

    • 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.
    • done

      public boolean done(RewriteContext hr)
      Description copied from class: Template
      Called after all tags have been processed, one final chance.
      Specified by:
      done in interface TemplateInterface
      Overrides:
      done in class Template