org.fourthline.cling.transport.impl.jetty
Class StreamClientImpl

java.lang.Object
  extended by org.fourthline.cling.transport.impl.jetty.StreamClientImpl
All Implemented Interfaces:
StreamClient

public class StreamClientImpl
extends Object
implements StreamClient

Implementation based on Jetty 8 client API.

This implementation works on Android, dependencies are the jetty-client Maven module.

Author:
Christian Bauer

Nested Class Summary
static class StreamClientImpl.HttpContentExchange
           
 
Field Summary
protected  org.eclipse.jetty.client.HttpClient client
           
protected  StreamClientConfigurationImpl configuration
           
 
Constructor Summary
StreamClientImpl(StreamClientConfigurationImpl configuration)
           
 
Method Summary
protected  StreamClientImpl.HttpContentExchange createHttpContentExchange(StreamClientConfigurationImpl configuration, StreamRequestMessage requestMessage)
           
 StreamClientConfigurationImpl getConfiguration()
           
 StreamResponseMessage sendRequest(StreamRequestMessage requestMessage)
          Sends the given request via TCP (HTTP) and returns the response.
 void stop()
          Stops the service, closes any connection pools etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configuration

protected final StreamClientConfigurationImpl configuration

client

protected final org.eclipse.jetty.client.HttpClient client
Constructor Detail

StreamClientImpl

public StreamClientImpl(StreamClientConfigurationImpl configuration)
                 throws InitializationException
Throws:
InitializationException
Method Detail

getConfiguration

public StreamClientConfigurationImpl getConfiguration()
Specified by:
getConfiguration in interface StreamClient
Returns:
This service's configuration.

sendRequest

public StreamResponseMessage sendRequest(StreamRequestMessage requestMessage)
Description copied from interface: StreamClient
Sends the given request via TCP (HTTP) and returns the response.

This method will always try to complete execution without throwing an exception. It will return null if an error occurs, and optionally log any exception messages.

This method is required to add a Host HTTP header to the outgoing HTTP request, even if the given StreamRequestMessage does not contain such a header.

This method will add the User-Agent HTTP header to the outgoing HTTP request if the given message did not already contain such a header. You can set this default value in your StreamClientConfiguration.

Specified by:
sendRequest in interface StreamClient
Parameters:
requestMessage - The message to send.
Returns:
The response or null if no response has been received or an error occurred.

stop

public void stop()
Description copied from interface: StreamClient
Stops the service, closes any connection pools etc.

Specified by:
stop in interface StreamClient

createHttpContentExchange

protected StreamClientImpl.HttpContentExchange createHttpContentExchange(StreamClientConfigurationImpl configuration,
                                                                         StreamRequestMessage requestMessage)


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