diff --git a/jOOQ-reactor-extensions/.gitignore b/jOOQ-reactor-extensions/.gitignore new file mode 100644 index 0000000000..4b664f2ce0 --- /dev/null +++ b/jOOQ-reactor-extensions/.gitignore @@ -0,0 +1,3 @@ +/target +/.idea +/*.iml diff --git a/jOOQ-reactor-extensions/LICENSE.txt b/jOOQ-reactor-extensions/LICENSE.txt new file mode 100644 index 0000000000..f760207dfa --- /dev/null +++ b/jOOQ-reactor-extensions/LICENSE.txt @@ -0,0 +1,19 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Other licenses: +----------------------------------------------------------------------------- +Commercial licenses for this work are available. These replace the above +Apache-2.0 license and offer limited warranties, support, maintenance, and +commercial database integrations. + +For more information, please visit: https://www.jooq.org/legal/licensing \ No newline at end of file diff --git a/jOOQ-reactor-extensions/NOTICE.txt b/jOOQ-reactor-extensions/NOTICE.txt new file mode 100644 index 0000000000..698edf47ee --- /dev/null +++ b/jOOQ-reactor-extensions/NOTICE.txt @@ -0,0 +1,10 @@ +Third party NOTICE.txt contents +=============================== + +Contents of https://github.com/apache/commons-lang/blob/master/NOTICE.txt +------------------------------------------------------------------------- +Apache Commons Lang +Copyright 2001-2019 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/jOOQ-reactor-extensions/pom.xml b/jOOQ-reactor-extensions/pom.xml new file mode 100644 index 0000000000..31c5efc193 --- /dev/null +++ b/jOOQ-reactor-extensions/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + + org.jooq + jooq-parent + 3.20.0-SNAPSHOT + + + jooq-reactor-extensions + jOOQ Reactor Extensions + jOOQ's utilities for Reactor integration + + + + Apache License, Version 2.0 + https://www.jooq.org/inc/LICENSE.txt + repo + + + + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.jooq.reactor.extensions + + + + + + + + + + org.jooq + jooq + + + org.jetbrains + annotations + provided + true + + + io.projectreactor + reactor-core + + + + + + + + + + + + diff --git a/jOOQ-reactor-extensions/src/main/java/module-info.java b/jOOQ-reactor-extensions/src/main/java/module-info.java new file mode 100644 index 0000000000..c3bdf1ba33 --- /dev/null +++ b/jOOQ-reactor-extensions/src/main/java/module-info.java @@ -0,0 +1,15 @@ +/** + * The jOOQ reactor extensions module. + */ +module org.jooq.reactor.extensions { + + // Other jOOQ modules + requires transitive org.jooq; + + // Nullability annotations for better Kotlin interop + requires static org.jetbrains.annotations; + + requires transitive reactor.core; + + exports org.jooq.reactor.extensions; +} diff --git a/jOOQ-reactor-extensions/src/main/java/org/jooq/reactor/extensions/CoreSubscriberProvider.java b/jOOQ-reactor-extensions/src/main/java/org/jooq/reactor/extensions/CoreSubscriberProvider.java new file mode 100644 index 0000000000..c90fb3f7a7 --- /dev/null +++ b/jOOQ-reactor-extensions/src/main/java/org/jooq/reactor/extensions/CoreSubscriberProvider.java @@ -0,0 +1,113 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * Apache-2.0 license and offer limited warranties, support, maintenance, and + * commercial database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.reactor.extensions; + +import java.util.function.Consumer; + +import org.jooq.SubscriberProvider; + +import org.reactivestreams.Subscriber; +import org.reactivestreams.Subscription; + +import reactor.core.CoreSubscriber; +import reactor.util.context.Context; + +/** + * A reactor {@link Context} aware implementation of the + * {@link SubscriberProvider} SPI. + *

+ * This implementation helps jOOQ wrap all of its internal {@link Subscriber} + * instances in a {@link CoreSubscriber}, which allows for reactor context + * propagation. + * + * @author Lukas Eder + */ +public class CoreSubscriberProvider implements SubscriberProvider { + + @Override + public Context context() { + return Context.empty(); + } + + @Override + public Context context(Subscriber subscriber) { + if (subscriber instanceof CoreSubscriber c) + return c.currentContext(); + else + return context(); + } + + @Override + public Subscriber subscriber( + Consumer onSubscribe, + Consumer onNext, + Consumer onError, + Runnable onComplete, + Context context + ) { + return new CoreSubscriber() { + + @Override + public Context currentContext() { + return context != null + ? context + : context(); + } + + @Override + public void onNext(T t) { + onNext.accept(t); + } + + @Override + public void onError(Throwable t) { + onError.accept(t); + } + + @Override + public void onComplete() { + onComplete.run(); + } + + @Override + public void onSubscribe(Subscription s) { + onSubscribe.accept(s); + } + }; + } +} diff --git a/jOOQ-reactor-extensions/src/main/resources/META-INF/LICENSE.txt b/jOOQ-reactor-extensions/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..f760207dfa --- /dev/null +++ b/jOOQ-reactor-extensions/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,19 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Other licenses: +----------------------------------------------------------------------------- +Commercial licenses for this work are available. These replace the above +Apache-2.0 license and offer limited warranties, support, maintenance, and +commercial database integrations. + +For more information, please visit: https://www.jooq.org/legal/licensing \ No newline at end of file diff --git a/jOOQ-reactor-extensions/src/main/resources/META-INF/README.txt b/jOOQ-reactor-extensions/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..3e6e227e05 --- /dev/null +++ b/jOOQ-reactor-extensions/src/main/resources/META-INF/README.txt @@ -0,0 +1,2 @@ +Thanks for downloading jOOQ. +Please visit http://www.jooq.org for more information. \ No newline at end of file diff --git a/pom.xml b/pom.xml index ad380d52c9..8b97cecfd2 100644 --- a/pom.xml +++ b/pom.xml @@ -131,6 +131,11 @@ jooq-postgres-extensions ${project.version} + + org.jooq + jooq-reactor-extensions + ${project.version} + org.jooq jooq-jackson-extensions @@ -860,6 +865,7 @@ jOOQ-jackson-extensions jOOQ-jpa-extensions jOOQ-postgres-extensions + jOOQ-reactor-extensions jOOQ-meta jOOQ-meta-extensions