-
Notifications
You must be signed in to change notification settings - Fork 4
bug: fix #9 - Add quarkus-jackson-jq as ExpressionFactory; Add ServiceProviderBuildItem #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
56 changes: 44 additions & 12 deletions
56
core/deployment/src/main/java/io/quarkiverse/flow/deployment/FlowNativeProcessor.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,26 +1,58 @@ | ||
| package io.quarkiverse.flow.deployment; | ||
|
|
||
| import com.github.f4b6a3.ulid.UlidCreator; | ||
| import com.github.f4b6a3.ulid.UlidFactory; | ||
|
|
||
| import io.quarkus.deployment.annotations.BuildProducer; | ||
| import io.quarkus.deployment.annotations.BuildStep; | ||
| import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; | ||
| import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; | ||
| import io.serverlessworkflow.impl.events.EventConsumer; | ||
| import io.serverlessworkflow.impl.events.EventPublisher; | ||
| import io.serverlessworkflow.impl.events.InMemoryEvents; | ||
| import io.serverlessworkflow.impl.executors.DefaultTaskExecutorFactory; | ||
| import io.serverlessworkflow.impl.executors.TaskExecutorFactory; | ||
| import io.serverlessworkflow.impl.expressions.ExpressionFactory; | ||
| import io.serverlessworkflow.impl.expressions.jq.JQExpressionFactory; | ||
| import io.serverlessworkflow.impl.jackson.schema.JsonSchemaValidatorFactory; | ||
| import io.serverlessworkflow.impl.schema.SchemaValidatorFactory; | ||
|
|
||
| /** | ||
| * see <a href="https://github.com/serverlessworkflow/sdk-java/issues/812">Native-image build fails due to UlidCreator static | ||
| * initialization (Random in image heap)</a> | ||
| */ | ||
| final class FlowNativeProcessor { | ||
| @BuildStep | ||
| RuntimeInitializedClassBuildItem ulidCreatorHolder() { | ||
| return new RuntimeInitializedClassBuildItem("com.github.f4b6a3.ulid.UlidCreator$MonotonicFactoryHolder"); | ||
| } | ||
|
|
||
| /** | ||
| * see <a href="https://github.com/serverlessworkflow/sdk-java/issues/812">Native-image build fails due to UlidCreator | ||
| * static | ||
| * initialization (Random in image heap)</a> | ||
| */ | ||
| @BuildStep | ||
| RuntimeInitializedClassBuildItem ulidCreator() { | ||
| return new RuntimeInitializedClassBuildItem("com.github.f4b6a3.ulid.UlidCreator"); | ||
| void runtimeInitUlid(BuildProducer<RuntimeInitializedClassBuildItem> producer) { | ||
| producer.produce(new RuntimeInitializedClassBuildItem( | ||
| "com.github.f4b6a3.ulid.UlidCreator$MonotonicFactoryHolder")); | ||
| producer.produce(new RuntimeInitializedClassBuildItem( | ||
| com.github.f4b6a3.ulid.UlidCreator.class.getName())); | ||
| producer.produce(new RuntimeInitializedClassBuildItem( | ||
| com.github.f4b6a3.ulid.UlidFactory.class.getName())); | ||
| } | ||
|
|
||
| /** | ||
| * Registers the CNCF Java SDK default providers for native compilation. | ||
| */ | ||
| @BuildStep | ||
| RuntimeInitializedClassBuildItem ulidFactory() { | ||
| return new RuntimeInitializedClassBuildItem("com.github.f4b6a3.ulid.UlidFactory"); | ||
| void registerSDKServiceProviders(BuildProducer<ServiceProviderBuildItem> sp) { | ||
|
|
||
| // TODO: make all of them @DefaultBeans so users can easily replace | ||
| // TODO: these providers must be compatible with Quarkus Ecosystem | ||
|
|
||
| sp.produce(new ServiceProviderBuildItem(ExpressionFactory.class.getName(), | ||
| JQExpressionFactory.class.getName())); | ||
| sp.produce(new ServiceProviderBuildItem(TaskExecutorFactory.class.getName(), | ||
| DefaultTaskExecutorFactory.class.getName())); | ||
| sp.produce(new ServiceProviderBuildItem(SchemaValidatorFactory.class.getName(), | ||
| JsonSchemaValidatorFactory.class.getName())); | ||
| sp.produce(new ServiceProviderBuildItem(EventConsumer.class.getName(), | ||
| InMemoryEvents.class.getName())); | ||
| sp.produce(new ServiceProviderBuildItem(EventPublisher.class.getName(), | ||
| InMemoryEvents.class.getName())); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
17 changes: 0 additions & 17 deletions
17
...runtime/src/main/java/io/quarkiverse/flow/producers/DefaultExpressionFactoryProducer.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...me/src/main/java/io/quarkiverse/flow/producers/DefaultSchemaValidatorFactoryProducer.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...ntime/src/main/java/io/quarkiverse/flow/producers/DefaultTaskExecutorFactoryProducer.java
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
core/runtime/src/main/java/io/quarkiverse/flow/producers/InMemoryEventsBean.java
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
core/runtime/src/main/java/io/quarkiverse/flow/providers/QuarkusJQExpressionFactory.java
This file contains hidden or 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 @@ | ||
| package io.quarkiverse.flow.providers; | ||
|
|
||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import jakarta.inject.Inject; | ||
|
|
||
| import io.quarkus.arc.DefaultBean; | ||
| import io.serverlessworkflow.impl.expressions.ExpressionUtils; | ||
| import io.serverlessworkflow.impl.expressions.ObjectExpression; | ||
| import io.serverlessworkflow.impl.expressions.jq.JQExpression; | ||
| import io.serverlessworkflow.impl.expressions.jq.JQExpressionFactory; | ||
| import net.thisptr.jackson.jq.Scope; | ||
| import net.thisptr.jackson.jq.Versions; | ||
| import net.thisptr.jackson.jq.exception.JsonQueryException; | ||
|
|
||
| @ApplicationScoped | ||
| @DefaultBean | ||
| public class QuarkusJQExpressionFactory extends JQExpressionFactory { | ||
|
|
||
| @Inject | ||
| Scope scope; // provided by quarkus-jackson-jq | ||
|
|
||
| public QuarkusJQExpressionFactory() { | ||
| } | ||
|
|
||
| @Override | ||
| public ObjectExpression buildExpression(String expression) { | ||
| try { | ||
| return new JQExpression(() -> scope, ExpressionUtils.trimExpr(expression), Versions.JQ_1_6); | ||
| } catch (JsonQueryException e) { | ||
| throw new IllegalArgumentException(e); | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.