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 BrokerService
brokerService
protected ScheduledThreadPoolExecutor
clockDaemon
-
Constructor Summary
Constructors Constructor Description LockableServiceSupport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BrokerService
getBrokerService()
Locker
getLocker()
long
getLockKeepAlivePeriod()
ScheduledThreadPoolExecutor
getScheduledThreadPoolExecutor()
abstract void
init()
Initialize resources before lockingboolean
isStopOnError()
boolean
isUseLock()
protected void
keepLockAlive()
void
postStop(ServiceStopper stopper)
handle for various operations after stopping the service (like locking)void
preStart()
handle for various operations before starting the service (like locking)void
setBrokerService(BrokerService brokerService)
void
setLocker(Locker locker)
Set locker to be usedvoid
setLockKeepAlivePeriod(long lockKeepAlivePeriod)
Period (in milliseconds) on whichLocker.keepAlive()
should be checkedvoid
setScheduledThreadPoolExecutor(ScheduledThreadPoolExecutor clockDaemon)
void
setStopOnError(boolean stopOnError)
Stop the broker if the locker get an exception while processing lock.void
setUseLock(boolean useLock)
Turn locking on/off on the resourceprotected void
stopBroker()
-
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 Exception
Initialize resources before locking- Throws:
Exception
-
setUseLock
public void setUseLock(boolean useLock)
Description copied from interface:Lockable
Turn locking on/off on the resource- Specified by:
setUseLock
in interfaceLockable
-
isUseLock
public boolean isUseLock()
-
setStopOnError
public void setStopOnError(boolean stopOnError)
Description copied from interface:Lockable
Stop the broker if the locker get an exception while processing lock.- Specified by:
setStopOnError
in interfaceLockable
-
isStopOnError
public boolean isStopOnError()
-
setLocker
public void setLocker(Locker locker) throws IOException
Description copied from interface:Lockable
Set locker to be used- Specified by:
setLocker
in interfaceLockable
- Throws:
IOException
-
getLocker
public Locker getLocker() throws IOException
- Throws:
IOException
-
setLockKeepAlivePeriod
public void setLockKeepAlivePeriod(long lockKeepAlivePeriod)
Description copied from interface:Lockable
Period (in milliseconds) on whichLocker.keepAlive()
should be checked- Specified by:
setLockKeepAlivePeriod
in interfaceLockable
-
getLockKeepAlivePeriod
public long getLockKeepAlivePeriod()
- Specified by:
getLockKeepAlivePeriod
in interfaceLockable
-
preStart
public void preStart() throws Exception
Description copied from class:ServiceSupport
handle for various operations before starting the service (like locking)- Overrides:
preStart
in classServiceSupport
- Throws:
Exception
-
postStop
public void postStop(ServiceStopper stopper) throws Exception
Description copied from class:ServiceSupport
handle for various operations after stopping the service (like locking)- Overrides:
postStop
in 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:
setBrokerService
in interfaceBrokerServiceAware
-
getBrokerService
public BrokerService getBrokerService()
-
-