public class ServiceBusImpl<S extends Service<?>,SCTX extends ServiceContext<S>> extends Object implements ServiceBus<S>
Constructor and Description |
---|
ServiceBusImpl(ServiceLookup<S,SCTX> aServiceLookup,
org.refcodes.component.ext.observer.ObservableLifeCycleAutomaton aObservableLifecycleAutomaton)
Constructs the subscriber part of the event bus.
|
Modifier and Type | Method and Description |
---|---|
protected void |
destroyServices() |
boolean |
hasService(ServiceMatcher<S> aServiceMatcher)
Determines whether the given
ServiceMatcher will result in a
single Service to be looked up. |
protected void |
initializeServices() |
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.LifeCycleEvent.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() |
protected void |
registerLifecycleEventDispatcher(org.refcodes.component.ext.observer.ObservableLifeCycleAutomaton aObservableLifecycleAutomaton)
This method registers a life-cycle event listener which dispatches any
incoming life-cycle events to the
#onLifecycleEvent(LifecycleEvent) method of this class. |
protected void |
resumeServices() |
protected void |
startServices() |
protected void |
stopServices() |
public ServiceBusImpl(ServiceLookup<S,SCTX> aServiceLookup, org.refcodes.component.ext.observer.ObservableLifeCycleAutomaton aObservableLifecycleAutomaton)
aEventBus
- The event bus for subscribing and publishing events.public S lookupService(ServiceMatcher<S> aServiceMatcher) throws NoMatchingServiceRuntimeException, AmbiguousServiceRuntimeException
ServiceBus
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)
ServiceBus
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.ObservableLifeCycleAutomaton aObservableLifecycleAutomaton)
#onLifecycleEvent(LifecycleEvent)
method of this class.aObservableLifecycleAutomaton
- protected void onLifecycleEvent(org.refcodes.component.ext.observer.LifeCycleEvent.LifeCycleRequestEvent aEvent)
#registerLifecycleEventDispatcher(ObservableLifecycle)
method to
register a dispatcher for any life-cycle events from a provided
observable life-cycle instance.aEvent
- protected void initializeServices()
protected void startServices()
protected void pauseServices()
protected void resumeServices()
protected void stopServices()
protected void destroyServices()
Copyright © 2017. All rights reserved.