Interface SynchronizerSupport
-
- All Known Subinterfaces:
Configuration,FileBasedConfiguration,HierarchicalConfiguration<T>
- All Known Implementing Classes:
AbstractConfiguration,AbstractHierarchicalConfiguration,AbstractYAMLBasedConfiguration,AppletConfiguration,BaseConfiguration,BaseHierarchicalConfiguration,CombinedConfiguration,CompositeConfiguration,DatabaseConfiguration,DataConfiguration,DynamicCombinedConfiguration,EnvironmentConfiguration,INIConfiguration,JNDIConfiguration,JSONConfiguration,MapConfiguration,PatternSubtreeConfigurationWrapper,PropertiesConfiguration,PropertyListConfiguration,ServletConfiguration,ServletContextConfiguration,ServletFilterConfiguration,ServletRequestConfiguration,SubnodeConfiguration,SubsetConfiguration,SystemConfiguration,XMLConfiguration,XMLPropertiesConfiguration,XMLPropertyListConfiguration,YAMLConfiguration
public interface SynchronizerSupport
Definition of an interface for objects that can be associated with a
Synchronizer.This interface defines methods for querying and setting the
Synchronizer. In addition, it is possible to lock the object for a certain operation. This is useful if some complex operations are to be performed on theSynchronizerSupportobject in an atomic way.Note that the actual effect of these methods depends on the concrete
Synchronizerimplementation in use! If only a dummySynchronizeris involved (which is appropriate if objects are only accessed by a single thread), locking an object does not really prohibit concurrent access.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SynchronizergetSynchronizer()Gets theSynchronizerused by this object.voidlock(LockMode mode)Locks this object for the specified mode.voidsetSynchronizer(Synchronizer sync)Sets theSynchronizerto be used by this object.voidunlock(LockMode mode)Releases a lock of this object that was obtained using thelock(LockMode)method.
-
-
-
Method Detail
-
getSynchronizer
Synchronizer getSynchronizer()
Gets theSynchronizerused by this object. An implementation must not return null. If noSynchronizerhas been set so far, a meaningful defaultSynchronizerhas to be returned.- Returns:
- the
Synchronizerused by this object
-
setSynchronizer
void setSynchronizer(Synchronizer sync)
Sets theSynchronizerto be used by this object. Calling this method and setting an appropriateSynchronizerdetermines whether this object can be accessed in a thread-safe way or not. The argument may be null; in this case an implementation should switch to a defaultSynchronizer.- Parameters:
sync- theSynchronizerfor this object
-
lock
void lock(LockMode mode)
Locks this object for the specified mode. This call may block until this object is released from other lock operations. When it returns the caller can access the object in a way compatible to the specifiedLockMode. When done theunlock()must be called with the sameLockModeargument. In practice, a try-finally construct should be used as in the following example:SynchronizerSupport syncSupport = ...; syncSupport.lock(LockMode.READ); try { // read access to syncSupport } finally { syncSupport.unlock(LockMode.READ); }Note: Always use this method for obtaining a lock rather than accessing the object'sSynchronizerdirectly. An implementation may perform additional actions which are not executed when only interacting with theSynchronizer.- Parameters:
mode- theLockMode
-
unlock
void unlock(LockMode mode)
Releases a lock of this object that was obtained using thelock(LockMode)method. This method must always be called pair-wise withlock(). The argument must match to the one passed to the correspondinglock()call; otherwise, the behavior of theSynchronizeris unspecified.- Parameters:
mode- theLockMode
-
-