Class ProxyBuilder<ProxyT>
java.lang.Object
dev.getelements.elements.rt.remote.ProxyBuilder<ProxyT>
-
Constructor Summary
ConstructorsConstructorDescriptionProxyBuilder
(Class<ProxyT> interfaceClassT) Creates aProxyBuilder<ProxyT>
for the supplied interface type.ProxyBuilder
(Class<ProxyT> interfaceClassT, String name) Creates aProxyBuilder<ProxyT>
for the supplied interface type. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns new instance ofProxyBuilder
using the built-inProxy
functionality.Given any interface methods that are declared as "default" this will ensure that they are not proxied.handler
(InvocationHandler invocationHandler) Specifies an instance ofInvocationHandler
, which can be used to handle invocations against aMethod
through aMethodAssignment
.withDefaultHandler
(InvocationHandler defaultInvocationHandler) Specifies the defaultInvocationHandler
, which gets called when no otherInvocationHandler
is able to handle the invocation.Specifies theObject.hashCode()
andObject.equals(Object)
method.withHandlersForRemoteDispatcher
(RemoteInvocationDispatcher remoteInvocationDispatcher) Generates anInvocationHandler
for each method int he class markedRemotelyInvokable
using the specifedRemoteInvocationDispatcher
.withHandlersForRemoteInvoker
(RemoteInvoker remoteInvoker) Generates anInvocationHandler
for each method in the class markedRemotelyInvokable
using the specifiedRemoteInvoker
.withMethodHandleCache
(BiFunction<dev.getelements.elements.rt.remote.MethodHandleKey, Supplier<MethodHandle>, MethodHandle> methodHandleCache) Allows for hte specification of a cache-getter function.Uses theSharedMethodHandleCache.getSharedMethodHandleCache()
to cache method handles.Specifies the a defaultObject.toString()
method, which simply returns the value "Proxy for the.class.Name"withToString
(String toString) Specifies the a defaultObject.toString()
method, which simply returns the hardcoded value.
-
Constructor Details
-
ProxyBuilder
Creates aProxyBuilder<ProxyT>
for the supplied interface type.- Parameters:
interfaceClassT
-
-
ProxyBuilder
Creates aProxyBuilder<ProxyT>
for the supplied interface type.- Parameters:
interfaceClassT
-name
- Relates toInvocation.getName()
and maps to the naming used inNamed
.
-
-
Method Details
-
dontProxyDefaultMethods
Given any interface methods that are declared as "default" this will ensure that they are not proxied.- Returns:
- this instance
-
withMethodHandleCache
public ProxyBuilder<ProxyT> withMethodHandleCache(BiFunction<dev.getelements.elements.rt.remote.MethodHandleKey, Supplier<MethodHandle>, MethodHandle> methodHandleCache) Allows for hte specification of a cache-getter function. If the underlying cache- Parameters:
methodHandleCache
- aFunction<dev.getelements.elements.rt.remote.MethodHandleKey,
used to retrieve cached instancesMethodHandle> - Returns:
-
handler
Specifies an instance ofInvocationHandler
, which can be used to handle invocations against aMethod
through aMethodAssignment
.- Parameters:
invocationHandler
- theInvocationHandler
- Returns:
- a
MethodAssignment
used to assign thisInvocationHandler
to a specificMethod
-
withDefaultHandler
Specifies the defaultInvocationHandler
, which gets called when no otherInvocationHandler
is able to handle the invocation.- Parameters:
defaultInvocationHandler
- the defaultInvocationHandler
- Returns:
- this instance
-
withToString
Specifies the a defaultObject.toString()
method, which simply returns the value "Proxy for the.class.Name"- Returns:
- this instance
-
withToString
Specifies the a defaultObject.toString()
method, which simply returns the hardcoded value.- Parameters:
toString
- the value to return whenObject.toString()
is invoked on the proxy.- Returns:
- this instance
-
withDefaultHashCodeAndEquals
Specifies theObject.hashCode()
andObject.equals(Object)
method.Object.hashCode()
will be implementedSystem.identityHashCode(Object)
and equals will be implemented as "=="- Returns:
- this instance
-
withHandlersForRemoteInvoker
Generates anInvocationHandler
for each method in the class markedRemotelyInvokable
using the specifiedRemoteInvoker
.- Returns:
- this instance
-
withHandlersForRemoteDispatcher
public ProxyBuilder<ProxyT> withHandlersForRemoteDispatcher(RemoteInvocationDispatcher remoteInvocationDispatcher) Generates anInvocationHandler
for each method int he class markedRemotelyInvokable
using the specifedRemoteInvocationDispatcher
.- Parameters:
remoteInvocationDispatcher
- theRemoteInvocationDispatcher
- Returns:
- this instance
-
build
Returns new instance ofProxyBuilder
using the built-inProxy
functionality.- Returns:
- the
ProxyBuilder
instance.
-