org.universAAL.middleware.service.impl
Class ServiceBusImpl

Package class diagram package ServiceBusImpl
java.lang.Object
  extended by org.universAAL.middleware.bus.model.AbstractBus
      extended by org.universAAL.middleware.service.impl.ServiceBusImpl
All Implemented Interfaces:
Broker, MessageListener, ServiceBus

public class ServiceBusImpl
extends AbstractBus
implements ServiceBus

Author:
mtazari - Saied Tazari

Field Summary
 
Fields inherited from class org.universAAL.middleware.bus.model.AbstractBus
aalSpaceManager, busStrategy, communicationModule, context, registry
 
Fields inherited from interface org.universAAL.middleware.service.ServiceBus
LOG_MATCHING_END, LOG_MATCHING_MISMATCH, LOG_MATCHING_MISMATCH_CODE, LOG_MATCHING_MISMATCH_DETAILS, LOG_MATCHING_NOSUCCESS, LOG_MATCHING_PROFILE, LOG_MATCHING_PROFILES_END, LOG_MATCHING_PROVIDER_END, LOG_MATCHING_START, LOG_MATCHING_SUCCESS, uAAL_SERVICE_BUS_MODULE_CONTEXT
 
Method Summary
 void addAvailabilitySubscription(String callerID, AvailabilitySubscriber subscriber, ServiceRequest request)
          Adds an availability subscription, in other words a listener, to receive events about the availability of services matching the given request.
 void addNewServiceProfiles(String calleeID, ServiceProfile[] realizedServices)
          Registers (advertises) new services (by providing descriptions of them) that will be provided by the ServiceCalee with the specified ID.
 void assessContentSerialization(Resource content)
           
 void brokerReply(String calleeID, BusMessage response)
          Can be used by ServiceCallees to send a response to the bus which will be delivered to the caller who initiated the initial request.
 void brokerRequest(String callerID, BusMessage request)
          Can be used by ServiceCallers to send a request to the bus.
protected  BusStrategy createBusStrategy(CommunicationModule commModule)
           
 ServiceProfile[] getAllServices(String callerID)
          A method used to retrieve the descriptions of all services advertised on the service bus.
 HashMap getMatchingServices(String s)
          Get all service profiles that describe services of the given service class.
 ServiceProfile[] getMatchingServices(String callerID, Service s)
          Get all service profiles that describe services that match the given template in terms of "query by example".
 ServiceProfile[] getMatchingServices(String callerID, String s)
          Get all service profiles that describe services of the given service class.
 ServiceProfile[] getMatchingServices(String callerID, String[] keywords)
          This version of the method accepts simple keyword-based queries about registered services.
static ModuleContext getModuleContext()
           
static Object[] getServiceBusFetchParams()
           
 void handleSendError(ChannelMessage message, CommunicationConnectorException e)
          Callback for error handling
 void removeAvailabilitySubscription(String callerID, AvailabilitySubscriber subscriber, String requestURI)
          Removes an availability subscription from the bus, which was previously added using addAvailabilitySubscription method.
 void removeMatchingProfiles(String calleeID, ServiceProfile[] realizedServices)
          Removes specified service profiles that were previously registered by the ServiceCalee with the specified ID.
static void startModule(Container c, ModuleContext mc, Object[] serviceBusShareParams, Object[] serviceBusFetchParams)
           
static void stopModule()
           
 void unregister(String memberID, BusMember m)
          Unregisters bus member from the bus (if the bus member with given ID exists).
 void unregister(String calleeID, ServiceCallee callee)
          Unregisters a service callee from the bus.
 void unregister(String callerID, ServiceCaller caller)
          Unregisters a service caller from the bus.
 
Methods inherited from class org.universAAL.middleware.bus.model.AbstractBus
addRegistryListener, brokerMessage, createRegistry, dispose, getBrokerName, getBusMember, getBusMemberID, getBusMembers, getBusMembersByID, getCurrentNumberOfPeers, getPeerCard, getPeerFromBusResourceURI, getURI, init, initBrokerage, isBusResourceURI, isValidMember, messageReceived, register, removeRegistryListener, unmarshall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getServiceBusFetchParams

