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,org.apache.activemq.Service
public abstract class LockableServiceSupport extends org.apache.activemq.util.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(org.apache.activemq.util.ServiceStopper stopper)voidpreStart()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 Exception- Overrides:
preStartin classorg.apache.activemq.util.ServiceSupport- Throws:
Exception
-
postStop
public void postStop(org.apache.activemq.util.ServiceStopper stopper) throws Exception- Overrides:
postStopin classorg.apache.activemq.util.ServiceSupport- 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()
-
-