Package org.somda.sdc.dpws.udp
Class UdpMessageQueueServiceImpl
- java.lang.Object
-
- com.google.common.util.concurrent.AbstractIdleService
-
- org.somda.sdc.dpws.udp.UdpMessageQueueServiceImpl
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service,UdpMessageQueueService,UdpMessageReceiverCallback
public class UdpMessageQueueServiceImpl extends com.google.common.util.concurrent.AbstractIdleService implements com.google.common.util.concurrent.Service, UdpMessageQueueService
Default implementation of UdpMessageQueueService.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidreceive(UdpMessage udpMessage)Receive one incoming UDP message.voidregisterUdpMessageQueueObserver(UdpMessageQueueObserver observer)Registers an observer to receive incoming UDP messages.booleansendMessage(UdpMessage message)Queues an outgoing UDP message.voidsetUdpBinding(UdpBindingService udpBinding)Injects the UDP binding service.protected voidshutDown()protected voidstartUp()voidunregisterUdpMessageQueueObserver(UdpMessageQueueObserver observer)Unregisters an observer to stop receiving incoming UDP messages.-
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, serviceName, startAsync, state, stopAsync, toString
-
-
-
-
Method Detail
-
setUdpBinding
public void setUdpBinding(UdpBindingService udpBinding)
Description copied from interface:UdpMessageQueueServiceInjects the UDP binding service.Without a UDP binding service the message queue cannot send and receive messages. Make sure the UDP binding is injected before the service is started.
- Specified by:
setUdpBindingin interfaceUdpMessageQueueService- Parameters:
udpBinding- the UDP binding service to inject.
-
sendMessage
public boolean sendMessage(UdpMessage message)
Description copied from interface:UdpMessageQueueServiceQueues an outgoing UDP message.- Specified by:
sendMessagein interfaceUdpMessageQueueService- Parameters:
message- the message to be send.- Returns:
- true if the message could be queued, otherwise false (queue overflow).
-
registerUdpMessageQueueObserver
public void registerUdpMessageQueueObserver(UdpMessageQueueObserver observer)
Description copied from interface:UdpMessageQueueServiceRegisters an observer to receive incoming UDP messages.- Specified by:
registerUdpMessageQueueObserverin interfaceUdpMessageQueueService- Parameters:
observer- the observer to register.
-
unregisterUdpMessageQueueObserver
public void unregisterUdpMessageQueueObserver(UdpMessageQueueObserver observer)
Description copied from interface:UdpMessageQueueServiceUnregisters an observer to stop receiving incoming UDP messages.- Specified by:
unregisterUdpMessageQueueObserverin interfaceUdpMessageQueueService- Parameters:
observer- the observer to unregister.
-
startUp
protected void startUp() throws Exception- Specified by:
startUpin classcom.google.common.util.concurrent.AbstractIdleService- Throws:
Exception
-
shutDown
protected void shutDown()
- Specified by:
shutDownin classcom.google.common.util.concurrent.AbstractIdleService
-
receive
public void receive(UdpMessage udpMessage)
Description copied from interface:UdpMessageReceiverCallbackReceive one incoming UDP message.- Specified by:
receivein interfaceUdpMessageReceiverCallback- Parameters:
udpMessage- UDP data as received from the network. The message contains the payload as well as the sender's address and port.
-
-