2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.services;
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import com.google.common.util.concurrent.MoreExecutors;
14 import java.util.function.Function;
15 import javax.annotation.Nonnull;
16 import javax.annotation.Nullable;
17 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
18 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
20 import org.opendaylight.yangtools.yang.binding.DataObject;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
24 public abstract class AbstractSilentErrorService<I, O extends DataObject>
25 extends AbstractSimpleService<I, O> {
27 protected AbstractSilentErrorService(RequestContextStack requestContextStack,
28 DeviceContext deviceContext,
30 super(requestContextStack, deviceContext, clazz);
34 public ListenableFuture<RpcResult<O>> handleServiceCall(@Nonnull I input,
35 @Nullable final Function<OfHeader, Boolean> isComplete) {
36 return Futures.catching(
37 super.handleServiceCall(input, isComplete),
39 t -> RpcResultBuilder.<O>failed().build(), MoreExecutors.directExecutor());