From: Jakub Toth Date: Tue, 7 Nov 2017 10:41:09 +0000 (+0100) Subject: Make ServicesWrapperImpl as argument in provider X-Git-Tag: release/oxygen~41 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=d7e7fc033919575500f46d724e8f1cddb31857f5;p=netconf.git Make ServicesWrapperImpl as argument in provider Change-Id: Id491309eb0f1bc75337ace02072248f25d60a1b9 Signed-off-by: Jakub Toth --- diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java index 1fa97116f2..6ad199e7ac 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProvider.java @@ -24,7 +24,7 @@ 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.ServicesWrapperImpl; +import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServiceWrapper; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.slf4j.Logger; @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; * Provider for restconf draft18. * */ -public class RestConnectorProvider implements RestconfConnector, AutoCloseable { +public class RestConnectorProvider implements RestconfConnector, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class); @@ -61,13 +61,16 @@ public class RestConnectorProvider implements RestconfConnector, AutoCloseable { private final DOMRpcService rpcService; private final DOMNotificationService notificationService; private final DOMMountPointService mountPointService; - private ListenerRegistration listenerRegistration; + private final T wrapperServices; + private ListenerRegistration listenerRegistration; private SchemaContextHandler schemaCtxHandler; - public RestConnectorProvider(final DOMDataBroker domDataBroker, final SchemaService schemaService, - final DOMRpcService rpcService, final DOMNotificationService notificationService, - final DOMMountPointService mountPointService) { + public RestConnectorProvider(final DOMDataBroker domDataBroker, + final SchemaService schemaService, final DOMRpcService rpcService, + final DOMNotificationService notificationService, final DOMMountPointService mountPointService, + final T wrapperServices) { + this.wrapperServices = Preconditions.checkNotNull(wrapperServices); this.schemaService = Preconditions.checkNotNull(schemaService); this.rpcService = Preconditions.checkNotNull(rpcService); this.notificationService = Preconditions.checkNotNull(notificationService); @@ -77,8 +80,6 @@ public class RestConnectorProvider implements RestconfConnector, AutoCloseable { } public void start() { - final ServicesWrapperImpl wrapperServices = ServicesWrapperImpl.getInstance(); - mountPointServiceHandler = new DOMMountPointServiceHandler(mountPointService); final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(dataBroker); diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServiceWrapper.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServiceWrapper.java new file mode 100644 index 0000000000..ee2538d7b0 --- /dev/null +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServiceWrapper.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.services.wrapper; + +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; + +public interface ServiceWrapper { + + void setHandlers(SchemaContextHandler schemaCtxHandler, DOMMountPointServiceHandler domMountPointServiceHandler, + TransactionChainHandler transactionChainHandler, DOMDataBrokerHandler domDataBrokerHandler, + RpcServiceHandler rpcServiceHandler, NotificationServiceHandler notificationServiceHandler); +} diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServicesWrapperImpl.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServicesWrapperImpl.java index 6bef1978af..1d585c5c8b 100644 --- a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServicesWrapperImpl.java +++ b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/services/wrapper/ServicesWrapperImpl.java @@ -44,7 +44,7 @@ import org.opendaylight.restconf.nb.rfc8040.services.simple.impl.RestconfSchemaS * */ @Path("/") -public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper { +public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper, ServiceWrapper { private RestconfDataService delegRestconfDataService; private RestconfInvokeOperationsService delegRestconfInvokeOpsService; @@ -135,6 +135,7 @@ public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServ return this.delegRestService.getLibraryVersion(); } + @Override public void setHandlers(final SchemaContextHandler schemaCtxHandler, final DOMMountPointServiceHandler domMountPointServiceHandler, final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler, diff --git a/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml b/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml index 7eda5a376f..6498a76aa6 100644 --- a/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml +++ b/restconf/restconf-nb-rfc8040/src/main/resources/org/opendaylight/blueprint/restconf-bp.xml @@ -36,6 +36,9 @@ + + @@ -43,6 +46,7 @@ + - - - + diff --git a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java index 6ed6fcff66..1fcc3e0024 100644 --- a/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java +++ b/restconf/restconf-nb-rfc8040/src/test/java/org/opendaylight/restconf/nb/rfc8040/RestConnectorProviderTest.java @@ -25,6 +25,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler; +import org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; @@ -55,7 +56,7 @@ public class RestConnectorProviderTest { Mockito.any(SchemaContextHandler.class)); this.connectorProvider = new RestConnectorProvider(mockDataBroker, mockSchemaService, mockRpcService, - mockNotificationService, mockMountPointService); + mockNotificationService, mockMountPointService, ServicesWrapperImpl.getInstance()); } /**