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;
* Provider for restconf draft18.
*
*/
-public class RestConnectorProvider implements RestconfConnector, AutoCloseable {
+public class RestConnectorProvider<T extends ServiceWrapper> implements RestconfConnector, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(RestConnectorProvider.class);
private final DOMRpcService rpcService;
private final DOMNotificationService notificationService;
private final DOMMountPointService mountPointService;
- private ListenerRegistration<SchemaContextListener> listenerRegistration;
+ private final T wrapperServices;
+ private ListenerRegistration<SchemaContextListener> 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);
}
public void start() {
- final ServicesWrapperImpl wrapperServices = ServicesWrapperImpl.getInstance();
-
mountPointServiceHandler = new DOMMountPointServiceHandler(mountPointService);
final DOMDataBrokerHandler brokerHandler = new DOMDataBrokerHandler(dataBroker);
--- /dev/null
+/*
+ * 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);
+}
*
*/
@Path("/")
-public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
+public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper, ServiceWrapper {
private RestconfDataService delegRestconfDataService;
private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
return this.delegRestService.getLibraryVersion();
}
+ @Override
public void setHandlers(final SchemaContextHandler schemaCtxHandler,
final DOMMountPointServiceHandler domMountPointServiceHandler,
final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
<reference id="domDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
ext:filter="(type=@{databroker-service-type})"/>
+ <bean id="wrapper" class="org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl"
+ factory-method="getInstance" />
+
<bean id="restconfProvider" class="org.opendaylight.restconf.nb.rfc8040.RestConnectorProvider"
init-method="start" destroy-method="close">
<argument ref="domDataBroker"/>
<argument ref="domRpcService"/>
<argument ref="domNotificationService"/>
<argument ref="domMountPointService"/>
+ <argument ref="wrapper"/>
</bean>
<service ref="restconfProvider"
<bean id="jsonRestconfService" depends-on="restconfProvider"
class="org.opendaylight.restconf.nb.rfc8040.rests.services.impl.JSONRestconfServiceRfc8040Impl"
destroy-method="close">
- <argument>
- <bean class="org.opendaylight.restconf.nb.rfc8040.services.wrapper.ServicesWrapperImpl"
- factory-method="getInstance" />
- </argument>
+ <argument ref="wrapper"/>
<argument>
<bean factory-ref="restconfProvider" factory-method="getMountPointServiceHandler" />
</argument>
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;
Mockito.any(SchemaContextHandler.class));
this.connectorProvider = new RestConnectorProvider(mockDataBroker, mockSchemaService, mockRpcService,
- mockNotificationService, mockMountPointService);
+ mockNotificationService, mockMountPointService, ServicesWrapperImpl.getInstance());
}
/**