This project has retired. For details please refer to its Attic page.
Locking
Polygene™
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

Locking

code

docs

tests

The Locking Library is a simple way to mark method with Read or Write locks, and the details is handled by this library.

This library is heavily used in EntityStore implementations.

Table 30. Artifact

Group IDArtifact IDVersion

org.apache.polygene.libraries

org.apache.polygene.library.locking

3.0.0


The library creates a java.util.concurrent.ReentrantReadWriteLock which is shared for all methods within the composite. It then acquires the read or write lock in a concern that is applied to the methods of the composite, which have the corresponding annotations.

@ReadLock

This annotation will apply the ReadLockConcern to the method, and acquire the lock.readLock() on entry and relase it on exit of the method. See the ReentrantReadWriteLock for details on how/when to use it and the exact semantics.

@WriteLock

This annotation will apply the WriteLockConcern to the method, and acquire the lock.writeLock() on entry and relase it on exit of the method. See the ReentrantReadWriteLock for details on how/when to use it and the exact semantics.

LockingAbstractComposite

This composite type is the easiest way to use this library. Simple extend you composite type interface with this interface and start marking the methods with the above annotations. No other complex assembly is required.

public interface SomeService
    extends ServiceComposite, LockingAbstractComposite
{
}

or apply it during assembly, in case that is the only choice (such as existing/external interfaces)

public class MyModuleAssembler
    implements ModuleAssembler{

    @Override
    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly module )
        throws AssemblyException
    {
        module.services( MyService.class ).withTypes( LockingAbstractComposite.class );
        return module;
    }
}