re-activate FindBugs
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / services / sal / SalTableServiceImpl.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. 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 package org.opendaylight.openflowplugin.impl.services.sal;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
13 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
14 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerTableMultipartService;
15 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerTableMultipartService;
16 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21
22 public final class SalTableServiceImpl implements SalTableService {
23
24     private final SingleLayerTableMultipartService singleLayerService;
25     private final MultiLayerTableMultipartService multiLayerService;
26
27     public SalTableServiceImpl(final RequestContextStack requestContextStack,
28                                final DeviceContext deviceContext,
29                                final ConvertorExecutor convertorExecutor,
30                                final MultipartWriterProvider multipartWriterProvider) {
31         singleLayerService = new SingleLayerTableMultipartService(requestContextStack,
32                                                                   deviceContext,
33                                                                   multipartWriterProvider);
34         multiLayerService = new MultiLayerTableMultipartService(requestContextStack,
35                                                                 deviceContext,
36                                                                 convertorExecutor,
37                                                                 multipartWriterProvider);
38     }
39
40     @Override
41     public ListenableFuture<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
42         return singleLayerService.canUseSingleLayerSerialization()
43             ? singleLayerService.handleAndReply(input)
44             : multiLayerService.handleAndReply(input);
45     }
46 }