Remove SSEInitializer 03/96203/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 17 May 2021 10:32:39 +0000 (12:32 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 17 May 2021 10:33:31 +0000 (12:33 +0200)
SSEInitializer is a simple indirection between RestconfDataStreamServiceImpl
and streams.Configuration. Eliminate the indirection.

JIRA: NETCONF-773
Change-Id: I88429d8a58720589fd73f1c6da7cb3d2176bf88f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/api/RestconfDataStreamService.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/RestconfDataStreamServiceImpl.java
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/sse/SSEInitializer.java [deleted file]

index aa7a470f8867fc3101b597ce8477860308076507..1940586786235c09203a497cbd80de0f06b29145 100644 (file)
@@ -21,15 +21,12 @@ public interface RestconfDataStreamService {
     /**
      * Get target data resource.
      *
-     * @param identifier
-     *            path to target
-     * @param uriInfo
-     *            URI info
+     * @param identifier path to target
+     * @param uriInfo URI info
      * @return {@link EventOutput}
      */
     @GET
     @Path("/{identifier:.+}")
     @Produces(SseFeature.SERVER_SENT_EVENTS)
     EventOutput getSSE(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
-
 }
index 85c6cfbdb1109409790370cb2c4a69d77be9542e..6befc2576346ddaeb633c214c44e7d1927dbe40b 100644 (file)
@@ -12,13 +12,14 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.ws.rs.core.UriInfo;
 import org.glassfish.jersey.media.sse.EventOutput;
+import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
 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.rests.services.api.RestconfDataStreamService;
+import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
 import org.opendaylight.restconf.nb.rfc8040.streams.listeners.BaseListenerInterface;
 import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenersBroker;
-import org.opendaylight.restconf.nb.rfc8040.streams.sse.SSEInitializer;
 import org.opendaylight.restconf.nb.rfc8040.streams.sse.SSESessionHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,8 +37,9 @@ public class RestconfDataStreamServiceImpl implements RestconfDataStreamService
     private final int heartbeatInterval;
 
     @Inject
-    public RestconfDataStreamServiceImpl(final SSEInitializer configuration) {
-        executorService = configuration.getExecutorService();
+    public RestconfDataStreamServiceImpl(final ScheduledThreadPool scheduledThreadPool,
+            final Configuration configuration) {
+        executorService = scheduledThreadPool.getExecutor();
         heartbeatInterval = configuration.getHeartbeatInterval();
         maximumFragmentLength = configuration.getMaximumFragmentLength();
     }
diff --git a/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/sse/SSEInitializer.java b/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/sse/SSEInitializer.java
deleted file mode 100644 (file)
index 763cfee..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.streams.sse;
-
-import java.util.concurrent.ScheduledExecutorService;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
-import org.opendaylight.restconf.nb.rfc8040.streams.Configuration;
-
-/**
- * Holder of configuration for SSE.
- */
-@Singleton
-public class SSEInitializer {
-    private final ScheduledExecutorService executorService;
-    private final int maximumFragmentLength;
-    private final int heartbeatInterval;
-
-    /**
-     * Creation of the SSE initializer.
-     *
-     * @param scheduledThreadPool    ODL thread pool used for fetching of scheduled executors.
-     * @param configuration          Connection configuration holder.
-     */
-    @Inject
-    public SSEInitializer(final ScheduledThreadPool scheduledThreadPool, final Configuration configuration) {
-        this.executorService = scheduledThreadPool.getExecutor();
-        this.maximumFragmentLength = configuration.getMaximumFragmentLength();
-        this.heartbeatInterval = configuration.getHeartbeatInterval();
-    }
-
-    /**
-     * Getter for ScheduledExecutorService.
-     */
-    public ScheduledExecutorService getExecutorService() {
-        return executorService;
-    }
-
-    /**
-     * Getter for Maximum Fragment Length.
-     */
-    public int getMaximumFragmentLength() {
-        return maximumFragmentLength;
-    }
-
-    /**
-     * Getter for Heartbeat Interval.
-     */
-    public int getHeartbeatInterval() {
-        return heartbeatInterval;
-    }
-}