Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jgroups.blocks.locking
Class LockService

    java.lang.Object
      org.jgroups.blocks.locking.LockService

    public class LockService

extends java.lang.Object

LockService is the main class for to use for distributed locking functionality. LockService needs access to a `JChannel` and interacts with a locking protocol (e.g. `CENTRAL_LOCK`) via events.

When no locking protocol is seen on the channel's stack, LockService will throw an exception at startup. An example of using LockService is:

       JChannel ch=new JChannel("/home/bela/locking.xml); // locking.xml needs to have a locking protocol towards the top
       LockService lock_service=new LockService(ch);
       ch.connect("lock-cluster");
       Lock lock=lock_service.getLock("mylock");
       lock.lock();
       try {
          // do something with the lock acquired
       }
       finally {
          lock.unlock();
       }

Note that, contrary to the semantics of `Lock`, unlock() can be called multiple times; after a lock has been released, future calls to unlock() have no effect.

Since:
  2.12
Author:
  Bela Ban

Nested Class Summary
`protected class` | `LockService.LockImpl`

Field Summary
`protected JChannel` | `ch`
`protected Locking` | `lock_prot`

Constructor Summary
`LockService()`
`LockService(JChannel ch)`

Method Summary
`void` | `addLockListener(LockNotification listener)`
`java.util.concurrent.locks.Lock` | `getLock(java.lang.String lock_name)`
`java.lang.String` | `printLocks()`
`void` | `removeLockListener(LockNotification listener)`
`void` | `setChannel(JChannel ch)`
`void` | `unlockAll()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ch

    protected JChannel ch

### lock_prot

    protected Locking lock_prot

Constructor Detail

### LockService

    public LockService()

### LockService

    public LockService(JChannel ch)

Method Detail

### setChannel

    public void setChannel(JChannel ch)

### getLock

    public java.util.concurrent.locks.Lock getLock(java.lang.String lock_name)

### unlockAll

    public void unlockAll()

### addLockListener

    public void addLockListener(LockNotification listener)

### removeLockListener

    public void removeLockListener(LockNotification listener)

### printLocks

    public java.lang.String printLocks()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.