org.jdsf.dl
Class LockObject

java.lang.Object
  extended by org.jdsf.dl.LockObject

public class LockObject
extends java.lang.Object

This class is a Framework for synchronizing different processes that run on different JVM and event uppon different computers. Currently we implemented on the synchronization ability unfortunatly synchronize is a java keyword that can not be overriden so we had to use the getLock an releaseLock methods To make the the solution complete we added the notifyFor, notifyAllFor and waitFor methods, that acts like the notify, notifyAll, wait methods (accordingly)

Author:
Aviad Lichtenstadt Date: Sep 20, 2006

Method Summary
static void getLock(java.lang.String lockName)
          this method will achieve the lock on the specified String.
static void notifyAllFor(java.lang.String lockName)
          This method will notify on the current lock name, this notification will be caught bt all waiting instances.
static void notifyFor(java.lang.String lockName)
          This method will notify on the current lock name, this notification can be caught by only one wait method.
static void releaseLock(java.lang.String lockName)
          this method will release the lock on the specified String.
static void waitFor(java.lang.String lockName)
          This method will wait for a notification on the specified string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLock

public static void getLock(java.lang.String lockName)
this method will achieve the lock on the specified String. this method will block untill it will be the only one to use the lock in the whole distributed space.

Parameters:
lockName - a lock String that should be the same on all instances of the code
Throws:
java.lang.IllegalMonitorStateException

releaseLock

public static void releaseLock(java.lang.String lockName)
this method will release the lock on the specified String. this method will release the lock and this way let other hanging Threads on different JVM as well (as on the current JVM) to enter the critical section

Parameters:
lockName - a lock String that should be the same on all instances of the code
Throws:
java.lang.IllegalMonitorStateException - if the monitor is not captured by this Thread

waitFor

public static void waitFor(java.lang.String lockName)
                    throws java.lang.InterruptedException
This method will wait for a notification on the specified string. The notification can come from any JVM that uses teh JDSF library. At current version there is no need to lock on the String before using hte wait method

Parameters:
lockName - a lock String that should be the same on all instances of the code
Throws:
java.lang.InterruptedException

notifyFor

public static void notifyFor(java.lang.String lockName)
This method will notify on the current lock name, this notification can be caught by only one wait method.

At current version there is no need to lock on the String before using hte wait method

Parameters:
lockName - a lock String that should be the same on all instances of the code

notifyAllFor

public static void notifyAllFor(java.lang.String lockName)
This method will notify on the current lock name, this notification will be caught bt all waiting instances.

At current version there is no need to lock on the String before using hte wait method

Parameters:
lockName - a lock String that should be the same on all instances of the code


Copyright © 16bytes Inc . All Rights Reserved.