Merge "Remove config knob for reconciliation framework"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / AbstractSilentErrorService.java
1 /**
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.services;
10
11 import com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.function.Function;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
16 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
17 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
22
23 public abstract class AbstractSilentErrorService<I, O extends DataObject>
24         extends AbstractSimpleService<I, O> {
25
26     protected AbstractSilentErrorService(RequestContextStack requestContextStack, DeviceContext deviceContext, Class<O> clazz) {
27         super(requestContextStack, deviceContext, clazz);
28     }
29
30     @Override
31     public ListenableFuture<RpcResult<O>> handleServiceCall(@Nonnull I input,
32                                                             @Nullable final Function<OfHeader, Boolean> isComplete) {
33         return Futures.catching(
34                 super.handleServiceCall(input, isComplete),
35                 Throwable.class,
36                 t -> RpcResultBuilder.<O>failed().build());
37     }
38
39 }