import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import java.lang.reflect.Method;
import java.util.HashMap;
public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation {
- private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS = CacheBuilder.newBuilder().weakKeys().build();
+ private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS =
+ CacheBuilder.newBuilder().weakKeys().build();
private final BindingNormalizedNodeSerializer codec;
private final RpcServiceInvoker invoker;
private final RpcService delegate;
private final QName inputQname;
- <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeSerializer codec, final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
+ <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeSerializer codec,
+ final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
try {
this.invoker = SERVICE_INVOKERS.get(type, () -> {
final Map<QName, Method> map = new HashMap<>();
@Nonnull
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc,
+ final NormalizedNode<?, ?> input) {
final SchemaPath schemaPath = rpc.getType();
final DataObject bindingInput = input != null ? deserialize(rpc.getType(), input) : null;
final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath, bindingInput);
}
private ListenableFuture<RpcResult<?>> invoke(final SchemaPath schemaPath, final DataObject input) {
- return JdkFutureAdapters.listenInPoolThread(invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input));
+ return invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input);
}
- private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(final ListenableFuture<RpcResult<?>> bindingResult) {
+ private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(
+ final ListenableFuture<RpcResult<?>> bindingResult) {
return LazyDOMRpcResultFuture.create(codec, bindingResult);
}