Package com.shri.restinpeace.proxy
Class RestClientInvocationHandler
java.lang.Object
com.shri.restinpeace.proxy.RestClientInvocationHandler
- All Implemented Interfaces:
InvocationHandler
JDK dynamic proxy handler backing every client returned by
RIP.getClient(Class). Routes Object
methods (toString/equals/hashCode) to
proxy-aware implementations, a default interface method (e.g. a
convenience wrapper calling another method on the same @RestClient
interface) to its own real implementation, and every other method call to
RequestExecutor based on its HTTP method annotation.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a handler backed by a freshRequestExecutorwith no runtime base URL override.RestClientInvocationHandler(RequestExecutor requestExecutor) Creates a handler backed by an already-builtRequestExecutor, instead of constructing a fresh one from a base URL or config - used by a compile-time-generated<Interface>_RipImplclass to build its own internal reflective fallback proxy (for the one method, if any, outsideRestClientProcessor's codegen-supported shape) that shares this exact client's retry/cache/interceptor/timeout config, rather than one built from scratch with none of it.Creates a handler backed by a freshRequestExecutorbuilt fromconfig.RestClientInvocationHandler(String baseUrlOverride) Creates a handler backed by a freshRequestExecutorthat resolves every relative method URL againstbaseUrlOverride. -
Method Summary
-
Constructor Details
-
RestClientInvocationHandler
public RestClientInvocationHandler()Creates a handler backed by a freshRequestExecutorwith no runtime base URL override. -
RestClientInvocationHandler
Creates a handler backed by a freshRequestExecutorthat resolves every relative method URL againstbaseUrlOverride.- Parameters:
baseUrlOverride- the runtime base URL, ornullto fall back to the interface's@BaseUrl
-
RestClientInvocationHandler
Creates a handler backed by a freshRequestExecutorbuilt fromconfig.- Parameters:
config- the per-client settings
-
RestClientInvocationHandler
Creates a handler backed by an already-builtRequestExecutor, instead of constructing a fresh one from a base URL or config - used by a compile-time-generated<Interface>_RipImplclass to build its own internal reflective fallback proxy (for the one method, if any, outsideRestClientProcessor's codegen-supported shape) that shares this exact client's retry/cache/interceptor/timeout config, rather than one built from scratch with none of it. Not part of the public API surface a consumer is expected to call directly.- Parameters:
requestExecutor- the already-built request executor to reuse
-
-
Method Details
-
invoke
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-