public class ServiceBusImpl extends BaseLifecycle implements ServiceBus, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Constructor and Description |
---|
ServiceBusImpl() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
destroy() |
protected Set<RemoteService> |
filterByApplicationId(String applicationId,
Set<RemoteService> remoteServices) |
List<Endpoint> |
getAllEndpoints()
Returns an unmodifiable list of all available and online endpoints of which the service bus
is aware, including both local and remote endpoints.
|
Endpoint |
getConfiguredEndpoint(ServiceConfiguration serviceConfiguration)
Returns the endpoint matching the given service configuration, if one exists.
|
Endpoint |
getEndpoint(QName serviceName)
Returns an available endpoint for the service with the given name.
|
Endpoint |
getEndpoint(QName serviceName,
String applicationId)
Returns an available endpoint for the service with the given name which is hosted by the
application with the given application id.
|
List<Endpoint> |
getEndpoints(QName serviceName)
Returns an unmodifiable list of accessible endpoints that are available to the service bus
with the given service name.
|
List<Endpoint> |
getEndpoints(QName serviceName,
String applicationId)
Returns an unmodifiable list of accessible endpoints that are available to the service bus
with the given service name for the given application id.
|
String |
getInstanceId()
Returns the instance ID which identifies this client application to the service bus.
|
Endpoint |
getLocalEndpoint(QName serviceName)
Returns the endpoint for the service with the given name that was published by this service
bus client.
|
Map<QName,Endpoint> |
getLocalEndpoints()
Returns an unmodifiable list of all services that have been published by this service bus
client.
|
List<Endpoint> |
getRemoteEndpoints(QName serviceName)
Returns an unmodifiable list of remotely accessible endpoints that are available in the
service registry with the given service name.
|
Object |
getService(QName serviceName)
Returns a proxy to the service with the given name.
|
Object |
getService(QName serviceName,
String applicationId)
Returns a proxy to the service with the given name which is hosted by the application with
the given application id.
|
protected boolean |
isDevMode() |
protected void |
logCompleteServiceDiff(CompleteServiceDiff serviceDiff) |
protected void |
processLocalServiceDiff(LocalServicesDiff localServicesDiff) |
protected void |
processRemoteServiceDiff(RemoteServicesDiff remoteServicesDiff) |
ServiceConfiguration |
publishService(ServiceDefinition serviceDefinition,
boolean synchronize)
Publish a service with the given ServiceDefinition to the service bus.
|
List<ServiceConfiguration> |
publishServices(List<ServiceDefinition> serviceDefinitions,
boolean synchronize)
Functions as per
ServiceBus.publishService(ServiceDefinition, boolean) but allows for multiple
services to be published to the bus in a single operation. |
protected void |
rebuildLocalServiceEndpointAfterPublishing(ServiceEndpoint publishedService) |
protected ServiceEndpoint |
rebuildServiceEndpointForUpdate(ServiceEndpoint originalEndpoint,
ServiceInfo registryServiceInfo) |
boolean |
removeService(QName serviceName,
boolean synchronize)
Removes the service from the service bus and the service registry with the given service
name.
|
List<Boolean> |
removeServices(List<QName> serviceNames,
boolean synchronize)
Functions as per
ServiceBus.removeService(QName, boolean) but allows for multiple services to
be removed from the bus in a single operation. |
void |
setDiffCalculator(ServiceRegistryDiffCalculator diffCalculator) |
void |
setInstanceId(String instanceId) |
void |
setScheduledPool(KSBScheduledPool scheduledPool) |
void |
setServiceExportManager(ServiceExportManager serviceExportManager) |
void |
setServiceRegistry(ServiceRegistry serviceRegistry) |
void |
start() |
protected void |
startSynchronizationThread() |
protected void |
stopSynchronizationThread() |
void |
synchronize()
Synchronizes the current client's service bus with the central service registry.
|
protected void |
synchronizeAndProcess(org.kuali.rice.ksb.impl.bus.ServiceBusImpl.SyncProcessor processor) |
void |
synchronizeLocalServices()
Synchronizes information about the services this client is publishing with the central
service registry.
|
void |
synchronizeRemoteServices()
Fetches information about the current state of the remote services available in the registry
and the synchronizes the current client's service bus state.
|
isStarted, setStarted, stop
public ServiceBusImpl()
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public void start() throws Exception
start
in interface Lifecycle
start
in class BaseLifecycle
Exception
protected boolean isDevMode()
protected void startSynchronizationThread()
public void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
Exception
protected void stopSynchronizationThread()
public String getInstanceId()
ServiceBus
getInstanceId
in interface ServiceBus
public void setInstanceId(String instanceId)
public List<Endpoint> getEndpoints(QName serviceName)
ServiceBus
getEndpoints
in interface ServiceBus
public List<Endpoint> getEndpoints(QName serviceName, String applicationId)
ServiceBus
getEndpoints
in interface ServiceBus
serviceName
- the name of the service for which to locate an available endpointapplicationId
- the id of the application for which to locate an available endpoint for
the given service namepublic List<Endpoint> getRemoteEndpoints(QName serviceName)
ServiceBus
If the service bus client has also deployed a service with this name, a remoted endpoint to this service will likely also be included in this list assuming that endpoint has already been synchronized with the registry.
In most cases, it is preferable to use ServiceBus.getEndpoints(QName)
instead of this method.
Because it will preferably return a local endpoint reference for a given service endpoint if
one is available.
getRemoteEndpoints
in interface ServiceBus
public Endpoint getLocalEndpoint(QName serviceName)
ServiceBus
getLocalEndpoint
in interface ServiceBus
serviceName
- the name of the service represented by the local endpointpublic Map<QName,Endpoint> getLocalEndpoints()
ServiceBus
getLocalEndpoints
in interface ServiceBus
public List<Endpoint> getAllEndpoints()
ServiceBus
getAllEndpoints
in interface ServiceBus
public Endpoint getEndpoint(QName serviceName)
ServiceBus
Based on the nature of this method, if there is more than one endpoint available for the
given name, multiple invocations of this method with the same service name may return
different Endpoint
instances each time.
getEndpoint
in interface ServiceBus
serviceName
- the name of the service for which to locate an available endpointpublic Endpoint getEndpoint(QName serviceName, String applicationId)
ServiceBus
ServiceBus.getEndpoint(QName)
with the exception that it will only consider endpoints with the
given application id.
Invoking this method with a null or blank value for applicationId
is equivalent to
invoking ServiceBus.getEndpoint(QName)
.
getEndpoint
in interface ServiceBus
serviceName
- the name of the service for which to locate an available endpointapplicationId
- the id of the application for which to locate an available endpoint for
the given service nameprotected Set<RemoteService> filterByApplicationId(String applicationId, Set<RemoteService> remoteServices)
public Endpoint getConfiguredEndpoint(ServiceConfiguration serviceConfiguration)
ServiceBus
getConfiguredEndpoint
in interface ServiceBus
serviceConfiguration
- the service configuration by which to lookup up the endpointpublic Object getService(QName serviceName)
ServiceBus
This proxy should additionally be thread-safe.
This method is equivalent to invoking #getEndpoint(QName).getService()
.
getService
in interface ServiceBus
serviceName
- the name of the service for which to locate an available proxypublic Object getService(QName serviceName, String applicationId)
ServiceBus
ServiceBus.getService(QName)
with the exception that it will only consider endpoints with the given application id.
Invoking this method with a null or blank value for applicationId
is equivalent to
invoking ServiceBus.getService(QName)
. This method is also equivalent to invoking
#getEndpoint(QName, String).getService()
.
getService
in interface ServiceBus
serviceName
- the name of the service for which to locate an available proxyapplicationId
- the id of the application for which to locate an available proxy for the
given service namepublic ServiceConfiguration publishService(ServiceDefinition serviceDefinition, boolean synchronize)
ServiceBus
The method also provides the ability for the service bus to immediately synchronize with the
service registry after registering the service if synchronize
is set to true
.
publishService
in interface ServiceBus
serviceDefinition
- the definition of the service to publish, must not be nullsynchronize
- indicates whether or not this service bus client should immediately
synchronize it's changes with the registry after registering the service.ServiceBus.synchronize()
public List<ServiceConfiguration> publishServices(List<ServiceDefinition> serviceDefinitions, boolean synchronize)
ServiceBus
ServiceBus.publishService(ServiceDefinition, boolean)
but allows for multiple
services to be published to the bus in a single operation. If the given list of service
definitions is empty then this method will do nothing (including skipping synchronization
with the registry if that was requested).publishServices
in interface ServiceBus
serviceDefinitions
- the list of definition for the services to publish, must not be
nullsynchronize
- indicates whether or not this service bus client should immediately
synchronize it's changes with the registry after registering the services.ServiceBus.publishService(ServiceDefinition, boolean)
,
ServiceBus.synchronize()
public boolean removeService(QName serviceName, boolean synchronize)
ServiceBus
This method also provides the ability for the service bus to immediately synchronize with the
service registry after removing the service if synchronize
is set to true
. If
the service is not located and successfully removed, however, the sychronization will not
run.
removeService
in interface ServiceBus
serviceName
- the name of the service to removesynchronize
- indicates whether or not this service bus client should immediately
synchronize after removing the serviceServiceBus.synchronize()
public List<Boolean> removeServices(List<QName> serviceNames, boolean synchronize)
ServiceBus
ServiceBus.removeService(QName, boolean)
but allows for multiple services to
be removed from the bus in a single operation. If the given list of service names is empty
then this method will do nothing (including skipping synchronization with the registry if
that was requested).
If the list returned from the method contains only false responses (meaning that no services were removed) this method will skip synchronization even if it is requested.
removeServices
in interface ServiceBus
serviceNames
- the list of names for the services to remove, must not be nullsynchronize
- indicates whether or not this service bus client should immediately
synchronize it's changes with the registry after removing the services.ServiceBus.removeService(QName, boolean)
,
ServiceBus.synchronize()
protected void synchronizeAndProcess(org.kuali.rice.ksb.impl.bus.ServiceBusImpl.SyncProcessor processor)
public void synchronize()
ServiceBus
Invoking this method is equivalent to invoking ServiceBus.synchronizeLocalServices()
and
ServiceBus.synchronizeRemoteServices()
in either order. However, the semantics vary slightly
as this method should attempt to invoke them as an atomic operation.
synchronize
in interface ServiceBus
public void synchronizeRemoteServices()
ServiceBus
synchronizeRemoteServices
in interface ServiceBus
public void synchronizeLocalServices()
ServiceBus
synchronizeLocalServices
in interface ServiceBus
protected void logCompleteServiceDiff(CompleteServiceDiff serviceDiff)
protected void processRemoteServiceDiff(RemoteServicesDiff remoteServicesDiff)
protected void processLocalServiceDiff(LocalServicesDiff localServicesDiff)
protected ServiceEndpoint rebuildServiceEndpointForUpdate(ServiceEndpoint originalEndpoint, ServiceInfo registryServiceInfo)
protected void rebuildLocalServiceEndpointAfterPublishing(ServiceEndpoint publishedService)
public void setServiceRegistry(ServiceRegistry serviceRegistry)
public void setDiffCalculator(ServiceRegistryDiffCalculator diffCalculator)
public void setServiceExportManager(ServiceExportManager serviceExportManager)
public void setScheduledPool(KSBScheduledPool scheduledPool)
Copyright © 2005–2015 The Kuali Foundation. All rights reserved.