public abstract class ServiceBaseImpl extends Object implements ServiceBase, Runnable
| Constructor and Description |
|---|
ServiceBaseImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addStats(ServiceStats serviceStats)
Adds supplementary service stats.
|
protected void |
closeSnoozeAlarm()
Closes the snooze alarm.
|
protected abstract ServiceStats |
createStats(StatsOwner statsOwner)
Creates a stats instance.
|
void |
fail()
Fails the service.
|
protected Optional<String> |
getLogID()
Gets the log ID.
|
protected ServiceActivatorBase |
getServiceActivatorBase()
Gets the service activator base owning this.
|
String |
getServiceName()
Gets the Service name.
|
ServiceStats |
getStats()
Gets the service stats.
|
protected Logger |
getThisLogger()
Gets the logger.
|
protected Thread |
getThread()
Gets the thread.
|
Optional<Timer> |
getTimer()
Gets the service timer.
|
protected Version |
getVersion()
Gets the version object.
|
protected void |
interrupt()
Interrupts the thread.
|
protected boolean |
isCurrentThread()
Asks if the service implementation thread is the current thread.
|
boolean |
isJMXRegistrationEnabled()
Asks if the JMX registration is enabled.
|
protected boolean |
isThreadStarted()
Asks if the thread has been started.
|
protected boolean |
join()
Waits for the thread to die.
|
protected void |
logStats(boolean intermediate)
Logs the stats.
|
protected void |
scheduleMidnightLogger()
Schedules the midnight logger.
|
protected void |
setLogID(Optional<String> logID)
Sets the log ID.
|
protected void |
setServiceActivatorBase(ServiceActivatorBase serviceActivatorBase)
Sets the service activator base.
|
void |
setServiceName(String serviceName)
Sets the service name.
|
protected boolean |
setUp()
Sets up the service thread.
|
void |
snooze(ElapsedTime snoozeTime)
Snoozes for the specified time.
|
void |
starting(Optional<ElapsedTime> waitHint)
Informs that the start is progressing.
|
protected void |
startThread()
Starts the thread.
|
protected void |
startTimer()
Starts the timer.
|
void |
stopping(Optional<ElapsedTime> waitHint)
Informs that the stop is progressing.
|
protected void |
stopTimer()
Stops the timer.
|
protected void |
tearDown()
Tears down what has been set up.
|
String |
toString() |
void |
uncaughtException(Thread thread,
Throwable throwable) |
protected void |
updateStats()
Allows a subclass to update the stats.
|
void |
wakeUp()
Wakes up all snoozers.
|
public final void addStats(ServiceStats serviceStats)
addStats in interface ServiceBaseserviceStats - The service stats.public void fail()
This is called by the service implementation or one of its children when an unexpected condition is detected. It may be overridden.
fail in interface ServiceBasepublic final String getServiceName()
getServiceName in interface ServiceBasepublic ServiceStats getStats()
getStats in interface ServiceBasepublic final Optional<Timer> getTimer()
getTimer in interface ServiceBasepublic boolean isJMXRegistrationEnabled()
isJMXRegistrationEnabled in interface ServiceBasepublic final void setServiceName(@Nonnull
String serviceName)
serviceName - The service name.public final void snooze(ElapsedTime snoozeTime) throws InterruptedException
Caution: calling this method while holding a lock object other than this instance may cause a stall.
snooze in interface ServiceBasesnoozeTime - The snooze time.InterruptedException - When interrupted.public final void starting(Optional<ElapsedTime> waitHint)
starting in interface ServiceBasewaitHint - An optional additional time in milliseconds.public final void stopping(Optional<ElapsedTime> waitHint)
stopping in interface ServiceBasewaitHint - Additional time in milliseconds.public String toString()
toString in class Objectpublic final void uncaughtException(Thread thread,
Throwable throwable)
uncaughtException in interface Thread.UncaughtExceptionHandlerpublic final void wakeUp()
wakeUp in interface ServiceBaseprotected final void closeSnoozeAlarm()
@Nonnull @CheckReturnValue protected abstract ServiceStats createStats(@Nonnull StatsOwner statsOwner)
statsOwner - The stats owner.@Nonnull @CheckReturnValue protected final Optional<String> getLogID()
@Nonnull @CheckReturnValue protected final ServiceActivatorBase getServiceActivatorBase()
@Nonnull @CheckReturnValue protected final Logger getThisLogger()
@Nonnull @CheckReturnValue protected Thread getThread()
@Nonnull @CheckReturnValue protected Version getVersion()
protected final void interrupt()
@CheckReturnValue protected final boolean isCurrentThread()
@CheckReturnValue protected final boolean isThreadStarted()
@CheckReturnValue protected final boolean join()
protected final void logStats(boolean intermediate)
intermediate - True means a final log.protected final void scheduleMidnightLogger()
This is used by service threads which are not set up to receive midnight events but still need to switch log files.
protected final void setLogID(@Nonnull
Optional<String> logID)
logID - The log ID.protected final void setServiceActivatorBase(@Nonnull
ServiceActivatorBase serviceActivatorBase)
serviceActivatorBase - The service activator base.@CheckReturnValue @OverridingMethodsMustInvokeSuper protected boolean setUp()
Overriding subclasses must call this with success before proceeding.
protected final void startThread()
protected final void startTimer()
protected final void stopTimer()
protected void tearDown()
protected void updateStats()
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.