-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
313 additions
and
167 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
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
48 changes: 48 additions & 0 deletions
48
nflow-engine/src/main/java/io/nflow/engine/service/WorkflowDefinitionClassNameScanner.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,48 @@ | ||
package io.nflow.engine.service; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
import org.springframework.core.io.AbstractResource; | ||
import org.springframework.stereotype.Component; | ||
|
||
import io.nflow.engine.config.NFlow; | ||
import io.nflow.engine.workflow.definition.AbstractWorkflowDefinition; | ||
import io.nflow.engine.workflow.definition.WorkflowState; | ||
|
||
/** | ||
* Register workflow definitions defined in the class name listing resource. | ||
*/ | ||
@Component | ||
public class WorkflowDefinitionClassNameScanner { | ||
|
||
private static final Logger logger = getLogger(WorkflowDefinitionClassNameScanner.class); | ||
|
||
@Inject | ||
public WorkflowDefinitionClassNameScanner(WorkflowDefinitionService workflowDefinitionService, | ||
@Nullable @NFlow AbstractResource classNameListing) throws IOException, ReflectiveOperationException { | ||
if (classNameListing == null) { | ||
logger.info("No non-Spring workflow definitions"); | ||
} else { | ||
try (BufferedReader br = new BufferedReader(new InputStreamReader(classNameListing.getInputStream(), UTF_8))) { | ||
String row; | ||
while ((row = br.readLine()) != null) { | ||
logger.info("Preparing workflow {}", row); | ||
@SuppressWarnings("unchecked") | ||
Class<AbstractWorkflowDefinition<? extends WorkflowState>> clazz = (Class<AbstractWorkflowDefinition<? extends WorkflowState>>) Class | ||
.forName(row); | ||
workflowDefinitionService.addWorkflowDefinition(clazz.getDeclaredConstructor().newInstance()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
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
24 changes: 24 additions & 0 deletions
24
nflow-engine/src/main/java/io/nflow/engine/service/WorkflowDefinitionSpringBeanScanner.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,24 @@ | ||
package io.nflow.engine.service; | ||
|
||
import java.util.Collection; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import io.nflow.engine.workflow.definition.AbstractWorkflowDefinition; | ||
import io.nflow.engine.workflow.definition.WorkflowState; | ||
|
||
/** | ||
* Register workflow definitions defined as Spring beans. | ||
*/ | ||
@Component | ||
public class WorkflowDefinitionSpringBeanScanner { | ||
|
||
@Inject | ||
public WorkflowDefinitionSpringBeanScanner(WorkflowDefinitionService workflowDefinitionService, | ||
Collection<AbstractWorkflowDefinition<? extends WorkflowState>> workflowDefinitions) { | ||
workflowDefinitions.forEach(workflowDefinitionService::addWorkflowDefinition); | ||
} | ||
|
||
} |
Oops, something went wrong.