Package sunlabs.brazil.sunlabs
Class LockTemplate
java.lang.Object
sunlabs.brazil.template.Template
sunlabs.brazil.sunlabs.LockTemplate
- All Implemented Interfaces:
TemplateInterface
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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
done
(RewriteContext hr) Called after all tags have been processed, one final chance.void
Acquire a lock, preventing any other session from accessing the same locked section of markup.void
Release the previosly named lock.
-
Constructor Details
-
LockTemplate
public LockTemplate()
-
-
Method Details
-
tag_lock
Acquire a lock, preventing any other session from accessing the same locked section of markup. -
tag_slash_lock
Release the previosly named lock. -
done
Description copied from class:Template
Called after all tags have been processed, one final chance.- Specified by:
done
in interfaceTemplateInterface
- Overrides:
done
in classTemplate
-