Module org.refcodes.servicebus
Package org.refcodes.servicebus
Class ServiceDirectoryImpl<S extends Service<?>,SCTX extends ServiceContext<S>>
java.lang.Object
org.refcodes.servicebus.ServiceDirectoryImpl<S,SCTX>
- Type Parameters:
S
- the generic typeSCTX
- the generic type
- All Implemented Interfaces:
ServiceDirectory<S,
,SCTX> ServiceLookup<S,
SCTX>
public class ServiceDirectoryImpl<S extends Service<?>,SCTX extends ServiceContext<S>>
extends Object
implements ServiceDirectory<S,SCTX>
The
ServiceDirectoryImpl
implements the ServiceDirectory
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addService
(ServiceDescriptor<S, SCTX> aServiceDescriptor) Registers a service to the service bus.Returns a collection containing theServiceDescriptor
instances known by theServiceLookup
.boolean
hasService
(ServiceDescriptor<S, SCTX> aServiceDescriptor) Determines whether the given service is known by the service bus by taking the service type and the service Meta-Data as criteria, not the service identity.void
removeService
(ServiceDescriptor<S, SCTX> aServiceDescriptor) Unregisters a service to the service bus.
-
Constructor Details
-
ServiceDirectoryImpl
public ServiceDirectoryImpl()
-
-
Method Details
-
getServiceDescriptors
Returns a collection containing theServiceDescriptor
instances known by theServiceLookup
.- Specified by:
getServiceDescriptors
in interfaceServiceLookup<S extends Service<?>,
SCTX extends ServiceContext<S>> - Returns:
- A collection containing the
ServiceDescriptor
instances known by theServiceLookup
.
-
hasService
Determines whether the given service is known by the service bus by taking the service type and the service Meta-Data as criteria, not the service identity. I.e. there must not be the same service twice on the service bus which can not be distinguished by its type and its Meta-Data (i.e. a matcher must be able to distinguish two services from each other).- Specified by:
hasService
in interfaceServiceLookup<S extends Service<?>,
SCTX extends ServiceContext<S>> - Parameters:
aServiceDescriptor
- the service descriptor- Returns:
- True in case the given service is known by the service bus.
-
addService
public void addService(ServiceDescriptor<S, SCTX> aServiceDescriptor) throws DuplicateServiceRuntimeExceptionRegisters a service to the service bus.- Specified by:
addService
in interfaceServiceDirectory<S extends Service<?>,
SCTX extends ServiceContext<S>> - Parameters:
aServiceDescriptor
- the service descriptor- Throws:
DuplicateServiceRuntimeException
- in case the service cannot be identified unambiguously by a matcher. A matcher declaration must be possible to identify the given service unambiguously. The service as being described by the service type and the service Meta-Data is already registered to the service bus.
-
removeService
public void removeService(ServiceDescriptor<S, SCTX> aServiceDescriptor) throws UnknownServiceRuntimeExceptionUnregisters a service to the service bus.- Specified by:
removeService
in interfaceServiceDirectory<S extends Service<?>,
SCTX extends ServiceContext<S>> - Parameters:
aServiceDescriptor
- the service descriptor- Throws:
UnknownServiceRuntimeException
- in case the service is not known.
-