public static Object[] getServiceBusFetchParams()

assessContentSerialization

public void assessContentSerialization(Resource content)

startModule

public static void startModule(Container c,
                               ModuleContext mc,
                               Object[] serviceBusShareParams,
                               Object[] serviceBusFetchParams)

stopModule

public static void stopModule()

getModuleContext

public static ModuleContext getModuleContext()

addAvailabilitySubscription

public void addAvailabilitySubscription(String callerID,
                                        AvailabilitySubscriber subscriber,
                                        ServiceRequest request)
Description copied from interface: ServiceBus
Adds an availability subscription, in other words a listener, to receive events about the availability of services matching the given request.

Specified by:
addAvailabilitySubscription in interface ServiceBus
Parameters:
callerID - the ID of the caller that is registering a subscriber.
subscriber - the object which will be notified when matching services are advertised or removed from the service bus.
request - the request to which newly registered or unregistered services must match in order to notify the subscriber about the corresponding events.
See Also:
ServiceBus.addAvailabilitySubscription(String, AvailabilitySubscriber, ServiceRequest)

addNewServiceProfiles

public void addNewServiceProfiles(String calleeID,
                                  ServiceProfile[] realizedServices)
Description copied from interface: ServiceBus
Registers (advertises) new services (by providing descriptions of them) that will be provided by the ServiceCalee with the specified ID.

Specified by:
addNewServiceProfiles in interface ServiceBus
Parameters:
calleeID - the ID of the ServiceCalee that is advertising new services on the service bus.
realizedServices - the description of the new services in terms of an array of service profiles.
See Also:
ServiceBus.addNewServiceProfiles(String, ServiceProfile[])

getAllServices

public ServiceProfile[] getAllServices(String callerID)
Description copied from interface: ServiceBus
A method used to retrieve the descriptions of all services advertised on the service bus.

Specified by:
getAllServices in interface ServiceBus
Parameters:
callerID - the ID of the caller that is asking the service bus.
Returns:
descriptions of all registered services in terms of an array of service profiles.
See Also:
ServiceBus.getAllServices(String)

getMatchingServices

public ServiceProfile[] getMatchingServices(String callerID,
                                            Service s)
Description copied from interface: ServiceBus
Get all service profiles that describe services that match the given template in terms of "query by example". This version of the method makes it possible to make more specific queries by specifying restrictions for certain properties of services.

Specified by:
getMatchingServices in interface ServiceBus
Parameters:
callerID - the ID of the caller that is asking the service bus.
s - the template to be used for making a "query by example"..
Returns:
profiles of services registered with the service bus that match the given template, or null if no such service has been registered.
See Also:
ServiceBus.getMatchingServices(String, Service)

getMatchingServices

public ServiceProfile[] getMatchingServices(String callerID,
                                            String s)
Description copied from interface: ServiceBus
Get all service profiles that describe services of the given service class. This version of the method makes it easier to make a simple query of all instances of a named service class by specifying its URI.

Specified by:
getMatchingServices in interface ServiceBus
Parameters:
callerID - the ID of the caller that is asking the service bus.
s - the URI of the desired service class.
Returns:
profiles of services registered with the service bus that are instances of the given service class, or null if no such service has been registered.
See Also:
ServiceBus#getMatchingService(String, String)

getMatchingServices

public HashMap getMatchingServices(String s)
Description copied from interface: ServiceBus
Get all service profiles that describe services of the given service class. This version of the method makes it easier to make a simple query of all instances of a named service class by specifying its URI.

Specified by:
getMatchingServices in interface ServiceBus
Parameters:
s - the URI of the desired service class.
Returns:
Map containing as a key calleeID which registered ServiceProfiles in the service bus that are instances of the given service class. Returned profiles are stored in value part of map in a List.
See Also:
ServiceBus#getMatchingService(String)

getMatchingServices

public ServiceProfile[] getMatchingServices(String callerID,
                                            String[] keywords)
