com.arsdigita.util
Interface Lockable

All Known Subinterfaces:
Component, Container, DataQueryBuilder, ExcursionComponent, ItemDetailModelBuilder, ListModelBuilder, Lockable, PropertyEditorModelBuilder, PropertySheetModelBuilder, TableColumnModel, TableModelBuilder, TreeModelBuilder
All Known Implementing Classes:
AbstractDataQueryBuilder, AbstractListModelBuilder, AbstractSingleSelectionModel, AbstractTableModelBuilder, Attributes, Completable, CompoundComponent, DataQueryListModelBuilder, DataTable.DataBuilderAdapter, DefaultTableColumnModel, FormModel, FormSection, LockableImpl, MapComponentSelectionModel, NullComponent, Page, ParameterModel, PartySearchSelect, ProcessListenerListModelBuilder, PropertyEditor.DefaultModelBuilder, SimpleComponent, SimpleContainer, StaticDataQueryBuilder, TableColumn

public interface Lockable

A common interface for all lockable parts of ACS. The locking mechanism makes it possible to safely split all data structures that are used inside a web server into ones that are constant across all requests and those that may change during a request.

The distinction betwen static and request-specific data helps in optimizing the amount of memory that needs to be allocated for each request. Data structures that are static can be allocated and initialized ahead of time, e.g., in the init method of a servlet. The initialized data structures are then locked to make them immutable. This mechanism ensures that static structures that are supposed to be shared by many requests, often even concurrently, do not change and are not "polluted" by request-specific data.

There is no automatic mechanism that makes an object immutable by itself. The right checks and operations need to be implemented by each class implementing Lockable.

Bebop parameters are a good example of how one logical structure is split into two classes: the class ParameterModel is Lockable and only contains the description of the parameter in an HTTP request that is static and does not change on a per-request basis, such as the name of the parameter and the (Java) type that the parameter value should be converted to. The class ParameterData contains all the request-specific information for a parameter, such as the value of the parameter.

Any class that implements Lockable is expected to be fully modifiable until its lock() method is called. From that point on, it is read-only and should throw exceptions whenever an attempt is made to modify it.

Version:
$Id: //core-platform/dev/src/com/arsdigita/util/Lockable.java#7 $
Author:
David Lutterkort

Field Summary
static String versionId
           
 
Method Summary
 boolean isLocked()
          Return whether an object is locked and thus immutable, or can still be modified.
 void lock()
          Lock an object.
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Method Detail

lock

public void lock()
Lock an object. Locked objects are to be considered immutable. Any attempt to modify them, e.g., through a setXXX method should lead to an exception.

Most lockable Bebop classes throw an IllegalStateException if an attempt is made to modify a locked instance.


isLocked

public boolean isLocked()
Return whether an object is locked and thus immutable, or can still be modified.



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC