public class WebConnectionWrapper extends Object implements WebConnection
Provides a convenient implementation of the WebConnection
interface that can be subclassed by developers
wishing to adapt a particular WebConnection.
This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped web connection object.
Constructor and Description |
---|
WebConnectionWrapper(WebClient webClient)
Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
connection of the WebClient.
|
WebConnectionWrapper(WebConnection webConnection)
Constructs a WebConnection object wrapping provided WebConnection.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
The default behavior of this method is to return
WebConnection.close() on the wrapped connection object. |
WebResponse |
getResponse(WebRequest request)
Submits a request and retrieves a response.
|
WebConnection |
getWrappedWebConnection()
Gets the wrapped
WebConnection . |
public WebConnectionWrapper(WebConnection webConnection) throws IllegalArgumentException
webConnection
- the webConnection that does the real workIllegalArgumentException
- if the connection is null
public WebConnectionWrapper(WebClient webClient) throws IllegalArgumentException
webClient
- the WebClient which WebConnection should be wrappedIllegalArgumentException
- if the WebClient is null
public WebResponse getResponse(WebRequest request) throws IOException
WebConnection.getResponse(WebRequest)
on the wrapped connection object.getResponse
in interface WebConnection
request
- the requestIOException
- if an IO error occurspublic WebConnection getWrappedWebConnection()
WebConnection
.public void close() throws IOException
WebConnection.close()
on the wrapped connection object.close
in interface AutoCloseable
close
in interface WebConnection
IOException
Copyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.