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 ofProxyBuilderusing the built-inProxyfunctionality.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 aMethodthrough aMethodAssignment.withDefaultHandler(InvocationHandler defaultInvocationHandler) Specifies the defaultInvocationHandler, which gets called when no otherInvocationHandleris able to handle the invocation.Specifies theObject.hashCode()andObject.equals(Object)method.withHandlersForRemoteDispatcher(RemoteInvocationDispatcher remoteInvocationDispatcher) Generates anInvocationHandlerfor each method int he class markedRemotelyInvokableusing the specifedRemoteInvocationDispatcher.withHandlersForRemoteInvoker(RemoteInvoker remoteInvoker) Generates anInvocationHandlerfor each method in the class markedRemotelyInvokableusing 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 aMethodthrough aMethodAssignment.- Parameters:
invocationHandler- theInvocationHandler- Returns:
- a
MethodAssignmentused to assign thisInvocationHandlerto a specificMethod
-
withDefaultHandler
Specifies the defaultInvocationHandler, which gets called when no otherInvocationHandleris 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 anInvocationHandlerfor each method in the class markedRemotelyInvokableusing the specifiedRemoteInvoker.- Returns:
- this instance
-
withHandlersForRemoteDispatcher
public ProxyBuilder<ProxyT> withHandlersForRemoteDispatcher(RemoteInvocationDispatcher remoteInvocationDispatcher) Generates anInvocationHandlerfor each method int he class markedRemotelyInvokableusing the specifedRemoteInvocationDispatcher.- Parameters:
remoteInvocationDispatcher- theRemoteInvocationDispatcher- Returns:
- this instance
-
build
Returns new instance ofProxyBuilderusing the built-inProxyfunctionality.- Returns:
- the
ProxyBuilderinstance.
-