org.fourthline.cling.protocol
Class ReceivingSync<IN extends StreamRequestMessage,OUT extends StreamResponseMessage>

java.lang.Object
  extended by org.fourthline.cling.protocol.ReceivingAsync<IN>
      extended by org.fourthline.cling.protocol.ReceivingSync<IN,OUT>
Type Parameters:
IN - The type of incoming UPnP message handled by this protocol.
OUT - The type of response UPnP message created by this protocol.
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ReceivingAction, ReceivingEvent, ReceivingRetrieval, ReceivingSubscribe, ReceivingUnsubscribe

public abstract class ReceivingSync<IN extends StreamRequestMessage,OUT extends StreamResponseMessage>
extends ReceivingAsync<IN>

Supertype for all synchronously executing protocols, handling reception of UPnP messages and return a response.

After instantiation by the ProtocolFactory, this protocol run()s and calls its own ReceivingAsync.waitBeforeExecution() method. By default, the protocol does not wait before then proceeding with executeSync().

The returned response will be available to the client of this protocol. The client will then call either responseSent(org.fourthline.cling.model.message.StreamResponseMessage) or responseException(Throwable), depending on whether the response was successfully delivered. The protocol can override these methods to decide if the whole procedure it is implementing was successful or not, including not only creation but also delivery of the response.

Author:
Christian Bauer

Field Summary
protected  OUT outputMessage
           
protected  RemoteClientInfo remoteClientInfo
           
 
Constructor Summary
protected ReceivingSync(UpnpService upnpService, IN inputMessage)
           
 
Method Summary
protected  void execute()
           
protected abstract  OUT executeSync()
           
 OUT getOutputMessage()
           
 RemoteClientInfo getRemoteClientInfo()
           
 void responseException(Throwable t)
          Called by the client of this protocol if the returned response was not delivered.
 void responseSent(StreamResponseMessage responseMessage)
          Called by the client of this protocol after the returned response has been successfully delivered.
 String toString()
           
 
Methods inherited from class org.fourthline.cling.protocol.ReceivingAsync
getFirstHeader, getInputMessage, getUpnpService, run, waitBeforeExecution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

remoteClientInfo

protected final RemoteClientInfo remoteClientInfo

outputMessage

protected OUT extends StreamResponseMessage outputMessage
Constructor Detail

ReceivingSync

protected ReceivingSync(UpnpService upnpService,
                        IN inputMessage)
Method Detail

getOutputMessage

public OUT getOutputMessage()

execute

protected final void execute()
                      throws RouterException
Specified by:
execute in class ReceivingAsync<IN extends StreamRequestMessage>
Throws:
RouterException

executeSync

protected abstract OUT executeSync()
                                                          throws RouterException
Throws:
RouterException

responseSent

public void responseSent(StreamResponseMessage responseMessage)
Called by the client of this protocol after the returned response has been successfully delivered.

NOOP by default.


responseException

public void responseException(Throwable t)
Called by the client of this protocol if the returned response was not delivered.

NOOP by default.

Parameters:
t - The reason why the response wasn't delivered.

getRemoteClientInfo

public RemoteClientInfo getRemoteClientInfo()

toString

public String toString()
Overrides:
toString in class ReceivingAsync<IN extends StreamRequestMessage>


Copyright © 2013 4th Line GmbH, Switzerland. All Rights Reserved.