Class ProxyBuilder
java.lang.Object
org.chenile.proxy.builder.ProxyBuilder
Creates a proxy for a chenile interface. A proxy allows the
clients to avail the benefits of interception, transformation, caching etc.
The chain of execution includes a router that determine if a local or remote http
proxy must be used to invoke the actual service
- Author:
- Raja Shankar Kolluru
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String(package private) LocalProxyInvoker(package private) ProxyTypeRouterprivate ProxyUtilsstatic final String(package private) RemoteProxyInvoker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TbuildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier) Build proxy for an interface.<T> TbuildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier, String baseUrl) Build proxy for an interface.<T> TbuildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier, ProxyBuilder.ProxyMode proxyMode) <T> TbuildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier, ProxyBuilder.ProxyMode proxyMode, String baseUrl) This is used for testing purposes.
-
Field Details
-
REMOTE_URL_BASE
- See Also:
-
INVOCATION_METHOD
- See Also:
-
proxyUtils
-
proxyTypeRouter
-
localProxyInvoker
-
remoteProxyInvoker
-
-
Constructor Details
-
ProxyBuilder
public ProxyBuilder()
-
-
Method Details
-
buildProxy
public <T> T buildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier, ProxyBuilder.ProxyMode proxyMode) -
buildProxy
Build proxy for an interface. The headers from the current request are copied using the headerCopier. The service name is the service which is being proxied- Type Parameters:
T- - the interface represented by a generic- Parameters:
interfaceToProxy- the interface that is implemented by the serviceserviceName- service name of the chenile serviceheaderCopier- any special treatment of header parameters- Returns:
- the mock proxy that implements the interface
-
buildProxy
public <T> T buildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier, String baseUrl) Build proxy for an interface. The headers from the current request are copied using the headerCopier. The service name is the service which is being proxied- Type Parameters:
T- - the interface represented by a generic- Parameters:
interfaceToProxy- the interface that is implemented by the serviceserviceName- service name of the chenile serviceheaderCopier- any special treatment of header parameters- Returns:
- the mock proxy that implements the interface
-
buildProxy
public <T> T buildProxy(Class<T> interfaceToProxy, String serviceName, HeaderCopier headerCopier, ProxyBuilder.ProxyMode proxyMode, String baseUrl) This is used for testing purposes. For production, please make sure that proxy mode is set to COMPUTE_DYNAMICALLY- Type Parameters:
T- Interface to proxy class- Parameters:
interfaceToProxy- the interface that needs to be proxiedserviceName- - name of the serviceheaderCopier- this copies headers from the source to the target CHenile exchangeproxyMode- - can be set to always proxy local or remote for testing purposes- Returns:
- the proxy that can be used in lieu of the service
-