Package org.apache.activemq.broker
Class LockableServiceSupport
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.broker.LockableServiceSupport
-
- All Implemented Interfaces:
BrokerServiceAware,Lockable,Service
- Direct Known Subclasses:
AbstractKahaDBStore,DataSourceServiceSupport,KahaDBPersistenceAdapter,MultiKahaDBPersistenceAdapter
public abstract class LockableServiceSupport extends ServiceSupport implements Lockable, BrokerServiceAware
Helper class for working with services that requires locking
-
-
Field Summary
Fields Modifier and Type Field Description protected BrokerServicebrokerServiceprotected ScheduledThreadPoolExecutorclockDaemon
-
Constructor Summary
Constructors Constructor Description LockableServiceSupport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BrokerServicegetBrokerService()LockergetLocker()longgetLockKeepAlivePeriod()ScheduledThreadPoolExecutorgetScheduledThreadPoolExecutor()abstract voidinit()Initialize resources before lockingbooleanisStopOnError()booleanisUseLock()protected voidkeepLockAlive()voidpostStop(ServiceStopper stopper)handle for various operations after stopping the service (like locking)voidpreStart()handle for various operations before starting the service (like locking)voidsetBrokerService(BrokerService brokerService)voidsetLocker(Locker locker)Set locker to be usedvoidsetLockKeepAlivePeriod(long lockKeepAlivePeriod)Period (in milliseconds) on whichLocker.keepAlive()should be checkedvoidsetScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor clockDaemon)voidsetStopOnError(boolean stopOnError)Stop the broker if the locker get an exception while processing lock.voidsetUseLock(boolean useLock)Turn locking on/off on the resourceprotected voidstopBroker()-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, doStart, doStop, isStarted, isStopped, isStopping, removeServiceListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.broker.Lockable
createDefaultLocker
-
-
-
-
Field Detail
-
clockDaemon
protected ScheduledThreadPoolExecutor clockDaemon
-
brokerService
protected BrokerService brokerService
-
-
Method Detail
-
init
public abstract void init() throws ExceptionInitialize resources before locking- Throws:
Exception
-
setUseLock
public void setUseLock(boolean useLock)
Description copied from interface:LockableTurn locking on/off on the resource- Specified by:
setUseLockin interfaceLockable
-
isUseLock
public boolean isUseLock()
-
setStopOnError
public void setStopOnError(boolean stopOnError)
Description copied from interface:LockableStop the broker if the locker get an exception while processing lock.- Specified by:
setStopOnErrorin interfaceLockable
-
isStopOnError
public boolean isStopOnError()
-
setLocker
public void setLocker(Locker locker) throws IOException
Description copied from interface:LockableSet locker to be used- Specified by:
setLockerin interfaceLockable- Throws:
IOException
-
getLocker
public Locker getLocker() throws IOException
- Throws:
IOException
-
setLockKeepAlivePeriod
public void setLockKeepAlivePeriod(long lockKeepAlivePeriod)
Description copied from interface:LockablePeriod (in milliseconds) on whichLocker.keepAlive()should be checked- Specified by:
setLockKeepAlivePeriodin interfaceLockable
-
getLockKeepAlivePeriod
public long getLockKeepAlivePeriod()
- Specified by:
getLockKeepAlivePeriodin interfaceLockable
-
preStart
public void preStart() throws ExceptionDescription copied from class:ServiceSupporthandle for various operations before starting the service (like locking)- Overrides:
preStartin classServiceSupport- Throws:
Exception
-
postStop
public void postStop(ServiceStopper stopper) throws Exception
Description copied from class:ServiceSupporthandle for various operations after stopping the service (like locking)- Overrides:
postStopin classServiceSupport- Throws:
Exception
-
keepLockAlive
protected void keepLockAlive()
-
stopBroker
protected void stopBroker()
-
getScheduledThreadPoolExecutor
public ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor()
-
setScheduledThreadPoolExecutor
public void setScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor clockDaemon)
-
setBrokerService
public void setBrokerService(BrokerService brokerService)
- Specified by:
setBrokerServicein interfaceBrokerServiceAware
-
getBrokerService
public BrokerService getBrokerService()
-
-