|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.netflix.client.ClientFactory
public class ClientFactory
A factory that creates client, load balancer and client configuration instances from properties. It also keeps mappings of client names to the created instances.
Constructor Summary | |
---|---|
ClientFactory()
|
Method Summary | |
---|---|
static IClient |
createNamedClient(java.lang.String name,
java.lang.Class<? extends IClientConfig> configClass)
Creates a named client using a IClientConfig instance created off the configClass class object passed in as the parameter. |
static IClient |
getNamedClient(java.lang.String name)
Return the named client from map if already created. |
static IClientConfig |
getNamedConfig(java.lang.String name)
Get the client configuration given the name or create one with DefaultClientConfigImpl if it does not exist. |
static IClientConfig |
getNamedConfig(java.lang.String name,
java.lang.Class<? extends IClientConfig> clientConfigClass)
Get the client configuration given the name or create one with clientConfigClass if it does not exist. |
static ILoadBalancer |
getNamedLoadBalancer(java.lang.String name)
Get the load balancer associated with the name, or create one with an instance DefaultClientConfigImpl if does not exist |
static ILoadBalancer |
getNamedLoadBalancer(java.lang.String name,
java.lang.Class<? extends IClientConfig> configClass)
Get the load balancer associated with the name, or create one with an instance of configClass if does not exist |
static java.lang.Object |
instantiateInstanceWithClientConfig(java.lang.String className,
IClientConfig clientConfig)
Creates instance related to client framework using reflection. |
static IClient<?,?> |
registerClientFromProperties(java.lang.String restClientName,
IClientConfig clientConfig)
Utility method to create client and load balancer (if enabled in client config) given the name and client config. |
static ILoadBalancer |
registerNamedLoadBalancerFromclientConfig(java.lang.String name,
IClientConfig clientConfig)
Create and register a load balancer with the name and given the class of configClass. |
static ILoadBalancer |
registerNamedLoadBalancerFromProperties(java.lang.String name,
java.lang.Class<? extends IClientConfig> configClass)
Create and register a load balancer with the name and given the class of configClass. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClientFactory()
Method Detail |
---|
public static IClient<?,?> registerClientFromProperties(java.lang.String restClientName, IClientConfig clientConfig) throws ClientException
instantiateInstanceWithClientConfig(String, IClientConfig)
restClientName
- clientConfig
-
ClientException
- if any errors occurs in the process, or if the client with the same name already existspublic static IClient getNamedClient(java.lang.String name)
getNamedConfig(String)
.
java.lang.RuntimeException
- if an error occurs in creating the client.public static IClient createNamedClient(java.lang.String name, java.lang.Class<? extends IClientConfig> configClass) throws ClientException
ClientException
- if any error occurs, or if the client with the same name already existspublic static ILoadBalancer getNamedLoadBalancer(java.lang.String name)
DefaultClientConfigImpl
if does not exist
java.lang.RuntimeException
- if any error occurspublic static ILoadBalancer getNamedLoadBalancer(java.lang.String name, java.lang.Class<? extends IClientConfig> configClass)
java.lang.RuntimeException
- if any error occursregisterNamedLoadBalancerFromProperties(String, Class)
public static ILoadBalancer registerNamedLoadBalancerFromclientConfig(java.lang.String name, IClientConfig clientConfig) throws ClientException
ClientException
- if load balancer with the same name already exists or any error occursinstantiateInstanceWithClientConfig(String, IClientConfig)
public static ILoadBalancer registerNamedLoadBalancerFromProperties(java.lang.String name, java.lang.Class<? extends IClientConfig> configClass) throws ClientException
ClientException
- if load balancer with the same name already exists or any error occursinstantiateInstanceWithClientConfig(String, IClientConfig)
public static java.lang.Object instantiateInstanceWithClientConfig(java.lang.String className, IClientConfig clientConfig) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException
IClientConfigAware
and if so invoke IClientConfigAware.initWithNiwsConfig(IClientConfig)
. If that does not
apply, it tries to find if there is a constructor with IClientConfig
as a parameter and if so invoke that constructor. If neither applies,
it simply invokes the no-arg constructor and ignores the clientConfig parameter.
className
- Class name of the objectclientConfig
- IClientConfig object used for initialization.
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
public static IClientConfig getNamedConfig(java.lang.String name)
DefaultClientConfigImpl
if it does not exist.
getNamedConfig(String, Class)
public static IClientConfig getNamedConfig(java.lang.String name, java.lang.Class<? extends IClientConfig> clientConfigClass)
IClientConfig.loadProperties(String)
will be called.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |