org.universAAL.ri.gateway.communicator.service.impl
Class GatewayCommunicatorImpl

Package class diagram package GatewayCommunicatorImpl
java.lang.Object
  extended by org.universAAL.ri.gateway.communicator.service.impl.GatewayCommunicatorImpl
All Implemented Interfaces:
GatewayCommunicator

public class GatewayCommunicatorImpl
extends Object
implements GatewayCommunicator

AALSpace Gateway Communicator implementation. Registers one OSGi service to be used by ImportExportManager, one HTTP service for communication with other communicators. Uses ImportExportManager's OSGi service for request/response delegation.

Author:
skallz

Field Summary
 
Fields inherited from interface org.universAAL.ri.gateway.communicator.service.GatewayCommunicator
ALIAS_PREFIX, EXPORT_SECURITY_CONSTRAINT_ALLOW, EXPORT_SECURITY_CONSTRAINT_DENY, HASH_KEY, IMPORT_SECURITY_CONSTRAINT_ALLOW, IMPORT_SECURITY_CONSTRAINT_DENY, LOCAL_SOCKET_PORT, REMOTE_GATEWAYS_PROP
 
Constructor Summary
GatewayCommunicatorImpl()
          Initializes the worker with given ImportExportManager reference.
 
Method Summary
 void addRemoteGateway(GatewayAddress gwAddrToAdd)
           
 void addRemoteGateways(Collection<GatewayAddress> gwAddressesToAdd)
           
 void handleMessage(InputStream in, OutputStream out)
           
 void removeRemoteGateway(GatewayAddress gwAddrToDelete)
           
 void sendContextEvent(Message message)
           
 void sendContextEvent(Message message, URL[] to)
          Sends a context event to other AALSpace Gateway Communicators listening at given URL.
 void sendImportRefresh(Message message)
           
 void sendImportRefresh(Message message, URL[] to)
           
 void sendImportRemoval(Message message)
           
 void sendImportRemoval(Message message, URL[] to)
           
 Message sendImportRequest(Message message)
           
 Message[] sendImportRequest(Message message, URL[] to)
           
 Message[] sendServiceRequest(Message message)
           
 Message[] sendServiceRequest(Message message, long timeout)
           
 Message sendServiceRequest(Message message, URL to)
           
 Message[] sendServiceRequest(Message message, URL[] to)
          Sends a service request to another AALSpace Gateway Communicator listening at given URL, waits for the response and returns it.
 Message[] sendServiceRequest(Message message, URL[] to, long timeout)
          Sends a service request to another AALSpace Gateway Communicator listening at given URL, waits for the response and returns it if arrived before timing out.
 void sendServiceRequestAsync(Message message, URL returnTo, URL to, ResponseCallback callback)
          Sends a service request to another AALSpace Gateway Communicator listening at given URL, registers callback which will be notified once the response arrives.
 void sendUIRequest(Message message)
           
 void sendUIRequest(Message message, URL[] to)
          Sends a ui call to other AALSpace Gateway Communicators listening at given URL.
 void sendUIResponse(Message message)
           
 void sendUIResponse(Message message, URL[] to)
          Sends a ui response to other AALSpace Gateway Communicators listening at given URL.
 void setManagers(ImportManager importManager, ExportManager exportManager)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GatewayCommunicatorImpl

public GatewayCommunicatorImpl()
                        throws Exception
Initializes the worker with given ImportExportManager reference.

Parameters:
space - ImportExportManager reference for request/response delegation
Throws:
Exception
Method Detail

addRemoteGateway

public void addRemoteGateway(GatewayAddress gwAddrToAdd)

removeRemoteGateway

public void removeRemoteGateway(GatewayAddress gwAddrToDelete)

addRemoteGateways

public void addRemoteGateways(Collection<GatewayAddress> gwAddressesToAdd)

setManagers

public void setManagers(ImportManager importManager,
                        ExportManager exportManager)

sendContextEvent

public void sendContextEvent(Message message,
                             URL[] to)
Sends a context event to other AALSpace Gateway Communicators listening at given URL.

Specified by:
sendContextEvent in interface GatewayCommunicator
Parameters:
message - context event to be sent
to - a list of URLs of remote communicators to which the event should be delivered

