sunlabs.brazil.sunlabs

Class LockTemplate

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

Method Summary
booleandone(RewriteContext hr)
voidtag_lock(RewriteContext hr)
Acquire a lock, preventing any other session from accessing the same locked section of markup.
voidtag_slash_lock(RewriteContext hr)
Release the previosly named lock.

Method Detail

done

public boolean done(RewriteContext hr)

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.