Remove SSEApplication 01/109101/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Nov 2023 16:08:20 +0000 (17:08 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Nov 2023 16:08:47 +0000 (17:08 +0100)
Use an anonymous Application subclass to tightly bind to the single
user.

JIRA: NETCONF-773
Change-Id: I38ae98f2c8e720785fbd7687ba8766e86419f6f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/DefaultRestconfStreamServletFactory.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/SSEApplication.java [deleted file]

index fc8a53e4a7b429332a1ef2325c288f9810c653ff..ed0a799bddd2b43ecb75a532bc3b6224beaab45a 100644 (file)
@@ -10,7 +10,9 @@ package org.opendaylight.restconf.nb.rfc8040.streams;
 import static java.util.Objects.requireNonNull;
 
 import java.util.Map;
+import java.util.Set;
 import javax.servlet.http.HttpServlet;
+import javax.ws.rs.core.Application;
 import org.opendaylight.aaa.web.servlet.ServletSupport;
 import org.opendaylight.restconf.server.spi.RestconfStream;
 import org.osgi.service.component.annotations.Activate;
@@ -62,8 +64,12 @@ public final class DefaultRestconfStreamServletFactory implements RestconfStream
     public HttpServlet newStreamServlet() {
         return useWebsockets ? new WebSocketInitializer(streamRegistry, pingExecutor, streamsConfiguration)
             : servletSupport.createHttpServletBuilder(
-                new SSEApplication(streamRegistry, pingExecutor, streamsConfiguration))
-            .build();
+                new Application() {
+                    @Override
+                    public Set<Object> getSingletons() {
+                        return Set.of(new SSEStreamService(streamRegistry, pingExecutor, streamsConfiguration));
+                    }
+                }).build();
     }
 
     @Override
diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/SSEApplication.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/streams/SSEApplication.java
deleted file mode 100644 (file)
index 5e8380e..0000000
+++ /dev/null
@@ -1,29 +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;
-
-import java.util.Set;
-import javax.ws.rs.core.Application;
-import org.opendaylight.restconf.server.spi.RestconfStream;
-
-/**
- * JAX-RS binding for Server-Sent Events.
- */
-final class SSEApplication extends Application {
-    private final SSEStreamService singleton;
-
-    SSEApplication(final RestconfStream.Registry streamRegistry, final PingExecutor pingExecutor,
-            final StreamsConfiguration configuration) {
-        singleton = new SSEStreamService(streamRegistry, pingExecutor, configuration);
-    }
-
-    @Override
-    public Set<Object> getSingletons() {
-        return Set.of(singleton);
-    }
-}