Description copied from interface: ServiceBus
This version of the method accepts simple keyword-based queries about registered services. The given keywords are checked against all names and textual descriptions used in the service profiles. A match is there only if all the given keywords have at least one occurrence.

Specified by:
getMatchingServices in interface ServiceBus
Parameters:
callerID - the ID of the caller that is asking the service bus.
keywords - the set of keywords to be used for textual match.
Returns:
the profiles of the matched services, or null if no such service is available.
See Also:
ServiceBus.getMatchingServices(String, String[])

removeAvailabilitySubscription

public void removeAvailabilitySubscription(String callerID,
                                           AvailabilitySubscriber subscriber,
                                           String requestURI)
Description copied from interface: ServiceBus
Removes an availability subscription from the bus, which was previously added using addAvailabilitySubscription method.

Specified by:
removeAvailabilitySubscription in interface ServiceBus
Parameters:
callerID - the ID of the caller that owns the listener
subscriber - the listeners registered by the caller
requestURI - the URI of the request used previously for subscription
See Also:
ServiceBus.removeAvailabilitySubscription(String, AvailabilitySubscriber, String)

removeMatchingProfiles

public void removeMatchingProfiles(String calleeID,
                                   ServiceProfile[] realizedServices)
Description copied from interface: ServiceBus
Removes specified service profiles that were previously registered by the ServiceCalee with the specified ID.

Specified by:
removeMatchingProfiles in interface ServiceBus
Parameters:
calleeID - the ID of the ServiceCalee that owns the service profiles.
realizedServices - the service profiles to be removed.
See Also:
ServiceBus#removeMatchingRegParams(String, ServiceProfile[])

brokerReply

public void brokerReply(String calleeID,
                        BusMessage response)
Description copied from interface: ServiceBus
Can be used by ServiceCallees to send a response to the bus which will be delivered to the caller who initiated the initial request.

Specified by:
brokerReply in interface ServiceBus
Parameters:
calleeID - the ID of the service callee which processed the request.
response - the actual response message.
See Also:
AbstractBus.brokerMessage(String, BusMessage)

brokerRequest

public void brokerRequest(String callerID,
                          BusMessage request)
Description copied from interface: ServiceBus
Can be used by ServiceCallers to send a request to the bus. The bus will then try to find matching services using the set of registered service profiles; for each match, the provider ServiceCallee will be asked by the bus to invoke the corresponding service utility and inform the bus about the results by calling ServiceBus.brokerReply(String, BusMessage). The bus will then inform the original requester (the ServiceCaller that has called this method) about the result.

Specified by:
brokerRequest in interface ServiceBus
Parameters:
callerID - the ID of the caller that is sending the request.
request - the actual request message.
See Also:
AbstractBus.brokerMessage(String, BusMessage)

unregister

public void unregister(String calleeID,
                       ServiceCallee callee)
Description copied from interface: ServiceBus
Unregisters a service callee from the bus.

Specified by:
unregister in interface ServiceBus
Parameters:
calleeID - the ID of the callee to be unregistered.
callee - the ServiceCallee object to be unregistered.
See Also:
ServiceBus.unregister(String, ServiceCallee)

unregister

public void unregister(String callerID,
                       ServiceCaller caller)
Description copied from interface: ServiceBus
Unregisters a service caller from the bus.

Specified by:
unregister in interface ServiceBus
Parameters:
callerID - the ID of the caller to be unregistered.
caller - the ServiceCaller object to be unregistered.
See Also:
ServiceBus.unregister(String, ServiceCaller)

unregister

public void unregister(String memberID,
                       BusMember m)
Description copied from class: AbstractBus
Unregisters bus member from the bus (if the bus member with given ID exists).

Overrides:
unregister in class AbstractBus

createBusStrategy

protected BusStrategy createBusStrategy(CommunicationModule commModule)
Specified by:
createBusStrategy in class AbstractBus

handleSendError

public void handleSendError(ChannelMessage message,
                            CommunicationConnectorException e)
Description copied from interface: MessageListener
Callback for error handling

Specified by:
handleSendError in interface MessageListener


Copyright © 2014 universAAL Consortium. All Rights Reserved.