-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSE Flow.Subscriber injectable as event sink
* Java Flow api used only by JerseyEventSink in java 11+ * Reactive streams tck tests for JerseyEventSink * Cancel on close propagation * Remove tests contradicting reactive streams spec https://github.com/reactive-streams/reactive-streams-jvm#2.13 Signed-off-by: Daniel Kec <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,017 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core-common/src/main/java11/org/glassfish/jersey/internal/jsr166/JerseyFlowSubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.internal.jsr166; | ||
|
||
public interface JerseyFlowSubscriber<T> extends Flow.Subscriber<T>, java.util.concurrent.Flow.Subscriber<T> { | ||
@Override | ||
default void onSubscribe(java.util.concurrent.Flow.Subscription subscription) { | ||
this.onSubscribe(new Flow.Subscription() { | ||
@Override | ||
public void request(final long n) { | ||
subscription.request(n); | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
subscription.cancel(); | ||
} | ||
}); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
core-common/src/main/java8/org/glassfish/jersey/internal/jsr166/JerseyFlowSubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
|
||
package org.glassfish.jersey.internal.jsr166; | ||
|
||
public interface JerseyFlowSubscriber<T> extends Flow.Subscriber<T> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
core-server/src/main/java/org/glassfish/jersey/server/model/internal/SseTypeResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package org.glassfish.jersey.server.model.internal; | ||
|
||
import java.security.AccessController; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.glassfish.jersey.internal.util.ReflectionHelper; | ||
|
||
public final class SseTypeResolver { | ||
|
||
private static final Set<Class<?>> SUPPORTED_SSE_SINK_TYPES; | ||
|
||
private SseTypeResolver() { | ||
} | ||
|
||
static { | ||
Set<Class<?>> set = new HashSet<>(8); | ||
|
||
set.add(org.glassfish.jersey.internal.jsr166.Flow.Subscriber.class); | ||
set.add(javax.ws.rs.sse.SseEventSink.class); | ||
Class<?> clazz = AccessController | ||
.doPrivileged(ReflectionHelper.classForNamePA("java.util.concurrent.Flow$Subscriber", null)); | ||
|
||
if (clazz != null) { | ||
set.add(clazz); | ||
} | ||
SUPPORTED_SSE_SINK_TYPES = Collections.unmodifiableSet(set); | ||
} | ||
|
||
public static boolean isSseSinkParam(Class<?> type) { | ||
return SUPPORTED_SSE_SINK_TYPES.contains(type); | ||
} | ||
} |
Oops, something went wrong.