sendUIRequest

public void sendUIRequest(Message message,
                          URL[] to)
Sends a ui call to other AALSpace Gateway Communicators listening at given URL.

Specified by:
sendUIRequest in interface GatewayCommunicator
Parameters:
message - context event to be sent
to - a list of URLs of remote communicators to which the event should be delivered

sendUIResponse

public void sendUIResponse(Message message,
                           URL[] to)
Sends a ui response to other AALSpace Gateway Communicators listening at given URL.

Specified by:
sendUIResponse in interface GatewayCommunicator
Parameters:
message - ui response
to - a list of URLs of remote communicators to which the event should be delivered

sendServiceRequest

public Message[] sendServiceRequest(Message message,
                                    URL[] to)
Sends a service request to another AALSpace Gateway Communicator listening at given URL, waits for the response and returns it. Equal to sendServiceRequest(message, to, 0);

Specified by:
sendServiceRequest in interface GatewayCommunicator
Parameters:
message - request massage to be sent to the remote communicator
to - remote communicator's URL
Returns:
response message

sendServiceRequest

public Message sendServiceRequest(Message message,
                                  URL to)

sendServiceRequest

public Message[] sendServiceRequest(Message message,
                                    URL[] to,
                                    long timeout)
                             throws TimeoutException
Sends a service request to another AALSpace Gateway Communicator listening at given URL, waits for the response and returns it if arrived before timing out.

Specified by:
sendServiceRequest in interface GatewayCommunicator
Parameters:
message - request massage to be sent to the remote communicator
to - remote communicator's URL
timeout - time in milliseconds to wait for the response
Returns:
response message
Throws:
TimeoutException - when timed out

sendServiceRequestAsync

public void sendServiceRequestAsync(Message message,
                                    URL returnTo,
                                    URL to,
                                    ResponseCallback callback)
Sends a service request to another AALSpace Gateway Communicator listening at given URL, registers callback which will be notified once the response arrives.

Specified by:
sendServiceRequestAsync in interface GatewayCommunicator
Parameters:
message - request massage to be sent to the remote communicator
returnTo - local communicator's URL to send back the response to
to - remote communicator's URL
callback - callback which will be notified once the response arrives

sendImportRequest

public Message[] sendImportRequest(Message message,
                                   URL[] to)
Specified by:
sendImportRequest in interface GatewayCommunicator

sendImportRefresh

public void sendImportRefresh(Message message,
                              URL[] to)
Specified by:
sendImportRefresh in interface GatewayCommunicator

sendImportRemoval

public void sendImportRemoval(Message message,
                              URL[] to)
Specified by:
sendImportRemoval in interface GatewayCommunicator

sendServiceRequest

public Message[] sendServiceRequest(Message message)
Specified by:
sendServiceRequest in interface GatewayCommunicator

sendServiceRequest

public Message[] sendServiceRequest(Message message,
                                    long timeout)
                             throws TimeoutException
Specified by:
sendServiceRequest in interface GatewayCommunicator
Throws:
TimeoutException

sendContextEvent

public void sendContextEvent(Message message)
Specified by:
sendContextEvent in interface GatewayCommunicator

sendUIResponse

public void sendUIResponse(Message message)
Specified by:
sendUIResponse in interface GatewayCommunicator

sendUIRequest

public void sendUIRequest(Message message)
Specified by:
sendUIRequest in interface GatewayCommunicator

sendImportRequest

public Message sendImportRequest(Message message)
Specified by:
sendImportRequest in interface GatewayCommunicator

sendImportRefresh

public void sendImportRefresh(Message message)
Specified by:
sendImportRefresh in interface GatewayCommunicator

sendImportRemoval

public void sendImportRemoval(Message message)
Specified by:
sendImportRemoval in interface GatewayCommunicator

handleMessage

public void handleMessage(InputStream in,
                          OutputStream out)
Specified by:
handleMessage in interface GatewayCommunicator

stop

public void stop()
Specified by:
stop in interface GatewayCommunicator

start

public void start()
           throws Exception
Specified by:
start in interface GatewayCommunicator
Throws:
Exception


Copyright © 2014 universAAL Consortium. All Rights Reserved.