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.WSClientasScala()voidclose()Closes this client, and releases underlying resources.static AhcWSClientcreate(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.StandaloneWSClientgetStandaloneWSClient()Return the implementation interface ofStandaloneAhcWSClient.ObjectgetUnderlying()The underlying implementation of the client, if any.WSRequesturl(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:WSClientThe underlying implementation of the client, if any. You must cast the returned value to the type you want.- Specified by:
getUnderlyingin interfaceWSClient- Returns:
- the backing object.
-
asScala
public play.api.libs.ws.WSClient asScala()
-
url
public WSRequest url(String url)
Description copied from interface:WSClientReturns 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 IOExceptionDescription copied from interface:WSClientCloses this client, and releases underlying resources.Use this for manually instantiated clients.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceWSClient- Throws:
IOException
-
getStandaloneWSClient
public play.libs.ws.StandaloneWSClient getStandaloneWSClient()
Return the implementation interface ofStandaloneAhcWSClient.- Returns:
StandaloneWSClient
-
-