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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Method Summary
Modifier and TypeMethodDescriptionvoidreceive(UdpMessage udpMessage) Receive one incoming UDP message.voidRegisters 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()voidUnregisters 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.common.util.concurrent.Service
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, failureCause, isRunning, startAsync, state, stopAsync
-
Method Details
-
setUdpBinding
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
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
Description copied from interface:UdpMessageQueueServiceRegisters an observer to receive incoming UDP messages.- Specified by:
registerUdpMessageQueueObserverin interfaceUdpMessageQueueService- Parameters:
observer- the observer to register.
-
unregisterUdpMessageQueueObserver
Description copied from interface:UdpMessageQueueServiceUnregisters an observer to stop receiving incoming UDP messages.- Specified by:
unregisterUdpMessageQueueObserverin interfaceUdpMessageQueueService- Parameters:
observer- the observer to unregister.
-
startUp
- 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
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.
-