public class AsyncHttpClientRegistryImpl extends Object implements AsyncHttpClientRegistry
| Constructor and Description |
|---|
AsyncHttpClientRegistryImpl() |
| Modifier and Type | Method and Description |
|---|---|
AsyncHttpClient |
addOrReplace(String name,
AsyncHttpClient ahc)
Registers this instance of AsyncHttpClient with this name and returns
back a null if an instance with the same name never existed but will return back the
previous instance if there was another instance registered with the same
name and has been replaced by this one.
|
void |
clearAllInstances()
Removes all instances from this registry.
|
AsyncHttpClient |
get(String clientName)
Returns back the AsyncHttpClient associated with this name
|
Set<String> |
getAllRegisteredNames() |
static AsyncHttpClientRegistry |
getInstance()
Returns a singleton instance of AsyncHttpClientRegistry
|
boolean |
registerIfNew(String name,
AsyncHttpClient ahc)
Will register only if an instance with this name doesn't exist and if it
does exist will not replace this instance and will return false.
|
boolean |
unregister(String name)
Remove the instance associate with this name
|
public static AsyncHttpClientRegistry getInstance()
public AsyncHttpClient get(String clientName)
AsyncHttpClientRegistryget in interface AsyncHttpClientRegistryclientName - the name of the client instance in the registrypublic AsyncHttpClient addOrReplace(String name, AsyncHttpClient ahc)
AsyncHttpClientRegistryaddOrReplace in interface AsyncHttpClientRegistryname - the name of the client instance in the registryahc - the client instancepublic boolean registerIfNew(String name, AsyncHttpClient ahc)
AsyncHttpClientRegistry
AsyncHttpClient ahc = AsyncHttpClientFactory.getAsyncHttpClient();
if(!AsyncHttpClientRegistryImpl.getInstance().registerIfNew(“MyAHC”,ahc)){
//An instance with this name is already registered so close ahc
ahc.close();
//and do necessary cleanup
}
registerIfNew in interface AsyncHttpClientRegistryname - the name of the client instance in the registryahc - the client instancepublic boolean unregister(String name)
AsyncHttpClientRegistryunregister in interface AsyncHttpClientRegistryname - the name of the client instance in the registrypublic Set<String> getAllRegisteredNames()
getAllRegisteredNames in interface AsyncHttpClientRegistrypublic void clearAllInstances()
AsyncHttpClientRegistryclearAllInstances in interface AsyncHttpClientRegistryCopyright © 2017. All Rights Reserved.