S
- the generic typeSCTX
- the generic typeorg.refcodes.mixin.Loggable
, ServiceBus<S>
public class ServiceBusImpl<S extends Service<?>,SCTX extends ServiceContext<S>> extends Object implements ServiceBus<S>, org.refcodes.mixin.Loggable
Constructor | Description |
---|---|
ServiceBusImpl(ServiceLookup<S,SCTX> aServiceLookup,
org.refcodes.component.ext.observer.ObservableLifeCycleStatusAutomaton aObservableLifecycleAutomaton) |
Constructs the subscriber part of the event bus.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
destroyServices() |
Destroy services.
|
boolean |
hasService(ServiceMatcher<S> aServiceMatcher) |
Determines whether the given
ServiceMatcher will result in a
single Service to be looked up. |
protected void |
initializeServices() |
Initialize services.
|
S |
lookupService(ServiceMatcher<S> aServiceMatcher) |
Looks for a service matching the given service descriptor and returns it
if found.
|
protected void |
onLifecycleEvent(org.refcodes.component.ext.observer.LifeCycleRequestEvent aEvent) |
This method is used to handle life-cycle events and inform the according
services of any life-cycle state changes.
|
protected void |
pauseServices() |
Pause services.
|
protected void |
registerLifecycleEventDispatcher(org.refcodes.component.ext.observer.ObservableLifeCycleStatusAutomaton aObservableLifecycleAutomaton) |
This method registers a life-cycle event listener which dispatches any
incoming life-cycle events to the according dispatcher method below.
|
protected void |
resumeServices() |
Resume services.
|
protected void |
startServices() |
Start services.
|
protected void |
stopServices() |
Stop services.
|
public ServiceBusImpl(ServiceLookup<S,SCTX> aServiceLookup, org.refcodes.component.ext.observer.ObservableLifeCycleStatusAutomaton aObservableLifecycleAutomaton)
aServiceLookup
- the service lookupaObservableLifecycleAutomaton
- the observable lifecycle automatonpublic S lookupService(ServiceMatcher<S> aServiceMatcher) throws NoMatchingServiceRuntimeException, AmbiguousServiceRuntimeException
lookupService
in interface ServiceBus<S extends Service<?>>
aServiceMatcher
- The ServiceMatcher
describing the service
for which to look for.ServiceConfigurationError
.AmbiguousServiceRuntimeException
- in case more than one
Service
matched the ServiceMatcher
.NoMatchingServiceRuntimeException
public boolean hasService(ServiceMatcher<S> aServiceMatcher)
ServiceMatcher
will result in a
single Service
to be looked up. I.e. the ServiceMatcher
must result in an unambiguous Service
to be identified.hasService
in interface ServiceBus<S extends Service<?>>
aServiceMatcher
- The ServiceMatcher
describing the
Service
for which to look for.Service
is matching the
matcher. Else false is returned (either more than one service was
identified or none service was identified).protected void registerLifecycleEventDispatcher(org.refcodes.component.ext.observer.ObservableLifeCycleStatusAutomaton aObservableLifecycleAutomaton)
aObservableLifecycleAutomaton
- the observable lifecycle automatonprotected void onLifecycleEvent(org.refcodes.component.ext.observer.LifeCycleRequestEvent aEvent)
registerLifecycleEventDispatcher(ObservableLifeCycleStatusAutomaton)
method to register a dispatcher for any life-cycle events from a provided
observable life-cycle instance.aEvent
- the eventprotected void initializeServices()
protected void startServices()
protected void pauseServices()
protected void resumeServices()
protected void stopServices()
protected void destroyServices()
Copyright © 2018. All rights reserved.