Package play.libs.ws.ahc
Class AhcWSClient
- Object
-
- play.libs.ws.ahc.AhcWSClient
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,WSClient
public class AhcWSClient extends Object implements WSClient
A WS client backed by AsyncHttpClient implementation.See https://www.playframework.com/documentation/latest/JavaWS for documentation.
-
-
Constructor Summary
Constructors Constructor Description AhcWSClient(play.libs.ws.ahc.StandaloneAhcWSClient client, Materializer materializer)
AhcWSClient(play.shaded.ahc.org.asynchttpclient.AsyncHttpClient client, Materializer materializer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description play.api.libs.ws.WSClient
asScala()
void
close()
Closes this client, and releases underlying resources.static AhcWSClient
create(play.api.libs.ws.ahc.AhcWSClientConfig config, play.api.libs.ws.ahc.cache.AhcHttpCache cache, Materializer materializer)
Creates WS client manually from configuration, internally creating a new instance of AsyncHttpClient and managing its own thread pool.play.libs.ws.StandaloneWSClient
getStandaloneWSClient()
Return the implementation interface ofStandaloneAhcWSClient
.Object
getUnderlying()
The underlying implementation of the client, if any.WSRequest
url(String url)
Returns a WSRequest object representing the URL.
-
-
-
Constructor Detail
-
AhcWSClient
public AhcWSClient(play.shaded.ahc.org.asynchttpclient.AsyncHttpClient client, Materializer materializer)
-
AhcWSClient
@Inject public AhcWSClient(play.libs.ws.ahc.StandaloneAhcWSClient client, Materializer materializer)
-
-
Method Detail
-
create
public static AhcWSClient create(play.api.libs.ws.ahc.AhcWSClientConfig config, play.api.libs.ws.ahc.cache.AhcHttpCache cache, Materializer materializer)
Creates WS client manually from configuration, internally creating a new instance of AsyncHttpClient and managing its own thread pool.This client is not managed as part of Play's lifecycle, and must be closed by calling ws.close(), otherwise you will run into memory leaks.
- Parameters:
config
- a config object, usually from AhcWSClientConfigFactorycache
- if not null, provides HTTP caching.materializer
- an Akka materializer- Returns:
- a new instance of AhcWSClient.
-
getUnderlying
public Object getUnderlying()
Description copied from interface:WSClient
The underlying implementation of the client, if any. You must cast the returned value to the type you want.- Specified by:
getUnderlying
in interfaceWSClient
- Returns:
- the backing object.
-
asScala
public play.api.libs.ws.WSClient asScala()
-
url
public WSRequest url(String url)
Description copied from interface:WSClient
Returns a WSRequest object representing the URL. You can append additional properties on the WSRequest by chaining calls, and execute the request to return an asynchronousPromise<WSResponse>
.
-
close
public void close() throws IOException
Description copied from interface:WSClient
Closes this client, and releases underlying resources.Use this for manually instantiated clients.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceWSClient
- Throws:
IOException
-
getStandaloneWSClient
public play.libs.ws.StandaloneWSClient getStandaloneWSClient()
Return the implementation interface ofStandaloneAhcWSClient
.- Returns:
StandaloneWSClient
-
-