-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support JDK9 methods in CS/CF wrappers using a MR-JAR
- Loading branch information
Showing
19 changed files
with
422 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,22 +21,24 @@ on: | |
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
java: [8, 11] | ||
name: build with jdk ${{matrix.java}} | ||
name: build with JDK 11 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
name: checkout | ||
|
||
- uses: actions/[email protected] | ||
name: set up jdk ${{matrix.java}} | ||
name: set up JDK 11 | ||
with: | ||
java-version: ${{matrix.java}} | ||
java-version: 11 | ||
|
||
- uses: actions/[email protected] | ||
name: set up JDK 8 | ||
with: | ||
java-version: 8 | ||
|
||
- name: build with maven | ||
run: mvn -B formatter:validate verify --file pom.xml | ||
run: JAVA_HOME=$JAVA_HOME_11_X64 mvn -B formatter:validate verify --file pom.xml -Djava8.home=$JAVA_HOME_8_X64 | ||
|
||
quality: | ||
needs: [build] | ||
|
@@ -48,7 +50,7 @@ jobs: | |
- uses: actions/checkout@v2 | ||
- uses: actions/[email protected] | ||
with: | ||
java-version: 8 | ||
java-version: 11 | ||
|
||
- name: sonar | ||
env: | ||
|
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ jobs: | |
|
||
- uses: actions/[email protected] | ||
with: | ||
java-version: 8 | ||
java-version: 11 | ||
|
||
- name: maven release ${{steps.metadata.outputs.current-version}} | ||
run: | | ||
|
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,37 @@ | ||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> | ||
<id>mvjar</id> | ||
<formats> | ||
<format>jar</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<moduleSets> | ||
<moduleSet> | ||
<useAllReactorProjects>true</useAllReactorProjects> | ||
<includes> | ||
<include>io.smallrye:smallrye-context-propagation-java8</include> | ||
</includes> | ||
<binaries> | ||
<unpack>true</unpack> | ||
<includeDependencies>false</includeDependencies> | ||
</binaries> | ||
</moduleSet> | ||
<moduleSet> | ||
<useAllReactorProjects>true</useAllReactorProjects> | ||
<includes> | ||
<include>io.smallrye:smallrye-context-propagation-java9</include> | ||
</includes> | ||
<binaries> | ||
<outputDirectory>META-INF/versions/9</outputDirectory> | ||
<unpack>true</unpack> | ||
<includeDependencies>false</includeDependencies> | ||
<unpackOptions> | ||
<excludes> | ||
<exclude>/META-INF/**</exclude> | ||
</excludes> | ||
</unpackOptions> | ||
</binaries> | ||
</moduleSet> | ||
</moduleSets> | ||
</assembly> |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.smallrye.context; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.Executor; | ||
|
||
import io.smallrye.context.impl.JdkSpecificImpl; | ||
|
||
public class JdkSpecific { | ||
|
||
private final static JdkSpecificImpl impl = new JdkSpecificImpl(); | ||
|
||
public interface Contract { | ||
public <T> CompletionStage<T> newCompletionStageWrapper(SmallRyeThreadContext threadContext, | ||
CompletionStage<T> future); | ||
|
||
public <T> CompletableFuture<T> newCompletableFutureWrapper(SmallRyeThreadContext threadContext, | ||
CompletableFuture<T> future, Executor executor, boolean minimal); | ||
} | ||
|
||
public static <T> CompletionStage<T> newCompletionStageWrapper(SmallRyeThreadContext threadContext, | ||
CompletionStage<T> future) { | ||
return impl.newCompletionStageWrapper(threadContext, future); | ||
} | ||
|
||
public static <T> CompletableFuture<T> newCompletableFutureWrapper(SmallRyeThreadContext threadContext, | ||
CompletableFuture<T> future, Executor executor, boolean minimal) { | ||
return impl.newCompletableFutureWrapper(threadContext, future, executor, minimal); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
core/src/main/java/io/smallrye/context/impl/JdkSpecificImpl.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,25 @@ | ||
package io.smallrye.context.impl; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.Executor; | ||
|
||
import io.smallrye.context.CompletableFutureWrapper; | ||
import io.smallrye.context.CompletionStageWrapper; | ||
import io.smallrye.context.JdkSpecific; | ||
import io.smallrye.context.SmallRyeThreadContext; | ||
|
||
public class JdkSpecificImpl implements JdkSpecific.Contract { | ||
|
||
@Override | ||
public <T> CompletionStage<T> newCompletionStageWrapper(SmallRyeThreadContext threadContext, | ||
CompletionStage<T> future) { | ||
return new CompletionStageWrapper<>(threadContext, future); | ||
} | ||
|
||
@Override | ||
public <T> CompletableFuture<T> newCompletableFutureWrapper(SmallRyeThreadContext threadContext, | ||
CompletableFuture<T> future, Executor executor, boolean minimal) { | ||
return new CompletableFutureWrapper<>(threadContext, future, executor, minimal); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
core/src/main/java9/io/smallrye/context/Jdk9CompletableFutureWrapper.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,63 @@ | ||
package io.smallrye.context; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Supplier; | ||
|
||
public class Jdk9CompletableFutureWrapper<T> extends CompletableFutureWrapper<T> { | ||
|
||
public Jdk9CompletableFutureWrapper(SmallRyeThreadContext context, CompletableFuture<T> f, Executor executor, | ||
boolean minimal) { | ||
super(context, f, executor, minimal); | ||
} | ||
|
||
@Override | ||
public <U> CompletableFuture<U> newIncompleteFuture() { | ||
CompletableFuture<U> ret = new CompletableFuture<>(); | ||
return context.withContextCapture(ret, executor); | ||
} | ||
|
||
@Override | ||
public Executor defaultExecutor() { | ||
return executor; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> copy() { | ||
return context.withContextCapture(f.copy(), executor); | ||
} | ||
|
||
@Override | ||
public CompletionStage<T> minimalCompletionStage() { | ||
// this creates a new MinimalStage we need to wrap | ||
return context.withContextCapture(f.minimalCompletionStage()); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> completeAsync(Supplier<? extends T> supplier) { | ||
// just forward | ||
return context.withContextCapture(f.completeAsync(context.contextualSupplierUnlessContextualized(supplier), executor), | ||
executor); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> completeAsync(Supplier<? extends T> supplier, Executor executor) { | ||
// just forward | ||
return context.withContextCapture(f.completeAsync(context.contextualSupplierUnlessContextualized(supplier), executor), | ||
this.executor); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> orTimeout(long timeout, TimeUnit unit) { | ||
// just forward | ||
return context.withContextCapture(f.orTimeout(timeout, unit), executor); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit) { | ||
// just forward | ||
return context.withContextCapture(f.completeOnTimeout(value, timeout, unit), executor); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/src/main/java9/io/smallrye/context/impl/JdkSpecificImpl.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,26 @@ | ||
package io.smallrye.context.impl; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
import java.util.concurrent.Executor; | ||
|
||
import io.smallrye.context.CompletionStageWrapper; | ||
import io.smallrye.context.Jdk9CompletableFutureWrapper; | ||
import io.smallrye.context.JdkSpecific; | ||
import io.smallrye.context.SmallRyeThreadContext; | ||
|
||
public class JdkSpecificImpl implements JdkSpecific.Contract { | ||
|
||
@Override | ||
public <T> CompletionStage<T> newCompletionStageWrapper(SmallRyeThreadContext threadContext, | ||
CompletionStage<T> future) { | ||
return new CompletionStageWrapper<>(threadContext, future); | ||
} | ||
|
||
@Override | ||
public <T> CompletableFuture<T> newCompletableFutureWrapper(SmallRyeThreadContext threadContext, | ||
CompletableFuture<T> future, Executor executor, boolean minimal) { | ||
return new Jdk9CompletableFutureWrapper<>(threadContext, future, executor, minimal); | ||
} | ||
|
||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:weld="http://jboss.org/schema/weld/beans" | ||
xsi:schemaLocation=" | ||
http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd | ||
http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd"> | ||
<weld:scan> | ||
<!-- Don't let Arquillian choke on MR-Jars --> | ||
<weld:exclude weld:pattern="META-INF\.versions\..*"></weld:exclude> | ||
</weld:scan> | ||
</beans> |
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
Empty file.
Empty file.
Empty file.
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
Oops, something went wrong.