public abstract class ServiceAppImpl extends Object implements ServiceApp
This abstract class supplies a minimal implementation for the service application interface. It also supplies help methods (protected) to its subclasses.
| Modifier and Type | Field and Description |
|---|---|
static String |
SERVICE_APP_PROPERTIES
The properties for the service application.
|
| Constructor and Description |
|---|
ServiceAppImpl() |
| Modifier and Type | Method and Description |
|---|---|
ServiceStats |
createStats(StatsOwner statsOwner)
Creates a stats instance.
|
void |
fail()
Fails.
|
Config |
getConfig()
Gets the service config.
|
KeyedGroups |
getConfigProperties()
Gets the config properties.
|
File |
getDataDir()
Gets the data directory.
|
long |
getJoinTimeout()
Gets the join timeout.
|
KeyedGroups |
getProperties()
Gets the application specific properties.
|
Service |
getService()
Gets the service holding this application.
|
UUID |
getSourceUUID()
Gets the source UUID.
|
protected Logger |
getThisLogger()
Gets the logger for this instance.
|
Optional<Timer> |
getTimer()
Gets the service timer.
|
boolean |
onAlert(Alert alert)
Called when a alert has been received.
|
boolean |
onEvent(Event event)
Called when a event has been received.
|
protected void |
onServiceNotAvailableException(ServiceNotAvailableException exception)
Called on service not available exception.
|
void |
onServicesNotReady()
Called when some services are not ready.
|
void |
onServicesReady()
Called when the pending actions processing is completed.
|
boolean |
onSignal(Signal signal)
Called when a signal has been received.
|
boolean |
setUp(Service service)
Sets up the application.
|
void |
start()
Starts the application.
|
void |
stop()
Stops the application.
|
void |
tearDown()
Tears down the application.
|
public static final String SERVICE_APP_PROPERTIES
public ServiceStats createStats(StatsOwner statsOwner)
createStats in interface ServiceAppstatsOwner - The stats owner.public final void fail()
@Nonnull @CheckReturnValue public final Config getConfig()
@Nonnull @CheckReturnValue public KeyedGroups getConfigProperties()
@Nonnull @CheckReturnValue public final File getDataDir()
@CheckReturnValue public long getJoinTimeout()
@Nonnull @CheckReturnValue public KeyedGroups getProperties()
These properties are contained in the non validated group '"service.app.properties"'.
Since this method is usually called during the set up of subclasses, they must call the set up of their superclass first.
@Nonnull @CheckReturnValue public Service getService()
@Nonnull @CheckReturnValue public UUID getSourceUUID()
@Nonnull @CheckReturnValue public Optional<Timer> getTimer()
public boolean onAlert(Alert alert)
Caution: this is called while synchronized on the service.
onAlert in interface ServiceAppalert - The alert.public boolean onEvent(Event event)
Caution: this is called while synchronized on the service.
onEvent in interface ServiceAppevent - The event.public void onServicesNotReady()
This is called by the pending actions processing when it not known if all registered services are ready. This may be used by a service thread to trigger some state refresh when the pending actions processing is completed; at that time, all the registered services will be ready.
onServicesNotReady in interface ServiceApppublic void onServicesReady()
onServicesReady in interface ServiceApppublic boolean onSignal(Signal signal)
Caution: this is called while synchronized on the service.
onSignal in interface ServiceAppsignal - The signal.public boolean setUp(Service service)
Overidden as needed.
Called by the framework and by overriding classes at the beginning of the override.
setUp in interface ServiceAppservice - The service holding this application.public void start()
Overidden as needed by the application.
Called by the framework.
Should return only when the application is started.
start in interface ServiceApppublic void stop()
Overidden as needed by the application.
Called by the framework.
stop in interface ServiceApppublic void tearDown()
Overidden as needed by the application.
Called by the framework and by overriding classes at the end of the override.
tearDown in interface ServiceApp@Nonnull @CheckReturnValue protected final Logger getThisLogger()
protected void onServiceNotAvailableException(@Nonnull
ServiceNotAvailableException exception)
exception - The service not available exception.Copyright © 2003-2019 Serge Brisson. All Rights Reserved.