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.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
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.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
public Rfc8040RestConfWiring(final SchemaContextHandler schemaCtxHandler,
final DOMMountPointServiceHandler domMountPointServiceHandler,
final TransactionChainHandler transactionChainHandler,
- final DOMDataBrokerHandler domDataBrokerHandler, @Reference final DOMRpcService rpcService,
+ // Note: DOMDataBroker is not @Reference, because there is funkiness in the hand-written
+ // blueprint container.
+ final DOMDataBroker dataBroker,
+ @Reference final DOMRpcService rpcService,
@Reference final DOMActionService actionService,
@Reference final DOMNotificationService notificationService,
final SSEInitializer sseInit,
final Configuration configuration,
@Reference final DOMSchemaService domSchemaService) {
servicesWrapper = ServicesWrapper.newInstance(schemaCtxHandler, domMountPointServiceHandler,
- transactionChainHandler, domDataBrokerHandler, rpcService, actionService, notificationService,
+ transactionChainHandler, dataBroker, rpcService, actionService, notificationService,
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 static java.util.Objects.requireNonNull;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-
-/**
- * Implementation of {@link DOMDataBrokerHandler}.
- */
-// FIXME: remove this class
-@Singleton
-public class DOMDataBrokerHandler {
- private final DOMDataBroker broker;
-
- @Inject
- public DOMDataBrokerHandler(final DOMDataBroker broker) {
- this.broker = requireNonNull(broker);
- }
-
- public @NonNull DOMDataBroker get() {
- return broker;
- }
-}
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.nb.rfc8040.handlers.DOMDataBrokerHandler;
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.RestconfStreamsSubscriptionService;
/**
* Initialize holder of handlers with holders as parameters.
*
- * @param domDataBrokerHandler
- * handler of {@link DOMDataBroker}
- * @param notificationService
- * handler of {@link DOMNotificationService}
+ * @param dataBroker {@link DOMDataBroker}
+ * @param notificationService {@link DOMNotificationService}
* @param schemaHandler
* handler of {@link SchemaContext}
* @param transactionChainHandler
* @param configuration
* configuration for restconf {@link Configuration}}
*/
- public RestconfStreamsSubscriptionServiceImpl(final DOMDataBrokerHandler domDataBrokerHandler,
+ public RestconfStreamsSubscriptionServiceImpl(final DOMDataBroker dataBroker,
final DOMNotificationService notificationService, final SchemaContextHandler schemaHandler,
final TransactionChainHandler transactionChainHandler, final Configuration configuration) {
- this.handlersHolder = new HandlersHolder(domDataBrokerHandler, notificationService,
+ this.handlersHolder = new HandlersHolder(dataBroker, notificationService,
transactionChainHandler, schemaHandler);
streamUtils = configuration.isUseSSE() ? SubscribeToStreamUtil.serverSentEvents()
: SubscribeToStreamUtil.webSockets();
*/
// FIXME: why do we even need this class?!
public static final class HandlersHolder {
- private final DOMDataBrokerHandler domDataBrokerHandler;
+ private final DOMDataBroker dataBroker;
private final DOMNotificationService notificationService;
private final TransactionChainHandler transactionChainHandler;
private final SchemaContextHandler schemaHandler;
- private HandlersHolder(final DOMDataBrokerHandler domDataBrokerHandler,
- final DOMNotificationService notificationService,
+ private HandlersHolder(final DOMDataBroker dataBroker, final DOMNotificationService notificationService,
final TransactionChainHandler transactionChainHandler, final SchemaContextHandler schemaHandler) {
- this.domDataBrokerHandler = domDataBrokerHandler;
+ this.dataBroker = dataBroker;
this.notificationService = notificationService;
this.transactionChainHandler = transactionChainHandler;
this.schemaHandler = schemaHandler;
}
/**
- * Get {@link DOMDataBrokerHandler}.
+ * Get {@link DOMDataBroker}.
*
- * @return the domDataBrokerHandler
+ * @return the dataBroker
*/
- public DOMDataBrokerHandler getDomDataBrokerHandler() {
- return this.domDataBrokerHandler;
+ public DOMDataBroker getDataBroker() {
+ return this.dataBroker;
}
/**
notificationQueryParams.getFilter().orElse(null),
false, notificationQueryParams.isSkipNotificationData());
listener.get().setCloseVars(handlersHolder.getTransactionChainHandler(), handlersHolder.getSchemaHandler());
- registration(datastoreType, listener.get(), handlersHolder.getDomDataBrokerHandler().get());
+ registration(datastoreType, listener.get(), handlersHolder.getDataBroker());
final URI uri = prepareUriByStreamName(uriInfo, streamName);
final DOMTransactionChain transactionChain = handlersHolder.getTransactionChainHandler().get();
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.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.common.patch.PatchStatusContext;
import org.opendaylight.restconf.common.schema.SchemaExportContext;
-import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
public static ServicesWrapper newInstance(final SchemaContextHandler schemaCtxHandler,
final DOMMountPointServiceHandler domMountPointServiceHandler,
- final TransactionChainHandler transactionChainHandler, final DOMDataBrokerHandler domDataBrokerHandler,
+ final TransactionChainHandler transactionChainHandler, final DOMDataBroker dataBroker,
final DOMRpcService rpcService, final DOMActionService actionService,
final DOMNotificationService notificationService, final DOMSchemaService domSchemaService,
final Configuration configuration) {
RestconfSchemaService restconfSchemaService = new RestconfSchemaServiceImpl(schemaCtxHandler,
domMountPointServiceHandler, yangTextSourceProvider);
RestconfStreamsSubscriptionService restconfSubscrService = new RestconfStreamsSubscriptionServiceImpl(
- domDataBrokerHandler, notificationService, schemaCtxHandler, transactionChainHandler,
- configuration);
+ dataBroker, notificationService, schemaCtxHandler, transactionChainHandler, configuration);
RestconfDataService restconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
domMountPointServiceHandler, restconfSubscrService, actionService, configuration);
RestconfInvokeOperationsService restconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcService,
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.util.SimpleUriInfo;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
-import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.TransactionChainHandler;
import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
+ "toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE";
@Mock
- private DOMDataBrokerHandler dataBrokerHandler;
+ private DOMDataBroker dataBroker;
@Mock
private UriInfo uriInfo;
@Mock
when(domTx.newReadWriteTransaction()).thenReturn(rwTx);
doReturn(CommitInfo.emptyFluentFuture()).when(wTx).commit();
- final DOMDataBroker dataBroker = mock(DOMDataBroker.class);
doReturn(domTx).when(dataBroker).createTransactionChain(any());
transactionHandler = new TransactionChainHandler(dataBroker);
doReturn(ImmutableClassToInstanceMap.of(DOMDataTreeChangeService.class, dataTreeChangeService))
.when(dataBroker).getExtensions();
- doReturn(dataBroker).when(this.dataBrokerHandler).get();
-
final MultivaluedMap<String, String> map = mock(MultivaluedMap.class);
final Set<Entry<String, List<String>>> set = new HashSet<>();
when(map.entrySet()).thenReturn(set);
@Test
public void testSubscribeToStreamSSE() {
- final UriBuilder uriBuilder = UriBuilder.fromUri(URI);
ListenersBroker.getInstance().registerDataChangeListener(
IdentifierCodec.deserialize("toaster:toaster/toasterStatus", this.schemaHandler.get()),
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
NotificationOutputType.XML);
final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
- new RestconfStreamsSubscriptionServiceImpl(this.dataBrokerHandler, this.notificationService,
+ new RestconfStreamsSubscriptionServiceImpl(this.dataBroker, this.notificationService,
this.schemaHandler, this.transactionHandler, configurationSse);
final NormalizedNodeContext response = streamsSubscriptionService
.subscribeToStream(
@Test
public void testSubscribeToStreamWS() {
- final UriBuilder uriBuilder = UriBuilder.fromUri(URI);
ListenersBroker.getInstance().registerDataChangeListener(
IdentifierCodec.deserialize("toaster:toaster/toasterStatus", this.schemaHandler.get()),
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
NotificationOutputType.XML);
final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
- new RestconfStreamsSubscriptionServiceImpl(this.dataBrokerHandler, this.notificationService,
+ new RestconfStreamsSubscriptionServiceImpl(this.dataBroker, this.notificationService,
this.schemaHandler, this.transactionHandler, configurationWs);
final NormalizedNodeContext response = streamsSubscriptionService
.subscribeToStream(
@Test(expected = RestconfDocumentedException.class)
public void testSubscribeToStreamMissingDatastoreInPath() {
final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
- new RestconfStreamsSubscriptionServiceImpl(this.dataBrokerHandler, this.notificationService,
+ new RestconfStreamsSubscriptionServiceImpl(this.dataBroker, this.notificationService,
this.schemaHandler, this.transactionHandler, configurationWs);
streamsSubscriptionService.subscribeToStream("toaster:toaster/toasterStatus/scope=ONE", this.uriInfo);
}
@Test(expected = RestconfDocumentedException.class)
public void testSubscribeToStreamMissingScopeInPath() {
final RestconfStreamsSubscriptionServiceImpl streamsSubscriptionService =
- new RestconfStreamsSubscriptionServiceImpl(this.dataBrokerHandler, this.notificationService,
+ new RestconfStreamsSubscriptionServiceImpl(this.dataBroker, this.notificationService,
this.schemaHandler, this.transactionHandler, configurationWs);
streamsSubscriptionService.subscribeToStream("toaster:toaster/toasterStatus/datastore=OPERATIONAL",
this.uriInfo);