+++ /dev/null
-/*
- * Copyright (c) 2020 Lumina Networks, Inc. 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;
-
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
-import java.util.Set;
-import javax.ws.rs.core.Application;
-import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyWriter;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonPatchStatusBodyWriter;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyWriter;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlPatchStatusBodyWriter;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.YangSchemaExportBodyWriter;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.YinSchemaExportBodyWriter;
-import org.opendaylight.restconf.nb.rfc8040.jersey.providers.errors.RestconfDocumentedExceptionMapper;
-
-/**
- * Abstract Restconf Application.
- */
-abstract class AbstractRestconfApplication extends Application {
- private final DatabindProvider databindProvider;
- private final List<Object> services;
-
- AbstractRestconfApplication(final DatabindProvider databindProvider, final List<Object> services) {
- this.databindProvider = requireNonNull(databindProvider);
- this.services = requireNonNull(services);
- }
-
- @Override
- public final Set<Class<?>> getClasses() {
- return Set.of(
- JsonNormalizedNodeBodyWriter.class, XmlNormalizedNodeBodyWriter.class,
- YinSchemaExportBodyWriter.class, YangSchemaExportBodyWriter.class,
- JsonPatchStatusBodyWriter.class, XmlPatchStatusBodyWriter.class);
- }
-
- @Override
- public final Set<Object> getSingletons() {
- return ImmutableSet.<Object>builderWithExpectedSize(services.size() + 1)
- .addAll(services)
- .add(new RestconfDocumentedExceptionMapper(databindProvider))
- .build();
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2020 Lumina Networks, Inc. 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;
-
-import java.util.List;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
-import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataStreamServiceImpl;
-
-/**
- * Restconf Application extends {@link AbstractRestconfApplication}. Is used for sending SSE.
- */
-@Singleton
-public class DataStreamApplication extends AbstractRestconfApplication {
- @Inject
- public DataStreamApplication(final DatabindProvider databindProvider,
- final RestconfDataStreamServiceImpl dataStreamService) {
- super(databindProvider, List.of(dataStreamService));
- }
-}
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.MdsalRestconfServer;
-import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataStreamServiceImpl;
import org.opendaylight.restconf.nb.rfc8040.streams.ListenersBroker;
import org.opendaylight.restconf.nb.rfc8040.streams.RestconfStreamsConstants;
import org.opendaylight.restconf.nb.rfc8040.streams.StreamsConfiguration;
streamServlet = ServletDetails.builder()
.addUrlPattern("/" + URLConstants.SSE_SUBPATH + "/*")
.servlet(servletSupport.createHttpServletBuilder(
- new DataStreamApplication(databindProvider,
- new RestconfDataStreamServiceImpl(scheduledThreadPool, listenersBroker, streamsConfiguration)))
+ new ServerSentEventsApplication(scheduledThreadPool, listenersBroker, streamsConfiguration))
.build())
.name("notificationServlet")
.asyncSupported(true)
*/
package org.opendaylight.restconf.nb.rfc8040;
-import java.util.List;
-import javax.inject.Inject;
-import javax.inject.Singleton;
+import java.util.Set;
+import javax.ws.rs.core.Application;
import org.opendaylight.mdsal.dom.api.DOMActionService;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonNormalizedNodeBodyWriter;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.JsonPatchStatusBodyWriter;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlNormalizedNodeBodyWriter;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.XmlPatchStatusBodyWriter;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.YangSchemaExportBodyWriter;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.YinSchemaExportBodyWriter;
+import org.opendaylight.restconf.nb.rfc8040.jersey.providers.errors.RestconfDocumentedExceptionMapper;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.MdsalRestconfServer;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataServiceImpl;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfImpl;
import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfStreamsSubscriptionServiceImpl;
import org.opendaylight.restconf.nb.rfc8040.streams.ListenersBroker;
-@Singleton
-public class RestconfApplication extends AbstractRestconfApplication {
- @Inject
- public RestconfApplication(final DatabindProvider databindProvider, final MdsalRestconfServer server,
+final class RestconfApplication extends Application {
+ private final Set<Object> singletons;
+
+ RestconfApplication(final DatabindProvider databindProvider, final MdsalRestconfServer server,
final DOMMountPointService mountPointService, final DOMDataBroker dataBroker,
final DOMActionService actionService, final DOMNotificationService notificationService,
final DOMSchemaService domSchemaService, final ListenersBroker listenersBroker) {
- super(databindProvider, List.of(
+ singletons = Set.of(
+ new RestconfDocumentedExceptionMapper(databindProvider),
// FIXME: NETCONF:1102: do not instantiate this service
new RestconfStreamsSubscriptionServiceImpl(dataBroker, notificationService, databindProvider,
listenersBroker),
new RestconfInvokeOperationsServiceImpl(databindProvider, server, mountPointService, listenersBroker),
new RestconfOperationsServiceImpl(databindProvider, server),
new RestconfSchemaServiceImpl(domSchemaService, mountPointService),
- new RestconfImpl(databindProvider)));
+ new RestconfImpl(databindProvider));
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return Set.of(
+ JsonNormalizedNodeBodyWriter.class, XmlNormalizedNodeBodyWriter.class,
+ YinSchemaExportBodyWriter.class, YangSchemaExportBodyWriter.class,
+ JsonPatchStatusBodyWriter.class, XmlPatchStatusBodyWriter.class);
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return singletons;
}
}
--- /dev/null
+/*
+ * Copyright (c) 2020 Lumina Networks, Inc. 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;
+
+import java.util.Set;
+import javax.ws.rs.core.Application;
+import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
+import org.opendaylight.restconf.nb.rfc8040.rests.services.impl.RestconfDataStreamServiceImpl;
+import org.opendaylight.restconf.nb.rfc8040.streams.ListenersBroker;
+import org.opendaylight.restconf.nb.rfc8040.streams.StreamsConfiguration;
+
+/**
+ * JAX-RS binding for Server-Sent Events.
+ */
+final class ServerSentEventsApplication extends Application {
+ private final RestconfDataStreamServiceImpl singleton;
+
+ ServerSentEventsApplication(final ScheduledThreadPool scheduledThreadPool, final ListenersBroker listenersBroker,
+ final StreamsConfiguration configuration) {
+ singleton = new RestconfDataStreamServiceImpl(scheduledThreadPool, listenersBroker, configuration);
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return Set.of(singleton);
+ }
+}
import static java.util.Objects.requireNonNull;
import java.util.concurrent.ScheduledExecutorService;
-import javax.inject.Inject;
-import javax.inject.Singleton;
import javax.ws.rs.Encoded;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
* Access to notification streams via Server-Sent Events.
*/
@Path("/")
-@Singleton
public final class RestconfDataStreamServiceImpl {
private static final Logger LOG = LoggerFactory.getLogger(RestconfDataStreamServiceImpl.class);
private final int maximumFragmentLength;
private final int heartbeatInterval;
- @Inject
public RestconfDataStreamServiceImpl(final ScheduledThreadPool scheduledThreadPool,
final ListenersBroker listenersBroker, final StreamsConfiguration configuration) {
executorService = scheduledThreadPool.getExecutor();