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 java.lang.Object implements ServiceDirectory<S,SCTX>
TheServiceDirectoryImplimplements theServiceDirectory.
-
-
Constructor Summary
Constructors Constructor Description ServiceDirectoryImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddService(ServiceDescriptor<S,SCTX> aServiceDescriptor)Registers a service to the service bus.java.util.Set<ServiceDescriptor<S,SCTX>>getServiceDescriptors()Returns a collection containing theServiceDescriptorinstances known by theServiceLookup.booleanhasService(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.voidremoveService(ServiceDescriptor<S,SCTX> aServiceDescriptor)Unregisters a service to the service bus.
-
-
-
Method Detail
-
getServiceDescriptors
public java.util.Set<ServiceDescriptor<S,SCTX>> getServiceDescriptors()
Returns a collection containing theServiceDescriptorinstances known by theServiceLookup.- Specified by:
getServiceDescriptorsin interfaceServiceLookup<S extends Service<?>,SCTX extends ServiceContext<S>>- Returns:
- A collection containing the
ServiceDescriptorinstances known by theServiceLookup.
-
hasService
public 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. 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:
hasServicein 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 DuplicateServiceRuntimeException
Registers a service to the service bus.- Specified by:
addServicein 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 UnknownServiceRuntimeException
Unregisters a service to the service bus.- Specified by:
removeServicein interfaceServiceDirectory<S extends Service<?>,SCTX extends ServiceContext<S>>- Parameters:
aServiceDescriptor- the service descriptor- Throws:
UnknownServiceRuntimeException- in case the service is not known.
-
-