import javax.inject.Singleton;
import org.apache.aries.blueprint.annotation.service.Reference;
import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
-import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesNotifWrapper;
public Rfc8040RestConfWiring(final SchemaContextHandler schemaCtxHandler,
final DOMMountPointServiceHandler domMountPointServiceHandler,
final TransactionChainHandler transactionChainHandler,
- final DOMDataBrokerHandler domDataBrokerHandler, final RpcServiceHandler rpcServiceHandler,
+ final DOMDataBrokerHandler domDataBrokerHandler, @Reference final DOMRpcService rpcService,
@Reference final DOMActionService actionService,
final NotificationServiceHandler notificationServiceHandler,
final SSEInitializer sseInit,
final Configuration configuration,
@Reference final DOMSchemaService domSchemaService) {
servicesWrapper = ServicesWrapper.newInstance(schemaCtxHandler, domMountPointServiceHandler,
- transactionChainHandler, domDataBrokerHandler, rpcServiceHandler, actionService,
+ transactionChainHandler, domDataBrokerHandler, rpcService, actionService,
notificationServiceHandler, domSchemaService, configuration);
servicesNotifWrapper = ServicesNotifWrapper.newInstance(sseInit);
}
+++ /dev/null
-/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.restconf.nb.rfc8040.handlers;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
-
-/**
- * Implementation of {@link RpcServiceHandler}.
- */
-// FIXME: remove this class
-@Singleton
-public class RpcServiceHandler {
- private final DOMRpcService rpcService;
-
- @Inject
- public RpcServiceHandler(final @Reference DOMRpcService rpcService) {
- this.rpcService = rpcService;
- }
-
- public DOMRpcService get() {
- return this.rpcService;
- }
-}
import javax.ws.rs.core.UriInfo;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
-import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfInvokeOperationsService;
import org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfInvokeOperationsUtil;
*/
@Path("/")
public class RestconfInvokeOperationsServiceImpl implements RestconfInvokeOperationsService {
- private final RpcServiceHandler rpcServiceHandler;
+ private final DOMRpcService rpcService;
private final SchemaContextHandler schemaContextHandler;
- public RestconfInvokeOperationsServiceImpl(final RpcServiceHandler rpcServiceHandler,
+ public RestconfInvokeOperationsServiceImpl(final DOMRpcService rpcService,
final SchemaContextHandler schemaContextHandler) {
- this.rpcServiceHandler = requireNonNull(rpcServiceHandler);
+ this.rpcService = requireNonNull(rpcService);
this.schemaContextHandler = requireNonNull(schemaContextHandler);
}
ErrorTag.OPERATION_NOT_SUPPORTED);
}
} else {
- response = RestconfInvokeOperationsUtil.invokeRpc(payload.getData(), schemaPath,
- this.rpcServiceHandler);
+ response = RestconfInvokeOperationsUtil.invokeRpc(payload.getData(), schemaPath, this.rpcService);
}
schemaContextRef = this.schemaContextHandler.get();
} else {
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Optional;
import java.util.concurrent.CancellationException;
-import javax.ws.rs.core.Response.Status;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMActionResult;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
-import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.YangConstants;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* input data
* @param rpc
* RPC type
- * @param rpcServiceHandler
- * rpc service handler to invoke rpc
+ * @param rpcService
+ * rpc service to invoke rpc
* @return {@link DOMRpcResult}
*/
public static DOMRpcResult invokeRpc(final NormalizedNode<?, ?> data, final QName rpc,
- final RpcServiceHandler rpcServiceHandler) {
- final DOMRpcService rpcService = rpcServiceHandler.get();
- if (rpcService == null) {
- throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
- }
-
+ final DOMRpcService rpcService) {
return prepareResult(rpcService.invokeRpc(rpc, nonnullInput(rpc, data)));
}
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
-import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfDataService;
public static ServicesWrapper newInstance(final SchemaContextHandler schemaCtxHandler,
final DOMMountPointServiceHandler domMountPointServiceHandler,
final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
- final RpcServiceHandler rpcServiceHandler, final DOMActionService actionService,
+ final DOMRpcService rpcService, final DOMActionService actionService,
final NotificationServiceHandler notificationServiceHandler, final DOMSchemaService domSchemaService,
final Configuration configuration) {
RestconfOperationsService restconfOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler,
configuration);
RestconfDataService restconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
domMountPointServiceHandler, restconfSubscrService, actionService, configuration);
- RestconfInvokeOperationsService restconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(
- rpcServiceHandler, schemaCtxHandler);
+ RestconfInvokeOperationsService restconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcService,
+ schemaCtxHandler);
RestconfService restconfService = new RestconfImpl(schemaCtxHandler);
return new ServicesWrapper(restconfDataService, restconfInvokeOpsService, restconfSubscrService,
restconfOpsService, restconfSchemaService, restconfService);
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.yangtools.yang.common.QName;
private RestconfInvokeOperationsServiceImpl invokeOperationsService;
- @Mock
- private RpcServiceHandler rpcServiceHandler;
-
@Mock
private DOMRpcService rpcService;
mock(DOMSchemaService.class));
schemaContextHandler.onModelContextUpdated(contextRef);
this.invokeOperationsService =
- new RestconfInvokeOperationsServiceImpl(this.rpcServiceHandler, schemaContextHandler);
- when(this.rpcServiceHandler.get()).thenReturn(this.rpcService);
+ new RestconfInvokeOperationsServiceImpl(this.rpcService, schemaContextHandler);
}
@Test
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFailedFluentFuture;
import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFluentFuture;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
-import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.handlers.RpcServiceHandler;
import org.opendaylight.yangtools.yang.common.RpcError;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
private static final TestData DATA = new TestData();
- private RpcServiceHandler serviceHandler;
@Mock
private DOMRpcService rpcService;
@Mock
private DOMMountPoint moutPoint;
- @Before
- public void setUp() {
- serviceHandler = new RpcServiceHandler(rpcService);
- }
-
@Test
public void invokeRpcTest() {
final DOMRpcResult mockResult = new DefaultDOMRpcResult(DATA.output, Collections.emptyList());
doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(DATA.rpc, DATA.input);
- final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.rpc, serviceHandler);
- Assert.assertTrue(rpcResult.getErrors().isEmpty());
+ final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.rpc, rpcService);
+ assertTrue(rpcResult.getErrors().isEmpty());
assertEquals(DATA.output, rpcResult.getResult());
}
"No implementation of RPC " + DATA.errorRpc.toString() + " available.");
doReturn(immediateFailedFluentFuture(exception)).when(rpcService).invokeRpc(DATA.errorRpc, DATA.input);
final DOMRpcResult rpcResult =
- RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.errorRpc, serviceHandler);
+ RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.errorRpc, rpcService);
assertNull(rpcResult.getResult());
final Collection<? extends RpcError> errorList = rpcResult.getErrors();
assertEquals(1, errorList.size());
doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(DATA.rpc, DATA.input);
final DOMRpcResult rpcResult =
RestconfInvokeOperationsUtil.invokeRpcViaMountPoint(moutPoint, DATA.input, DATA.rpc);
- Assert.assertTrue(rpcResult.getErrors().isEmpty());
+ assertTrue(rpcResult.getErrors().isEmpty());
assertEquals(DATA.output, rpcResult.getResult());
}
public void checkResponseTest() {
final DOMRpcResult mockResult = new DefaultDOMRpcResult(DATA.output, Collections.emptyList());
doReturn(immediateFluentFuture(mockResult)).when(rpcService).invokeRpc(DATA.rpc, DATA.input);
- final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.rpc, serviceHandler);
- Assert.assertTrue(rpcResult.getErrors().isEmpty());
+ final DOMRpcResult rpcResult = RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.rpc, rpcService);
+ assertTrue(rpcResult.getErrors().isEmpty());
assertEquals(DATA.output, rpcResult.getResult());
assertNotNull(RestconfInvokeOperationsUtil.checkResponse(rpcResult));
}