Skip to content

Commit d6b21b8

Browse files
authored
Merge pull request #476 from fjtirado/Fix_#473
[Fix #473] Refactor project structure
2 parents 076911a + fa3d1d3 commit d6b21b8

File tree

64 files changed

+535
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+535
-245
lines changed

api/pom.xml

-71
Original file line numberDiff line numberDiff line change
@@ -121,77 +121,6 @@
121121
</execution>
122122
</executions>
123123
</plugin>
124-
<plugin>
125-
<groupId>org.apache.maven.plugins</groupId>
126-
<artifactId>maven-checkstyle-plugin</artifactId>
127-
<configuration>
128-
<checkstyleRules>
129-
<module name="Checker">
130-
<module name="RegexpHeader">
131-
<property name="header" value="${checkstyle.header.template}" />
132-
<property name="fileExtensions" value="${checkstyle.header.extensions}" />
133-
</module>
134-
<module name="TreeWalker">
135-
<module name="RegexpSinglelineJava">
136-
<property name="format" value="@author" />
137-
<property name="message" value="No @author tag allowed" />
138-
</module>
139-
</module>
140-
</module>
141-
</checkstyleRules>
142-
<outputFile>${project.build.directory}/checkstyle.log</outputFile>
143-
<includeTestSourceDirectory>true</includeTestSourceDirectory>
144-
<includeResources>true</includeResources>
145-
<includeTestResources>true</includeTestResources>
146-
<consoleOutput>false</consoleOutput>
147-
<failsOnError>false</failsOnError>
148-
<logViolationsToConsole>${checkstyle.logViolationsToConsole}</logViolationsToConsole>
149-
<failOnViolation>${checkstyle.failOnViolation}</failOnViolation>
150-
<sourceDirectories>
151-
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
152-
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
153-
</sourceDirectories>
154-
</configuration>
155-
<executions>
156-
<execution>
157-
<phase>compile</phase>
158-
<goals>
159-
<goal>check</goal>
160-
</goals>
161-
</execution>
162-
</executions>
163-
</plugin>
164-
<plugin>
165-
<groupId>com.spotify.fmt</groupId>
166-
<artifactId>fmt-maven-plugin</artifactId>
167-
<configuration>
168-
<sourceDirectory>src/main/java</sourceDirectory>
169-
<testSourceDirectory>src/test/java</testSourceDirectory>
170-
<verbose>false</verbose>
171-
<filesNamePattern>.*\.java</filesNamePattern>
172-
<skip>false</skip>
173-
<skipSortingImports>false</skipSortingImports>
174-
<style>google</style>
175-
</configuration>
176-
<executions>
177-
<execution>
178-
<goals>
179-
<goal>format</goal>
180-
</goals>
181-
</execution>
182-
</executions>
183-
</plugin>
184-
<plugin>
185-
<groupId>org.apache.maven.plugins</groupId>
186-
<artifactId>maven-jar-plugin</artifactId>
187-
<executions>
188-
<execution>
189-
<goals>
190-
<goal>test-jar</goal>
191-
</goals>
192-
</execution>
193-
</executions>
194-
</plugin>
195124
</plugins>
196125
</build>
197126
</project>

impl/bom/pom.xml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>io.serverlessworkflow</groupId>
5+
<artifactId>serverlessworkflow-impl</artifactId>
6+
<version>7.0.0-SNAPSHOT</version>
7+
</parent>
8+
<artifactId>serverlessworkflow-impl-bom</artifactId>
9+
<packaging>pom</packaging>
10+
<dependencies>
11+
<dependency>
12+
<groupId>io.serverlessworkflow</groupId>
13+
<artifactId>serverlessworkflow-impl-core</artifactId>
14+
</dependency>
15+
<dependency>
16+
<groupId>io.serverlessworkflow</groupId>
17+
<artifactId>serverlessworkflow-impl-http</artifactId>
18+
</dependency>
19+
</dependencies>
20+
</project>

impl/core/.checkstyle

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
4+
<local-check-config name="maven-checkstyle-plugin default" location="file:/home/ftirados/kogito_new/.metadata/.plugins/com.basistech.m2e.code.quality.checkstyle/serverlessworkflow-impl-core_inline_checkstyle.xml" type="remote" description="maven-checkstyle-plugin configuration default">
5+
<property name="checkstyle.header.file" value="/home/ftirados/kogito_new/.metadata/.plugins/org.eclipse.core.resources/.projects/serverlessworkflow-impl-core/com.basistech.m2e.code.quality.checkstyleConfigurator/checkstyle-header-default.txt"/>
6+
<property name="checkstyle.cache.file" value="${project_loc}/target/checkstyle-cachefile"/>
7+
</local-check-config>
8+
<fileset name="java-sources-default" enabled="true" check-config-name="maven-checkstyle-plugin default" local="true">
9+
<file-match-pattern match-pattern="^src/test/java/.*\/.*\.java" include-pattern="true"/>
10+
<file-match-pattern match-pattern="^src/main/java/.*\/.*\.java" include-pattern="true"/>
11+
<file-match-pattern match-pattern="^src/main/resources/.*\.properties" include-pattern="true"/>
12+
<file-match-pattern match-pattern="^src/test/resources/.*\.properties" include-pattern="true"/>
13+
</fileset>
14+
</fileset-config>

impl/core/pom.xml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>io.serverlessworkflow</groupId>
5+
<artifactId>serverlessworkflow-impl</artifactId>
6+
<version>7.0.0-SNAPSHOT</version>
7+
</parent>
8+
<artifactId>serverlessworkflow-impl-core</artifactId>
9+
<properties>
10+
<version.net.thisptr>1.1.0</version.net.thisptr>
11+
</properties>
12+
<dependencies>
13+
<dependency>
14+
<groupId>io.serverlessworkflow</groupId>
15+
<artifactId>serverlessworkflow-api</artifactId>
16+
<version>7.0.0-SNAPSHOT</version>
17+
</dependency>
18+
<dependency>
19+
<groupId>com.networknt</groupId>
20+
<artifactId>json-schema-validator</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>net.thisptr</groupId>
24+
<artifactId>jackson-jq</artifactId>
25+
<version>${version.net.thisptr}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.junit.jupiter</groupId>
29+
<artifactId>junit-jupiter-api</artifactId>
30+
<scope>test</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.junit.jupiter</groupId>
34+
<artifactId>junit-jupiter-engine</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.junit.jupiter</groupId>
39+
<artifactId>junit-jupiter-params</artifactId>
40+
<scope>test</scope>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.assertj</groupId>
44+
<artifactId>assertj-core</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
48+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl;
17+
18+
public enum WorkflowState {
19+
STARTED,
20+
WAITING,
21+
COMPLETED
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl.executors;
17+
18+
import io.serverlessworkflow.api.types.TaskBase;
19+
import io.serverlessworkflow.impl.TaskContext;
20+
import io.serverlessworkflow.impl.WorkflowContext;
21+
import io.serverlessworkflow.impl.WorkflowDefinition;
22+
23+
public class CallTaskExecutor<T extends TaskBase> extends AbstractTaskExecutor<T> {
24+
25+
private final CallableTask<T> callable;
26+
27+
protected CallTaskExecutor(T task, WorkflowDefinition definition, CallableTask<T> callable) {
28+
super(task, definition);
29+
this.callable = callable;
30+
callable.init(task, definition);
31+
}
32+
33+
@Override
34+
protected void internalExecute(WorkflowContext workflow, TaskContext<T> taskContext) {
35+
taskContext.rawOutput(callable.apply(workflow, taskContext, taskContext.input()));
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl.executors;
17+
18+
import com.fasterxml.jackson.databind.JsonNode;
19+
import io.serverlessworkflow.api.types.TaskBase;
20+
import io.serverlessworkflow.impl.TaskContext;
21+
import io.serverlessworkflow.impl.WorkflowContext;
22+
import io.serverlessworkflow.impl.WorkflowDefinition;
23+
24+
public interface CallableTask<T extends TaskBase> {
25+
void init(T task, WorkflowDefinition definition);
26+
27+
JsonNode apply(WorkflowContext workflowContext, TaskContext<T> taskContext, JsonNode input);
28+
29+
boolean accept(Class<? extends TaskBase> clazz);
30+
}

impl/src/main/java/io/serverlessworkflow/impl/executors/DefaultTaskExecutorFactory.java renamed to impl/core/src/main/java/io/serverlessworkflow/impl/executors/DefaultTaskExecutorFactory.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
*/
1616
package io.serverlessworkflow.impl.executors;
1717

18+
import io.serverlessworkflow.api.types.CallHTTP;
1819
import io.serverlessworkflow.api.types.CallTask;
1920
import io.serverlessworkflow.api.types.Task;
2021
import io.serverlessworkflow.api.types.TaskBase;
2122
import io.serverlessworkflow.impl.WorkflowDefinition;
23+
import java.util.ServiceLoader;
24+
import java.util.ServiceLoader.Provider;
2225

2326
public class DefaultTaskExecutorFactory implements TaskExecutorFactory {
2427

@@ -30,12 +33,15 @@ public static TaskExecutorFactory get() {
3033

3134
protected DefaultTaskExecutorFactory() {}
3235

36+
private ServiceLoader<CallableTask> callTasks = ServiceLoader.load(CallableTask.class);
37+
3338
public TaskExecutor<? extends TaskBase> getTaskExecutor(
3439
Task task, WorkflowDefinition definition) {
3540
if (task.getCallTask() != null) {
3641
CallTask callTask = task.getCallTask();
3742
if (callTask.getCallHTTP() != null) {
38-
return new HttpExecutor(callTask.getCallHTTP(), definition);
43+
return new CallTaskExecutor<>(
44+
callTask.getCallHTTP(), definition, findCallTask(CallHTTP.class));
3945
}
4046
} else if (task.getSwitchTask() != null) {
4147
return new SwitchExecutor(task.getSwitchTask(), definition);
@@ -46,4 +52,15 @@ public TaskExecutor<? extends TaskBase> getTaskExecutor(
4652
}
4753
throw new UnsupportedOperationException(task.get().getClass().getName() + " not supported yet");
4854
}
55+
56+
@SuppressWarnings("unchecked")
57+
private <T extends TaskBase> CallableTask<T> findCallTask(Class<T> clazz) {
58+
return (CallableTask<T>)
59+
callTasks.stream()
60+
.map(Provider::get)
61+
.filter(s -> s.accept(clazz))
62+
.findAny()
63+
.orElseThrow(
64+
() -> new UnsupportedOperationException(clazz.getName() + " not supported yet"));
65+
}
4966
}

impl/src/main/java/io/serverlessworkflow/impl/executors/SwitchExecutor.java renamed to impl/core/src/main/java/io/serverlessworkflow/impl/executors/SwitchExecutor.java

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package io.serverlessworkflow.impl.executors;
217

318
import io.serverlessworkflow.api.types.FlowDirective;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.impl.expressions;
17+
18+
public class ExpressionValidationException extends RuntimeException {
19+
20+
private static final long serialVersionUID = 1L;
21+
22+
public ExpressionValidationException(String message) {
23+
super(message);
24+
}
25+
26+
public ExpressionValidationException(String message, Throwable ex) {
27+
super(message, ex);
28+
}
29+
}

impl/src/main/java/io/serverlessworkflow/impl/jsonschema/DefaultSchemaValidator.java renamed to impl/core/src/main/java/io/serverlessworkflow/impl/jsonschema/DefaultSchemaValidator.java

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
/*
2-
* Licensed to the Apache Software Foundation (ASF) under one
3-
* or more contributor license agreements. See the NOTICE file
4-
* distributed with this work for additional information
5-
* regarding copyright ownership. The ASF licenses this file
6-
* to you under the Apache License, Version 2.0 (the
7-
* "License"); you may not use this file except in compliance
8-
* with the License. You may obtain a copy of the License at
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
93
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
117
*
12-
* Unless required by applicable law or agreed to in writing,
13-
* software distributed under the License is distributed on an
14-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
16-
* specific language governing permissions and limitations
17-
* under the License.
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1815
*/
1916
package io.serverlessworkflow.impl.jsonschema;
2017

0 commit comments

Comments
 (0)