Class LockTemplate

  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.sunlabs.LockTemplate (view source)
All Implemented Interfaces:

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.


 <lock name="server">
   <set namespace="server" name=.....>
   <set namespace="server" name=.....>
This insures that no other session may access the code protected by the "server" lock, either from this or any other template.

Field Summary
Fields inherited from class sunlabs.brazil.template.Template
Constructor Summary
Method Summary
 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 sunlabs.brazil.template.Template
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public LockTemplate()
Method Detail


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


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


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
done in class Template

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.