Class CachingOfBizPropertySet
- All Implemented Interfaces:
com.opensymphony.module.propertyset.PropertySet
,Serializable
OFBizPropertySet
that caches property entries and values to provide
more efficient access.
Note that JiraCachingPropertySet
is just a decorator around an arbitrary supplied
property set and thus has uncertain behaviour both in a clustered environment and when there
are multiple instances of the caching property set, as the individual caches have no way to
share state.
CachingOfBizPropertySet
is different. It is a flyweight around the
OfBizPropertyEntryStore
, which caches the operations that it can (such as the
existence, type, and value of an entry) and delegates those it can't cache to the database
directly. The implementation deviates from that of OFBizPropertySet
only in ways
that make it more fault-tolerant, such as by not throwing an exception when removing a
nonexistent property and not throwing an exception when setting a property to a new type
without removing it first.
The only known disadvantage to using this class is that it will eagerly load the value on
a cache miss. This seems to be an acceptable loss, because the main reasons why code
would bother to call exists(String)
or getType(String)
seem to be
- To know whether or not the property exists and/or the appropriate getter type to use, both of which suggest that the value will eventually be retrieved anyway and that loading it eagerly is not wasteful.
- To guard against the exception that
OFBizPropertySet
throws if you attempt to remove a property that does not exist of change the type of an existing property. This implementation silently ignores a spurious remove and gracefully updates the type if it is changed, so these guards are not necessary. - To use the existence or absence of the key as a
boolean
value, where the actual stored value is a meaningless sentinel. This is a strange thing to do, and it makes more sense to store an actualboolean
value for the property, instead.
This class is thread-safe, in spite of the difficulties that the PropertySet
contract imposes upon it. Its only mutable state is the entity definition provided through
PropertySet.init(Map, Map)
. This is stored in an immutable holder class whose reference
is marked as volatile
to ensure safe publishing.
Although OFBizPropertySet
itself allows for multiple generic delegators to be used,
this implementation ignores this setting. JIRA always uses the "default"
delegator.
- Since:
- v6.2
- See Also:
-
Field Summary
Fields inherited from class com.opensymphony.module.propertyset.AbstractPropertySet
schema
Fields inherited from interface com.opensymphony.module.propertyset.PropertySet
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML
-
Constructor Summary
ConstructorsConstructorDescriptionCachingOfBizPropertySet
(OfBizPropertyEntryStore entryStore, String entityName, Long entityId) CachingOfBizPropertySet
(String entityName, Long entityId) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
protected Object
getKeys()
getKeys
(int type) int
int
hashCode()
void
void
remove()
void
Implementation note: UnlikeOFBizPropertySet
, this implementation will not throw an exception if the property does not exist.protected void
boolean
supportsType
(int type) Methods inherited from class com.opensymphony.module.propertyset.AbstractPropertySet
getAsActualType, getBoolean, getData, getDate, getDouble, getInt, getLong, getObject, getProperties, getSchema, getString, getText, getXML, isSettable, setAsActualType, setBoolean, setData, setDate, setDouble, setInt, setLong, setObject, setProperties, setSchema, setString, setText, setXML, supportsTypes, toString, type, type
-
Constructor Details
-
CachingOfBizPropertySet
public CachingOfBizPropertySet() -
CachingOfBizPropertySet
-
CachingOfBizPropertySet
public CachingOfBizPropertySet(OfBizPropertyEntryStore entryStore, String entityName, Long entityId)
-
-
Method Details
-
getKeys
- Specified by:
getKeys
in interfacecom.opensymphony.module.propertyset.PropertySet
- Overrides:
getKeys
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
getKeys
- Specified by:
getKeys
in interfacecom.opensymphony.module.propertyset.PropertySet
- Overrides:
getKeys
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
getKeys
- Specified by:
getKeys
in interfacecom.opensymphony.module.propertyset.PropertySet
- Overrides:
getKeys
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
getKeys
- Specified by:
getKeys
in interfacecom.opensymphony.module.propertyset.PropertySet
-
getType
- Specified by:
getType
in interfacecom.opensymphony.module.propertyset.PropertySet
- Throws:
com.opensymphony.module.propertyset.PropertyException
-
exists
- Specified by:
exists
in interfacecom.opensymphony.module.propertyset.PropertySet
- Throws:
com.opensymphony.module.propertyset.PropertyException
-
init
- Specified by:
init
in interfacecom.opensymphony.module.propertyset.PropertySet
- Overrides:
init
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
remove
public void remove() throws com.opensymphony.module.propertyset.PropertyException- Specified by:
remove
in interfacecom.opensymphony.module.propertyset.PropertySet
- Throws:
com.opensymphony.module.propertyset.PropertyException
-
remove
Implementation note: UnlikeOFBizPropertySet
, this implementation will not throw an exception if the property does not exist.- Specified by:
remove
in interfacecom.opensymphony.module.propertyset.PropertySet
- Parameters:
key
- the key of the property to be removed- Throws:
com.opensymphony.module.propertyset.PropertyException
- if the attempt to remove an existing property fails at the persistence layer
-
supportsType
public boolean supportsType(int type) - Specified by:
supportsType
in interfacecom.opensymphony.module.propertyset.PropertySet
- Overrides:
supportsType
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
setImpl
- Specified by:
setImpl
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
get
- Specified by:
get
in classcom.opensymphony.module.propertyset.AbstractPropertySet
-
equals
-
hashCode
public int hashCode()
-