net.sf.sasl.distributed.lock.impl
Class LockSessionFactory

java.lang.Object
  extended by net.sf.sasl.distributed.lock.impl.LockSessionFactory
All Implemented Interfaces:
ILockSessionFactory, org.springframework.beans.factory.DisposableBean

public class LockSessionFactory
extends Object
implements ILockSessionFactory, org.springframework.beans.factory.DisposableBean

Lock session factory that creates lock session of type DefaultLockSession. Please see the documentation of DefaultLockSession how this lock session works.

Since:
0.0.1 (sasl-distributed-lock-library)
Author:
Philipp Förmer

Constructor Summary
LockSessionFactory()
           
 
Method Summary
 void destroy()
          Will release all associated resources with the factory, which also includes that all thread shared lock sessions will be released.
 ILockSession getActiveThreadSharedSession(boolean allowCreate)
          Returns an active lock session for the current thread, if there exists one (a call to getActiveThreadSharedSession(true) was done before).
 ILockProvider getLockProvider()
           
 boolean isDoThreadCheck()
           
 boolean isStrictLockSequences()
           
 ILockSession openNewLockSession()
          Creates and configures a fresh new lock session and returns it.
 void release()
          Releases the lock session factory.
protected  void removeFromCache(DefaultLockSession lockSession)
          Removes the lock session from the thread shared lock session cache.
 void setDoThreadCheck(boolean doThreadCheck)
          Sets whether thread access check should be done for created lock sessions or not.
 void setLockProvider(ILockProvider lockProvider)
          Sets the lock provider of which created lock sessions will acquire, lock and unlock locks.
 void setStrictLockSequences(boolean strictLockSequences)
          Sets whether strict lock sequence mode should be enabled for created lock sessions or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockSessionFactory

public LockSessionFactory()
Method Detail

isDoThreadCheck

public boolean isDoThreadCheck()
Returns:
true or false.
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
setDoThreadCheck(boolean)

setDoThreadCheck

public void setDoThreadCheck(boolean doThreadCheck)
Sets whether thread access check should be done for created lock sessions or not. Per default thread access check is enabled.

Parameters:
doThreadCheck - true or false.
Since:
0.0.1 (sasl-distributed-lock-library)

isStrictLockSequences

public boolean isStrictLockSequences()
Returns:
true or false.
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
setStrictLockSequences(boolean)

setStrictLockSequences

public void setStrictLockSequences(boolean strictLockSequences)
Sets whether strict lock sequence mode should be enabled for created lock sessions or not. Per default strict lock sequence mode is enabled.

Parameters:
strictLockSequences - true or false.
Since:
0.0.1 (sasl-distributed-lock-library)

getLockProvider

public ILockProvider getLockProvider()
Returns:
null or non null.
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
setLockProvider(ILockProvider)

setLockProvider

public void setLockProvider(ILockProvider lockProvider)
                     throws IllegalArgumentException
Sets the lock provider of which created lock sessions will acquire, lock and unlock locks.

Parameters:
lockProvider - non null
Throws:
IllegalArgumentException - if lockProvider is null.
Since:
0.0.1 (sasl-distributed-lock-library)

getActiveThreadSharedSession

public ILockSession getActiveThreadSharedSession(boolean allowCreate)
Description copied from interface: ILockSessionFactory
Returns an active lock session for the current thread, if there exists one (a call to getActiveThreadSharedSession(true) was done before). If there exists no active lock session and allowCreate is true, than a new lock session will be created for the thread and returned. Else null will be returned.

Specified by:
getActiveThreadSharedSession in interface ILockSessionFactory
Parameters:
allowCreate - true or false.
Returns:
null or non null
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
ILockSessionFactory.getActiveThreadSharedSession(boolean)

removeFromCache

protected void removeFromCache(DefaultLockSession lockSession)
Removes the lock session from the thread shared lock session cache.

Parameters:
lockSession - non null
Since:
0.0.1 (sasl-distributed-lock-library)

openNewLockSession

public ILockSession openNewLockSession()
Description copied from interface: ILockSessionFactory
Creates and configures a fresh new lock session and returns it.

Specified by:
openNewLockSession in interface ILockSessionFactory
Returns:
non null
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
ILockSessionFactory.openNewLockSession()

release

public void release()
Description copied from interface: ILockSessionFactory
Releases the lock session factory. All critical acquired resources by the lock sessions, for example held lock sessions, should get released immediately.

Specified by:
release in interface ILockSessionFactory
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
ILockSessionFactory.release()

destroy

public void destroy()
             throws Exception
Will release all associated resources with the factory, which also includes that all thread shared lock sessions will be released. The caller should make sure that the thread shared sessions are not anymore under use. A destroyed factory could never be used again.

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception
Since:
0.0.1 (sasl-distributed-lock-library)
See Also:
DisposableBean.destroy()


Copyright © 2010. All Rights Reserved.