├── .gitignore ├── .mvn ├── jvm.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .project ├── .settings └── .gitignore ├── .travis.yml ├── LICENSE-2.0.txt ├── README.md ├── demo ├── .gitignore ├── .project ├── flows-demo │ ├── .classpath │ ├── .gitignore │ ├── .project │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.m2e.core.prefs │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── neuro4j │ │ │ └── workflow │ │ │ └── demo │ │ │ ├── lesson1 │ │ │ ├── Hello.n4j │ │ │ ├── HelloBlock.java │ │ │ └── Main.java │ │ │ ├── lesson2 │ │ │ ├── Loop.n4j │ │ │ └── Main.java │ │ │ ├── lesson3 │ │ │ ├── Decision.n4j │ │ │ └── Main.java │ │ │ └── lesson4 │ │ │ ├── Call.n4j │ │ │ ├── Main.java │ │ │ └── OtherFlow.n4j │ │ └── resources │ │ └── logback.xml └── pom.xml ├── doc ├── .gitignore ├── Neuro4jPresentation.pptx ├── eclipse-codestyle.xml ├── images │ ├── .gitignore │ ├── DashboardResult.png │ ├── DownloadPages.png │ ├── DownloadPagesResult.png │ ├── FlowWithHystrixCommands.png │ ├── HelloWorld.png │ ├── HelloWorldCustomBlock.png │ ├── HelloWorldCustomBlock_1 (2).png │ ├── HelloWorld_.png │ ├── MainClass.png │ ├── Parallel.png │ ├── ch.png │ ├── debug.png │ ├── diagram.png │ ├── empty-flow.png │ ├── guice-workflow-adapter │ │ └── customblock.png │ ├── img-3.png │ ├── spring-webmvc-workflow │ │ ├── CustomBlock.png │ │ ├── controller.png │ │ └── flow.png │ ├── step-debug.png │ ├── tutorials │ │ ├── DebugFirstFlow │ │ │ ├── debugperspective.png │ │ │ ├── dopayment.png │ │ │ ├── newconfiguration.png │ │ │ ├── setbreakpoint.png │ │ │ ├── step1.png │ │ │ └── step2.png │ │ ├── GuiceWorkflowExample │ │ │ └── image1.png │ │ ├── SpringEmailExample │ │ │ └── result.png │ │ ├── SpringJmsExample │ │ │ ├── importedProject.png │ │ │ └── result.png │ │ ├── SpringMVCExample │ │ │ ├── flow.png │ │ │ └── importedproject.png │ │ ├── WorkflowExample │ │ │ ├── flow3node.png │ │ │ ├── flowperspective.png │ │ │ ├── newcustomblock.png │ │ │ ├── newcustomblockmenu.png │ │ │ ├── newworkflow.png │ │ │ ├── parameters.png │ │ │ ├── projectwithimage.png │ │ │ ├── result.png │ │ │ ├── selectcustomnode.png │ │ │ └── withcustomicon.png │ │ └── WorkflowHowTo │ │ │ ├── img1_custom_icon.png │ │ │ ├── img2_cb_impl_class.png │ │ │ └── img3_cb_view.png │ └── with-icon.png └── pdf │ ├── HelloWorld.pdf │ └── StudioDebugPlugin.pdf ├── guava-cacheloader ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── guava │ │ ├── GuavaCachedWorkflowLoader.java │ │ └── GuavaWorkflowCache.java │ └── test │ ├── java │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── async │ │ ├── CounterWorkflowLoader.java │ │ ├── CounterXmlWorkflowConverter.java │ │ ├── CustomBlockSleep.java │ │ ├── FakeWorkflowLoader.java │ │ ├── GuavaCacheTest.java │ │ ├── Neuro4jWorkflowMultiThreadsTest.java │ │ └── WorkflowLoaderIntTest.java │ └── resources │ └── org │ └── neuro4j │ └── workflow │ └── flows │ ├── FlowForClasspathLoader.n4j │ └── FlowForClasspathLoaderOtherFile.n4j ├── guice-workflow-adapter ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── guice │ │ └── GuiceCustomBlockInitStrategy.java │ └── test │ └── java │ └── org │ └── neuro4j │ └── workflow │ └── guice │ ├── AllTests.java │ ├── AppInjector.java │ ├── GuiceWithWorkflowTestCase.java │ ├── flows │ ├── CustomBlockWithService.java │ └── Flow.n4j │ └── service │ ├── MessageService.java │ └── MyMessageService.java ├── history.md ├── jasper-report-workflow ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neuro4j │ │ │ └── jasper │ │ │ ├── datasource │ │ │ └── CreateJRBeanCollectionDataSource.java │ │ │ ├── input │ │ │ └── LoadTemplate.java │ │ │ ├── output │ │ │ └── CreateFileOutputStream.java │ │ │ ├── parameters │ │ │ └── CreateReportParameters.java │ │ │ └── report │ │ │ ├── GenerateReport.java │ │ │ └── GenerateReport.png │ └── resources │ │ └── org │ │ └── neuro4j │ │ └── jasper │ │ └── report │ │ └── GenerateReport.png │ └── test │ ├── java │ └── tests │ │ └── org │ │ └── neuro4j │ │ └── jasper │ │ └── reports │ │ ├── GenerateReport.n4j │ │ └── PdfReportTestCase.java │ └── resources │ └── reports │ ├── TableReport.jrxml │ ├── report1.jasper │ ├── report1.jrprint │ └── report1.jrxml ├── logback.xml ├── mvnw ├── mvnw.cmd ├── netflix-governator-adapter ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── governator │ │ └── GovernatorCustomBlockInitStrategy.java │ └── test │ └── java │ └── org │ └── neuro4j │ └── workflow │ └── governator │ ├── AppInjector.java │ ├── GovernatorWithWorkflowTest.java │ ├── flows │ ├── CustomBlockWithService.java │ └── Flow.n4j │ └── service │ ├── MessageService.java │ └── MyMessageService.java ├── netflix-hystrix-adapter ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neuro4j │ │ │ └── workflow │ │ │ └── hystrix │ │ │ ├── BaseHystrixCommand.java │ │ │ ├── DefaultHystrixBootstrap.java │ │ │ ├── HystrixLifecycleCommand.java │ │ │ └── HystrixLifecycleListener.java │ └── resources │ │ └── reference.conf │ └── test │ ├── java │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── hystrix │ │ ├── FlowWithHystrix.n4j │ │ ├── HystrixTest.java │ │ ├── SleepHystrixCommand.java │ │ └── SomeHystrixCommand.java │ └── resources │ └── application.conf ├── neuro4j-typesafeconfig ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── neuro4j │ │ │ └── workflow │ │ │ └── typesafe │ │ │ └── config │ │ │ └── WorkflowConfigFactory.java │ └── resources │ │ └── reference.conf │ └── test │ ├── java │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── typesafe │ │ └── config │ │ └── WorkflowConfigFactoryTests.java │ └── resources │ └── application.conf ├── neuro4j-workflow-common ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── neuro4j │ └── workflow │ ├── core │ └── SystemOutBlock.java │ └── log │ └── PrintFlowContext.java ├── neuro4j-workflow-core ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neuro4j │ │ └── workflow │ │ ├── ActionBlock.java │ │ ├── ActionHandler.java │ │ ├── ExecutionResult.java │ │ ├── FlowContext.java │ │ ├── UUIDMgr.java │ │ ├── WorkflowRequest.java │ │ ├── async │ │ ├── CallableTask.java │ │ └── ThreadPoolTaskExecutor.java │ │ ├── cache │ │ ├── ActionHandlersRegistry.java │ │ ├── ConcurrentMapWorkflowCache.java │ │ ├── EmptyWorkflowCache.java │ │ └── WorkflowCache.java │ │ ├── common │ │ ├── FlowExecutionException.java │ │ ├── JSONWorkflowConverter.java │ │ ├── ParameterDefinition.java │ │ ├── ParameterDefinitionImpl.java │ │ ├── ParameterDefinitionList.java │ │ ├── SWFParametersConstants.java │ │ ├── Workflow.java │ │ ├── WorkflowConverter.java │ │ ├── WorkflowEngine.java │ │ └── XmlWorkflowConverter.java │ │ ├── debug │ │ └── DebugService.java │ │ ├── enums │ │ ├── ActionBlockCache.java │ │ ├── CachedNode.java │ │ ├── DecisionCompTypes.java │ │ ├── DecisionOperators.java │ │ ├── FlowVisibility.java │ │ └── StartNodeTypes.java │ │ ├── loader │ │ ├── ClasspathWorkflowLoader.java │ │ ├── CustomBlockInitStrategy.java │ │ ├── DefaultCustomBlockInitStrategy.java │ │ ├── FileWorkflowLoader.java │ │ ├── InMemoryWorkflowLoader.java │ │ ├── RemoteWorkflowLoader.java │ │ ├── URLWorkflowLoader.java │ │ ├── WorkflowLoader.java │ │ └── f4j │ │ │ ├── FlowConverter.java │ │ │ ├── FlowXML.java │ │ │ ├── NodeType.java │ │ │ ├── NodeXML.java │ │ │ ├── ParameterXML.java │ │ │ ├── SWFConstants.java │ │ │ ├── TransitionXML.java │ │ │ └── WorkflowBuilder.java │ │ ├── node │ │ ├── CallNode.java │ │ ├── CustomBlock.java │ │ ├── CustomBlockLoader.java │ │ ├── CustomNode.java │ │ ├── DecisionNode.java │ │ ├── EndNode.java │ │ ├── FlowParameter.java │ │ ├── JoinNode.java │ │ ├── KeyMapper.java │ │ ├── LoopNode.java │ │ ├── StartNode.java │ │ ├── SwitchNode.java │ │ ├── Transition.java │ │ ├── ViewNode.java │ │ ├── WorkflowNode.java │ │ └── WorkflowProcessor.java │ │ └── utils │ │ └── Validation.java │ └── test │ ├── java │ └── org │ │ └── neuro4j │ │ ├── flows │ │ ├── common │ │ │ └── WorkflowEngineTestCase.java │ │ ├── custom │ │ │ ├── FlowContextTestCase.java │ │ │ ├── FlowWithParameters.n4j │ │ │ ├── InputParametersTestCase.java │ │ │ ├── OutParametersTestCase.java │ │ │ ├── TestBean.java │ │ │ └── blocks │ │ │ │ ├── BlockWithMandatoryInputParameter.java │ │ │ │ ├── BlockWithStaticInputName.java │ │ │ │ ├── BlockWithStringParameter.java │ │ │ │ └── CustomWithInOutParam.java │ │ ├── example │ │ │ ├── HelloWorld.java │ │ │ └── HelloWorldTest.java │ │ ├── network │ │ │ ├── NetworkTestCase.java │ │ │ ├── NetworkTestFlow.n4j │ │ │ └── p2 │ │ │ │ └── NetworkTestFlow2.n4j │ │ ├── nodes │ │ │ ├── callnode │ │ │ │ ├── CallByNameFlow.n4j │ │ │ │ ├── CallByNameFlow2.n4j │ │ │ │ ├── CallNodeTestCase.java │ │ │ │ └── Flow1.n4j │ │ │ ├── decisionnode │ │ │ │ ├── DecisionFlow.n4j │ │ │ │ └── DecisionNodeTestCase.java │ │ │ ├── loopnode │ │ │ │ ├── LoopExample.n4j │ │ │ │ └── LoopNodeTestCase.java │ │ │ ├── mappernode │ │ │ │ ├── MapperFlow.n4j │ │ │ │ └── MapperNodeTestCase.java │ │ │ ├── switchnode │ │ │ │ ├── SwitchFlow.n4j │ │ │ │ └── SwitchNodeTestCase.java │ │ │ └── viewnode │ │ │ │ ├── SetViewTemplate.n4j │ │ │ │ └── SetViewTemplateNodeTestCase.java │ │ └── tests │ │ │ └── AllTests.java │ │ ├── tests │ │ └── base │ │ │ └── BaseFlowTestCase.java │ │ └── workflow │ │ ├── async │ │ ├── CustomBlockSleep.java │ │ ├── Neuro4jWorkflowAsyncTest.java │ │ ├── Neuro4jWorkflowMultiThreadsTest.java │ │ └── SleepRandom.java │ │ ├── common │ │ ├── ActionRegistryTest.java │ │ ├── CacheTest.java │ │ ├── CommonTest.java │ │ ├── ConfigBuilderTest.java │ │ ├── ConverterTest.java │ │ ├── Neuro4jWorkflowTest.java │ │ ├── WorkflowBuilderTest.java │ │ ├── WorkflowLoaderIntTests.java │ │ ├── WorkflowLoaderMockTest.java │ │ └── WorkflowLoaderTest.java │ │ ├── core │ │ ├── CustomBlockEmptyCache.java │ │ ├── CustomBlockNoDefaultConstructor.java │ │ ├── CustomBlockNodeCached.java │ │ ├── CustomBlockNoneCached.java │ │ ├── CustomBlockWithEmptyList.java │ │ ├── CustomBlockWithErrorExit.java │ │ ├── CustomBlockWithNoAnotations.java │ │ └── SystemOutBlock.java │ │ ├── fork │ │ └── ForkTest.java │ │ ├── loader │ │ └── CounterWorkflowLoader.java │ │ └── nodes │ │ ├── CallNodeTest.java │ │ ├── CustomBlockInitStrategyTest.java │ │ ├── CustomNodeTest.java │ │ ├── DecisionNodeTest.java │ │ ├── JoinNodeTest.java │ │ └── LoopNodeTest.java │ └── resources │ ├── file1.n4j │ ├── logback-test.xml │ ├── org │ ├── mydomain │ │ └── FlowForFileWorkflowLoader.n4j │ └── neuro4j │ │ └── workflow │ │ └── flows │ │ ├── FlowForClasspathLoader.n4j │ │ ├── FlowForClasspathLoaderOtherFile.n4j │ │ ├── FlowForFileLoader.n4j │ │ ├── FlowWithAllNodes.n4j │ │ ├── FlowtotestCache.n4j │ │ ├── ForkWorkflow.n4j │ │ ├── LocalFlowCallsRemote.n4j │ │ └── RemoteFlow.n4j │ └── somefolder │ └── org │ └── mydomain │ └── FlowForFileWorkflowLoader.n4j ├── pom.xml ├── spring-context-adapter ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── neuro4j │ │ └── springframework │ │ └── context │ │ └── SpringContextInitStrategy.java │ └── test │ └── java │ └── org │ └── neuro4j │ └── workflow │ └── spring │ ├── CustomBlockNoComponent.java │ ├── CustomBlockWithService.java │ ├── Flow.n4j │ ├── SampleApplication.java │ ├── SpringContextWorkflowTest.java │ └── service │ ├── MessageService.java │ └── MyMessageService.java ├── spring-jms-adapter ├── .gitignore ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── neuro4j │ │ └── springframework │ │ └── jms │ │ ├── CloseApplicationContext.java │ │ ├── GetTextMessageCreator.java │ │ ├── JMSMessageListener.java │ │ └── JMSQueueSender.java │ └── resources │ └── org │ └── neuro4j │ └── springframework │ └── jms │ ├── JMSMessageListener.png │ └── JMSQueueSender.png ├── spring-mail-adapter ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── neuro4j │ │ └── springintegration │ │ └── mail │ │ ├── MessageHandlerFactoryBean.java │ │ └── debug │ │ ├── PrintMessage.java │ │ └── PrintMessageHeader.java │ └── resources │ └── org │ └── neuro4j │ └── springintegration │ └── mail │ └── HandleInputMessage.png ├── tools └── eclipse │ ├── README.md │ └── n4jstudio_installer.sh └── tutorials ├── .gitignore ├── .project ├── GuiceWorkflowExample ├── .gitignore ├── .settings │ ├── .gitignore │ └── org.eclipse.jdt.core.prefs ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── neuro4j │ └── workflow │ └── guice │ ├── App.java │ ├── flows │ ├── CustomBlockWithService.java │ └── Flow.n4j │ └── service │ ├── MessageService.java │ └── MyMessageService.java ├── HystrixExample ├── README.md ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── neuro4j │ │ └── example │ │ ├── AppConfig.java │ │ ├── HystrixServletDefinitions.java │ │ ├── SampleApplication.java │ │ ├── WelcomeController.java │ │ ├── commons │ │ └── DownloadPage.java │ │ └── services │ │ ├── DownloadService.java │ │ └── JsoupDownloadService.java │ ├── resources │ ├── application.conf │ ├── application.properties │ ├── logback.xml │ └── org │ │ └── neuro4j │ │ └── workflow │ │ └── DownloadPages.n4j │ └── webapp │ └── welcome.jsp ├── ParallelProcessingExample ├── .gitignore ├── README.md ├── pom.xml └── src │ ├── .gitignore │ └── main │ ├── .gitignore │ ├── java │ └── org │ │ └── neuro4j │ │ └── example │ │ ├── AppConfig.java │ │ ├── SampleApplication.java │ │ ├── WelcomeController.java │ │ ├── commons │ │ └── DownloadPage.java │ │ └── services │ │ ├── DownloadService.java │ │ └── JsoupDownloadService.java │ ├── resources │ ├── .gitignore │ ├── application.properties │ ├── logback.xml │ └── org │ │ ├── .gitignore │ │ └── neuro4j │ │ ├── .gitignore │ │ └── workflow │ │ ├── .gitignore │ │ └── DownloadPages.n4j │ └── webapp │ ├── download.jsp │ └── welcome.jsp ├── SpringEmailExample ├── .gitignore ├── .settings │ └── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── neuro4j │ │ └── springframework │ │ └── email │ │ └── example │ │ ├── GetMailsFromGmail.n4j │ │ ├── GmailImapIdleTestApp.java │ │ └── GmailPop3TestApp.java │ └── resources │ ├── META-INF │ └── spring │ │ └── integration │ │ ├── controllers.xml │ │ ├── gmail-imap-idle-config.xml │ │ └── gmail-pop3-config.xml │ └── logback.xml ├── SpringJmsExample ├── .gitignore ├── .settings │ └── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── neuro4j │ │ └── springframework │ │ └── jms │ │ ├── example │ │ ├── Application.java │ │ ├── DoSomething.java │ │ └── RemoveJmsTmpFiles.java │ │ └── flows │ │ └── MessageFlow.n4j │ └── resources │ └── logback.xml ├── SpringTimerExample ├── .gitignore ├── .settings │ └── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── neuro4j │ │ └── springframework │ │ └── timer │ │ └── example │ │ ├── App.java │ │ └── TimerFlow.n4j │ └── resources │ ├── logback.xml │ ├── quartz-context.xml │ └── quartz-context.xml.example ├── WorkflowExample ├── .gitignore ├── pom.xml └── src │ ├── .gitignore │ ├── main │ ├── .gitignore │ ├── java │ │ └── org │ │ │ └── neuro4j │ │ │ └── workflow │ │ │ └── tutorial │ │ │ ├── App.java │ │ │ ├── HelloFlow.n4j │ │ │ └── HelloWorld.java │ └── resources │ │ ├── .gitignore │ │ ├── logback.xml │ │ └── org │ │ ├── .gitignore │ │ └── neuro4j │ │ ├── .gitignore │ │ └── workflow │ │ ├── .gitignore │ │ └── tutorial │ │ └── HelloWorld_.png │ └── test │ └── java │ └── org │ └── neuro4j │ └── workflow │ └── tutorial │ └── HelloWorldTest.java └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /.DS_Store 7 | -------------------------------------------------------------------------------- /.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx512m -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | workflow 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.core.resources.prefs 2 | /org.eclipse.m2e.core.prefs 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: java 3 | script: mvn test 4 | jdk: 5 | - oraclejdk8 6 | after_success: 7 | # - mvn clean test cobertura:cobertura coveralls:report 8 | - mvn clean test jacoco:report coveralls:report 9 | -------------------------------------------------------------------------------- /LICENSE-2.0.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2016, Neuro4j 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /demo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | wf-parent 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /demo/flows-demo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /demo/flows-demo/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /demo/flows-demo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | flows-demo 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.ajdt.core.ajbuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.ajdt.ui.ajnature 21 | org.eclipse.jdt.core.javanature 22 | org.eclipse.m2e.core.maven2Nature 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/flows-demo/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /demo/flows-demo/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 3 | org.eclipse.jdt.core.compiler.compliance=1.7 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.7 6 | -------------------------------------------------------------------------------- /demo/flows-demo/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /demo/flows-demo/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.neuro4j.examples 7 | wf-parent 8 | 3.5.1-SNAPSHOT 9 | ../pom.xml 10 | 11 | flows-demo 12 | 13 | 1.0.13 14 | 15 | 16 | 17 | ch.qos.logback 18 | logback-classic 19 | ${logback.version} 20 | 21 | 22 | 23 | 24 | 25 | 26 | src/main/java 27 | 28 | **/*.n4j 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson1/Hello.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 0, 29, -9, -91|9, 86, 0, -34| 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 32, -11, -79|11, 83, 0, -28| 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson1/HelloBlock.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.demo.lesson1; 2 | 3 | 4 | import static org.neuro4j.workflow.demo.lesson1.HelloBlock.IN_NAME; 5 | import static org.neuro4j.workflow.demo.lesson1.HelloBlock.OUT_MESSAGE; 6 | 7 | import org.neuro4j.workflow.ActionBlock; 8 | import org.neuro4j.workflow.FlowContext; 9 | import org.neuro4j.workflow.common.FlowExecutionException; 10 | import org.neuro4j.workflow.common.ParameterDefinition; 11 | import org.neuro4j.workflow.common.ParameterDefinitionList; 12 | 13 | @ParameterDefinitionList(input={ 14 | @ParameterDefinition(name=IN_NAME, isOptional=true, type= "java.lang.String")}, 15 | output={ 16 | @ParameterDefinition(name=OUT_MESSAGE, isOptional=false, type= "java.lang.String")}) 17 | public class HelloBlock implements ActionBlock { 18 | 19 | static final String IN_NAME = "name"; 20 | 21 | static final String OUT_MESSAGE = "message"; 22 | 23 | 24 | 25 | public int execute(FlowContext ctx) throws FlowExecutionException { 26 | 27 | String name = (String)ctx.get(IN_NAME); 28 | 29 | String message = "Hello "; 30 | 31 | if (name != null) 32 | { 33 | message += name; 34 | } 35 | 36 | ctx.put(OUT_MESSAGE, message); 37 | 38 | 39 | return NEXT; 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson1/Main.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.demo.lesson1; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.neuro4j.workflow.ExecutionResult; 7 | import org.neuro4j.workflow.common.WorkflowEngine; 8 | 9 | public class Main { 10 | 11 | /** 12 | * This class shows how to run simple flow with user-defined code. User Block "HelloBlock" combines input parameter "name" with text "Hello " and returns it. 13 | * After execution new variable "message" will hold this text. 14 | * 15 | * @param args 16 | */ 17 | public static void main(String[] args) { 18 | 19 | Map params = new HashMap(); 20 | params.put("name", "John"); 21 | WorkflowEngine engine = new WorkflowEngine(); 22 | ExecutionResult result = engine.execute("org.neuro4j.workflow.demo.lesson1.Hello-Start", params); 23 | 24 | String greeting = (String) result.getFlowContext().get("message"); 25 | System.out.println(greeting); 26 | 27 | 28 | } 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson2/Main.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.demo.lesson2; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.neuro4j.workflow.ExecutionResult; 9 | import org.neuro4j.workflow.common.WorkflowEngine; 10 | 11 | public class Main { 12 | 13 | /** 14 | * @param args 15 | */ 16 | public static void main(String[] args) { 17 | 18 | 19 | Map params = new HashMap(); 20 | List list = new ArrayList(); 21 | list.add("value1"); 22 | list.add("value2"); 23 | list.add("value3"); 24 | 25 | 26 | params.put("list1", list); 27 | 28 | ExecutionResult result = new WorkflowEngine().execute("org.neuro4j.workflow.demo.lesson2.Loop-Start", params); 29 | 30 | 31 | 32 | } 33 | 34 | 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson3/Main.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.demo.lesson3; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.neuro4j.workflow.ExecutionResult; 7 | import org.neuro4j.workflow.common.WorkflowEngine; 8 | 9 | public class Main { 10 | 11 | /** 12 | * @param args 13 | */ 14 | public static void main(String[] args) { 15 | 16 | 17 | Map params = new HashMap(); 18 | 19 | params.put("var", "true"); 20 | 21 | ExecutionResult result = new WorkflowEngine().execute("org.neuro4j.workflow.demo.lesson3.Decision-Start", params); 22 | 23 | 24 | 25 | } 26 | 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson4/Main.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.demo.lesson4; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.neuro4j.workflow.ExecutionResult; 7 | import org.neuro4j.workflow.common.WorkflowEngine; 8 | 9 | public class Main { 10 | 11 | /** 12 | * @param args 13 | */ 14 | public static void main(String[] args) { 15 | 16 | 17 | Map params = new HashMap(); 18 | 19 | ExecutionResult result = new WorkflowEngine().execute("org.neuro4j.workflow.demo.lesson4.Call-Start", params); 20 | 21 | 22 | 23 | } 24 | 25 | 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/java/org/neuro4j/workflow/demo/lesson4/OtherFlow.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 0, 29, 4, -110|-4, 105, 0, -34| 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 0, 32, 12, -134|-12, 138, 0, -28| 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /demo/flows-demo/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /doc/Neuro4jPresentation.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/Neuro4jPresentation.pptx -------------------------------------------------------------------------------- /doc/images/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /doc/images/DashboardResult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/DashboardResult.png -------------------------------------------------------------------------------- /doc/images/DownloadPages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/DownloadPages.png -------------------------------------------------------------------------------- /doc/images/DownloadPagesResult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/DownloadPagesResult.png -------------------------------------------------------------------------------- /doc/images/FlowWithHystrixCommands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/FlowWithHystrixCommands.png -------------------------------------------------------------------------------- /doc/images/HelloWorld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/HelloWorld.png -------------------------------------------------------------------------------- /doc/images/HelloWorldCustomBlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/HelloWorldCustomBlock.png -------------------------------------------------------------------------------- /doc/images/HelloWorldCustomBlock_1 (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/HelloWorldCustomBlock_1 (2).png -------------------------------------------------------------------------------- /doc/images/HelloWorld_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/HelloWorld_.png -------------------------------------------------------------------------------- /doc/images/MainClass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/MainClass.png -------------------------------------------------------------------------------- /doc/images/Parallel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/Parallel.png -------------------------------------------------------------------------------- /doc/images/ch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/ch.png -------------------------------------------------------------------------------- /doc/images/debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/debug.png -------------------------------------------------------------------------------- /doc/images/diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/diagram.png -------------------------------------------------------------------------------- /doc/images/empty-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/empty-flow.png -------------------------------------------------------------------------------- /doc/images/guice-workflow-adapter/customblock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/guice-workflow-adapter/customblock.png -------------------------------------------------------------------------------- /doc/images/img-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/img-3.png -------------------------------------------------------------------------------- /doc/images/spring-webmvc-workflow/CustomBlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/spring-webmvc-workflow/CustomBlock.png -------------------------------------------------------------------------------- /doc/images/spring-webmvc-workflow/controller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/spring-webmvc-workflow/controller.png -------------------------------------------------------------------------------- /doc/images/spring-webmvc-workflow/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/spring-webmvc-workflow/flow.png -------------------------------------------------------------------------------- /doc/images/step-debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/step-debug.png -------------------------------------------------------------------------------- /doc/images/tutorials/DebugFirstFlow/debugperspective.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/DebugFirstFlow/debugperspective.png -------------------------------------------------------------------------------- /doc/images/tutorials/DebugFirstFlow/dopayment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/DebugFirstFlow/dopayment.png -------------------------------------------------------------------------------- /doc/images/tutorials/DebugFirstFlow/newconfiguration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/DebugFirstFlow/newconfiguration.png -------------------------------------------------------------------------------- /doc/images/tutorials/DebugFirstFlow/setbreakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/DebugFirstFlow/setbreakpoint.png -------------------------------------------------------------------------------- /doc/images/tutorials/DebugFirstFlow/step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/DebugFirstFlow/step1.png -------------------------------------------------------------------------------- /doc/images/tutorials/DebugFirstFlow/step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/DebugFirstFlow/step2.png -------------------------------------------------------------------------------- /doc/images/tutorials/GuiceWorkflowExample/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/GuiceWorkflowExample/image1.png -------------------------------------------------------------------------------- /doc/images/tutorials/SpringEmailExample/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/SpringEmailExample/result.png -------------------------------------------------------------------------------- /doc/images/tutorials/SpringJmsExample/importedProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/SpringJmsExample/importedProject.png -------------------------------------------------------------------------------- /doc/images/tutorials/SpringJmsExample/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/SpringJmsExample/result.png -------------------------------------------------------------------------------- /doc/images/tutorials/SpringMVCExample/flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/SpringMVCExample/flow.png -------------------------------------------------------------------------------- /doc/images/tutorials/SpringMVCExample/importedproject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/SpringMVCExample/importedproject.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/flow3node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/flow3node.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/flowperspective.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/flowperspective.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/newcustomblock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/newcustomblock.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/newcustomblockmenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/newcustomblockmenu.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/newworkflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/newworkflow.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/parameters.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/projectwithimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/projectwithimage.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/result.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/selectcustomnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/selectcustomnode.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowExample/withcustomicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowExample/withcustomicon.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowHowTo/img1_custom_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowHowTo/img1_custom_icon.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowHowTo/img2_cb_impl_class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowHowTo/img2_cb_impl_class.png -------------------------------------------------------------------------------- /doc/images/tutorials/WorkflowHowTo/img3_cb_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/tutorials/WorkflowHowTo/img3_cb_view.png -------------------------------------------------------------------------------- /doc/images/with-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/images/with-icon.png -------------------------------------------------------------------------------- /doc/pdf/HelloWorld.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/pdf/HelloWorld.pdf -------------------------------------------------------------------------------- /doc/pdf/StudioDebugPlugin.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/doc/pdf/StudioDebugPlugin.pdf -------------------------------------------------------------------------------- /guava-cacheloader/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /guava-cacheloader/README.md: -------------------------------------------------------------------------------- 1 | Guava CacheLoader Plugin. 2 | ======== 3 | 4 | guava-cacheloader plugin allows use guava-cache for workflow loader 5 | 6 | 7 | -------------------------------------------------------------------------------- /guava-cacheloader/src/main/java/org/neuro4j/workflow/guava/GuavaCachedWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.guava; 2 | 3 | import java.util.concurrent.Callable; 4 | import java.util.concurrent.ExecutionException; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | import org.neuro4j.workflow.common.FlowExecutionException; 8 | import org.neuro4j.workflow.common.Workflow; 9 | import org.neuro4j.workflow.loader.WorkflowLoader; 10 | 11 | import com.google.common.base.Throwables; 12 | import com.google.common.cache.Cache; 13 | import com.google.common.cache.CacheBuilder; 14 | 15 | /** 16 | * WorkflowLoader based on Guava Cache. 17 | * 18 | */ 19 | public class GuavaCachedWorkflowLoader implements WorkflowLoader{ 20 | 21 | private final WorkflowLoader delegate; 22 | 23 | private final Cache cache; 24 | 25 | 26 | public GuavaCachedWorkflowLoader(WorkflowLoader delegate, Cache cache) { 27 | super(); 28 | this.delegate = delegate; 29 | this.cache = cache; 30 | } 31 | 32 | public static GuavaCachedWorkflowLoader cacheWithExpiration(final WorkflowLoader delegate, final long duration, 33 | final TimeUnit unit) { 34 | Cache cache = CacheBuilder.newBuilder().expireAfterAccess(duration, unit).build(); 35 | return new GuavaCachedWorkflowLoader(delegate, cache); 36 | } 37 | 38 | 39 | @Override 40 | public Workflow load(final String name) throws FlowExecutionException { 41 | try { 42 | return cache.get(name, new Callable() { 43 | @Override 44 | public Workflow call() throws Exception { 45 | return delegate.load(name); 46 | } 47 | }); 48 | } catch (ExecutionException e) { 49 | Throwables.propagateIfPossible(e.getCause(), FlowExecutionException.class); 50 | throw Throwables.propagate(e.getCause()); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /guava-cacheloader/src/test/java/org/neuro4j/workflow/async/CounterWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.Workflow; 7 | import org.neuro4j.workflow.loader.WorkflowLoader; 8 | 9 | public class CounterWorkflowLoader implements WorkflowLoader{ 10 | 11 | AtomicInteger counter = new AtomicInteger(0); 12 | 13 | private final WorkflowLoader delegate; 14 | 15 | public CounterWorkflowLoader(WorkflowLoader delegate){ 16 | this.delegate = delegate; 17 | } 18 | 19 | @Override 20 | public Workflow load(String name) throws FlowExecutionException { 21 | counter.incrementAndGet(); 22 | return delegate.load(name); 23 | } 24 | 25 | public AtomicInteger getCounter(){ 26 | return counter; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /guava-cacheloader/src/test/java/org/neuro4j/workflow/async/CounterXmlWorkflowConverter.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | import java.io.Reader; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | import org.neuro4j.workflow.common.FlowExecutionException; 7 | import org.neuro4j.workflow.common.Workflow; 8 | import org.neuro4j.workflow.common.WorkflowConverter; 9 | import org.neuro4j.workflow.common.XmlWorkflowConverter; 10 | 11 | public class CounterXmlWorkflowConverter implements WorkflowConverter{ 12 | 13 | XmlWorkflowConverter converter = new XmlWorkflowConverter(); 14 | 15 | AtomicInteger counter = new AtomicInteger(0); 16 | 17 | 18 | @Override 19 | public Workflow convert(Reader reader, String name) throws FlowExecutionException { 20 | counter.incrementAndGet(); 21 | return converter.convert(reader, name); 22 | } 23 | 24 | @Override 25 | public String getFileExt() { 26 | return converter.getFileExt(); 27 | } 28 | 29 | public AtomicInteger getCounter() { 30 | return counter; 31 | } 32 | 33 | 34 | } -------------------------------------------------------------------------------- /guava-cacheloader/src/test/java/org/neuro4j/workflow/async/CustomBlockSleep.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinition; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | import org.neuro4j.workflow.enums.CachedNode; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.neuro4j.workflow.ActionBlock; 12 | 13 | import static org.neuro4j.workflow.async.CustomBlockSleep.*; 14 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 15 | 16 | @ParameterDefinitionList(input={ 17 | @ParameterDefinition(name=IN_TIMETOSLEE, isOptional=true, type= "java.lang.Integer")}, 18 | output={ 19 | }) 20 | @CachedNode(type=NONE) 21 | public class CustomBlockSleep implements ActionBlock { 22 | 23 | private static final Logger logger = LoggerFactory.getLogger(CustomBlockSleep.class); 24 | 25 | static final String IN_TIMETOSLEE = "timeToSlee"; 26 | 27 | 28 | 29 | 30 | public int execute(FlowContext ctx) throws FlowExecutionException { 31 | 32 | Integer timeToSlee = (Integer)ctx.get(IN_TIMETOSLEE); 33 | 34 | try { 35 | Thread.sleep(timeToSlee); 36 | } catch (InterruptedException e) { 37 | logger.error(e.getMessage(), e); 38 | } 39 | 40 | return NEXT; 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /guava-cacheloader/src/test/java/org/neuro4j/workflow/async/FakeWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | import static org.junit.Assert.fail; 4 | 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.Workflow; 7 | import org.neuro4j.workflow.loader.WorkflowLoader; 8 | 9 | public class FakeWorkflowLoader implements WorkflowLoader { 10 | 11 | @Override 12 | public Workflow load(String name) throws FlowExecutionException { 13 | fail("should not be here"); 14 | throw new FlowExecutionException("It should not be there!"); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /guice-workflow-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /guice-workflow-adapter/README.md: -------------------------------------------------------------------------------- 1 | Google Guice Plugin. 2 | ======== 3 | 4 | guice-workflow-adapter plugin allows developer to initialize custom blocks using Google Guice library. 5 | 6 | 7 | Reusable java code with service: 8 | ![workflow-example-higlevel](https://raw.github.com/neuro4j/workflow/master/doc/images/guice-workflow-adapter/customblock.png "Google Guice adapter:") 9 | -------------------------------------------------------------------------------- /guice-workflow-adapter/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.neuro4j 7 | workflow 8 | 3.5.1-SNAPSHOT 9 | ../pom.xml 10 | 11 | guice-workflow-adapter 12 | 13 | 14 | 15 | com.google.inject 16 | guice 17 | 18 | 19 | org.neuro4j 20 | neuro4j-workflow-core 21 | ${project.version} 22 | 23 | 24 | junit 25 | junit 26 | test 27 | 28 | 29 | 30 | 31 | 32 | src/main/java 33 | 34 | **/*.n4j 35 | 36 | 37 | 38 | src/main/resources 39 | 40 | **/** 41 | 42 | 43 | 44 | 45 | 46 | src/test/java 47 | 48 | **/** 49 | 50 | 51 | 52 | src/test/resources 53 | 54 | **/** 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /guice-workflow-adapter/src/test/java/org/neuro4j/workflow/guice/AllTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.guice; 18 | 19 | import org.junit.runner.RunWith; 20 | import org.junit.runners.Suite; 21 | import org.junit.runners.Suite.SuiteClasses; 22 | 23 | @RunWith(Suite.class) 24 | @SuiteClasses({ GuiceWithWorkflowTestCase.class }) 25 | public class AllTests { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /guice-workflow-adapter/src/test/java/org/neuro4j/workflow/guice/AppInjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.guice; 18 | 19 | import org.neuro4j.workflow.guice.service.MessageService; 20 | import org.neuro4j.workflow.guice.service.MyMessageService; 21 | 22 | import com.google.inject.AbstractModule; 23 | 24 | public class AppInjector extends AbstractModule { 25 | 26 | @Override 27 | protected void configure() { 28 | bind(MessageService.class).to(MyMessageService.class); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /guice-workflow-adapter/src/test/java/org/neuro4j/workflow/guice/flows/CustomBlockWithService.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2013-2016, Neuro4j 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.neuro4j.workflow.guice.flows; 19 | 20 | import org.neuro4j.workflow.FlowContext; 21 | import org.neuro4j.workflow.common.FlowExecutionException; 22 | import org.neuro4j.workflow.guice.service.MessageService; 23 | import org.neuro4j.workflow.node.CustomBlock; 24 | 25 | import com.google.inject.Inject; 26 | 27 | 28 | /** 29 | * This custom block uses Google Guice library for dependency injection. 30 | * 31 | */ 32 | public class CustomBlockWithService extends CustomBlock { 33 | 34 | private MessageService service; 35 | 36 | public int execute(FlowContext ctx) throws FlowExecutionException { 37 | 38 | this.service.sendMessage("Hi", "Mister"); 39 | return NEXT; 40 | } 41 | 42 | 43 | @Inject 44 | public void setService(MessageService svc) { 45 | this.service = svc; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /guice-workflow-adapter/src/test/java/org/neuro4j/workflow/guice/service/MessageService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.guice.service; 18 | 19 | public interface MessageService { 20 | String sendMessage(String msg, String receipient); 21 | } -------------------------------------------------------------------------------- /guice-workflow-adapter/src/test/java/org/neuro4j/workflow/guice/service/MyMessageService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | 18 | package org.neuro4j.workflow.guice.service; 19 | 20 | /** 21 | * Test service. 22 | * 23 | */ 24 | public class MyMessageService implements MessageService { 25 | 26 | public String sendMessage(String msg, String receipient) { 27 | String message = "Message to " + receipient + " = " + msg; 28 | System.out.println(message); 29 | return message; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /history.md: -------------------------------------------------------------------------------- 1 | # 2.1.1 - TBD 2 | * added XMLFileWorkflowLoader, ClasspathWorkflowLoader, RemoteWorkflowLoader 3 | 4 | # 2.0.1 - 10/10/2016 5 | -------------------------------------------------------------------------------- /jasper-report-workflow/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /.DS_Store 7 | -------------------------------------------------------------------------------- /jasper-report-workflow/src/main/java/org/neuro4j/jasper/report/GenerateReport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/jasper-report-workflow/src/main/java/org/neuro4j/jasper/report/GenerateReport.png -------------------------------------------------------------------------------- /jasper-report-workflow/src/main/resources/org/neuro4j/jasper/report/GenerateReport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/jasper-report-workflow/src/main/resources/org/neuro4j/jasper/report/GenerateReport.png -------------------------------------------------------------------------------- /jasper-report-workflow/src/test/java/tests/org/neuro4j/jasper/reports/PdfReportTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 tests.org.neuro4j.jasper.reports; 17 | 18 | import java.util.Collections; 19 | 20 | import junit.framework.TestCase; 21 | 22 | import org.junit.Before; 23 | import org.junit.Test; 24 | import org.neuro4j.workflow.ExecutionResult; 25 | import org.neuro4j.workflow.common.WorkflowEngine; 26 | import org.neuro4j.workflow.common.WorkflowEngine.ConfigBuilder; 27 | 28 | /** 29 | * 30 | */ 31 | public class PdfReportTestCase extends TestCase { 32 | 33 | 34 | WorkflowEngine engine; 35 | 36 | @Before 37 | public void setUp(){ 38 | engine = new WorkflowEngine(new ConfigBuilder()); 39 | } 40 | 41 | @Test 42 | public void testPdfCreation() { 43 | ExecutionResult result = engine.execute("tests.org.neuro4j.jasper.reports.GenerateReport-Start", Collections. emptyMap()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /jasper-report-workflow/src/test/resources/reports/report1.jasper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/jasper-report-workflow/src/test/resources/reports/report1.jasper -------------------------------------------------------------------------------- /jasper-report-workflow/src/test/resources/reports/report1.jrprint: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/jasper-report-workflow/src/test/resources/reports/report1.jrprint -------------------------------------------------------------------------------- /logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /netflix-governator-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /netflix-governator-adapter/README.md: -------------------------------------------------------------------------------- 1 | Netflix Governator Plugin. 2 | ======== 3 | 4 | netflix-governator-adapter allows developer to initialize custom blocks using Netflix Governator library. 5 | 6 | Netflix Governator is a library of extensions and utilities that extend Google Guice to provide: 7 | 8 | * Classpath scanning and automatic binding 9 | * Lifecycle management 10 | * Configuration to field mapping 11 | * Field validation 12 | * Parallelized object warmup 13 | * Lazy singleton support 14 | * Generic binding annotations 15 | 16 | Example: 17 | ``` 18 | Injector injector = LifecycleInjector.builder().withModuleClass(AppInjector.class) 19 | .usingBasePackages("org.neuro4j").build().createInjector(); 20 | 21 | GovernatorCustomBlockInitStrategy initStrategy = new GovernatorCustomBlockInitStrategy(injector); 22 | 23 | WorkflowEngine engine = new WorkflowEngine(new ConfigBuilder().withCustomBlockInitStrategy(initStrategy)); 24 | 25 | ExecutionResult result = engine.execute("org.neuro4j.workflow.governator.flows.Flow-Start"); 26 | 27 | ``` 28 | -------------------------------------------------------------------------------- /netflix-governator-adapter/src/test/java/org/neuro4j/workflow/governator/AppInjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.governator; 18 | 19 | import org.neuro4j.workflow.governator.service.MessageService; 20 | import org.neuro4j.workflow.governator.service.MyMessageService; 21 | 22 | import com.google.inject.AbstractModule; 23 | 24 | public class AppInjector extends AbstractModule { 25 | 26 | @Override 27 | protected void configure() { 28 | bind(MessageService.class).to(MyMessageService.class); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /netflix-governator-adapter/src/test/java/org/neuro4j/workflow/governator/flows/Flow.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 0, 32, -1, -181|1, 185, 0, -28| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 29, 1, -186|-1, 181, 0, -34| 28 | 29 | 30 | 31 | 32 | This flow demonstrates how to use Google Guice for dependency injection in CustomBlock 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /netflix-governator-adapter/src/test/java/org/neuro4j/workflow/governator/service/MessageService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.governator.service; 18 | 19 | public interface MessageService { 20 | String sendMessage(String msg, String receipient); 21 | } -------------------------------------------------------------------------------- /netflix-governator-adapter/src/test/java/org/neuro4j/workflow/governator/service/MyMessageService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | 18 | package org.neuro4j.workflow.governator.service; 19 | 20 | /** 21 | * Test service. 22 | * 23 | */ 24 | public class MyMessageService implements MessageService { 25 | 26 | public String sendMessage(String msg, String receipient) { 27 | String message = "Message to " + receipient + " = " + msg; 28 | System.out.println(message); 29 | return message; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/README.md: -------------------------------------------------------------------------------- 1 | Netflix Hystrix Plugin. 2 | ======== 3 | 4 | netflix-hystrix-adapter 5 | 6 | 7 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/src/main/java/org/neuro4j/workflow/hystrix/HystrixLifecycleListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | 18 | package org.neuro4j.workflow.hystrix; 19 | 20 | public interface HystrixLifecycleListener { 21 | 22 | void onConstruct(); 23 | 24 | void onCommandStart(); 25 | 26 | void onCommandComplete(); 27 | } 28 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | neuro4j{ 2 | 3 | hystrix{ 4 | 5 | WorkflowDefaultGroupKey{ 6 | threadpoolSize = 20 7 | queueSize = 50 8 | maxWait = 3000 9 | } 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /netflix-hystrix-adapter/src/test/java/org/neuro4j/workflow/hystrix/HystrixTest.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.hystrix; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.neuro4j.workflow.ExecutionResult; 11 | import org.neuro4j.workflow.common.WorkflowEngine; 12 | 13 | public class HystrixTest { 14 | 15 | 16 | 17 | @Before 18 | public void setUp() { 19 | 20 | 21 | } 22 | 23 | 24 | @Test 25 | public void testSympleHystryxCommand() { 26 | 27 | WorkflowEngine engine = new WorkflowEngine(); 28 | Map parameters = new HashMap(); 29 | 30 | String name = "Mister"; 31 | 32 | parameters.put("name", name); 33 | 34 | ExecutionResult result = engine.execute("org.neuro4j.workflow.hystrix.FlowWithHystrix-StartNode1", parameters); 35 | assertNotNull(result); 36 | assertNull(result.getException()); 37 | Map returnParameters = result.getFlowContext().getParameters(); 38 | 39 | 40 | String message = (String)returnParameters.get("message"); 41 | assertEquals("Hello, " + name, message); 42 | 43 | } 44 | 45 | @Test 46 | public void testSleepCommand() { 47 | 48 | WorkflowEngine engine = new WorkflowEngine(); 49 | Map parameters = new HashMap(); 50 | 51 | 52 | parameters.put("sleepMs", 1500l); 53 | 54 | ExecutionResult result = engine.execute("org.neuro4j.workflow.hystrix.FlowWithHystrix-StartNode2", parameters); 55 | assertNotNull(result); 56 | assertNull(result.getException()); 57 | Map returnParameters = result.getFlowContext().getParameters(); 58 | 59 | String lastNode = result.getLastSuccessfulNodeName(); 60 | 61 | assertEquals("EndNode3", lastNode); 62 | 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/src/test/java/org/neuro4j/workflow/hystrix/SleepHystrixCommand.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.hystrix; 2 | 3 | 4 | import static org.neuro4j.workflow.hystrix.DefaultHystrixBootstrap.DEFAULT_COMMAND_KEY; 5 | import static org.neuro4j.workflow.hystrix.DefaultHystrixBootstrap.getSetterForGroup; 6 | import static org.neuro4j.workflow.hystrix.SleepHystrixCommand.IN_PARAM1; 7 | 8 | import org.neuro4j.workflow.FlowContext; 9 | import org.neuro4j.workflow.common.ParameterDefinition; 10 | import org.neuro4j.workflow.common.ParameterDefinitionList; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | @ParameterDefinitionList(input={ 15 | @ParameterDefinition(name=IN_PARAM1, isOptional=false, type= "java.lang.Long")}) 16 | 17 | public class SleepHystrixCommand extends BaseHystrixCommand { 18 | 19 | static final String IN_PARAM1 = "param1"; 20 | private static final Logger Logger = LoggerFactory.getLogger(SleepHystrixCommand.class); 21 | 22 | public SleepHystrixCommand() { 23 | super(getSetterForGroup("TestGroupKey1", "TestCommandKey1")); 24 | } 25 | 26 | @Override 27 | protected Integer executeInternal(FlowContext ctx) throws Exception { 28 | 29 | Long sleepMs = (Long) ctx.get(IN_PARAM1); 30 | 31 | try { 32 | Thread.currentThread().sleep(sleepMs); 33 | } catch (InterruptedException ex) { 34 | Logger.error(ex.getMessage(), ex); 35 | } 36 | 37 | return NEXT; 38 | } 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/src/test/java/org/neuro4j/workflow/hystrix/SomeHystrixCommand.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.hystrix; 2 | 3 | 4 | import static org.neuro4j.workflow.hystrix.SomeHystrixCommand.IN_PARAM1; 5 | import static org.neuro4j.workflow.hystrix.SomeHystrixCommand.OUT_PARAM; 6 | 7 | import org.neuro4j.workflow.FlowContext; 8 | import org.neuro4j.workflow.common.ParameterDefinition; 9 | import org.neuro4j.workflow.common.ParameterDefinitionList; 10 | import org.neuro4j.workflow.hystrix.BaseHystrixCommand; 11 | 12 | @ParameterDefinitionList(input={ 13 | @ParameterDefinition(name=IN_PARAM1, isOptional=true, type= "java.lang.String")}, 14 | output={ 15 | @ParameterDefinition(name=OUT_PARAM, isOptional=true, type= "java.lang.String")}) 16 | 17 | public class SomeHystrixCommand extends BaseHystrixCommand { 18 | 19 | static final String IN_PARAM1 = "param1"; 20 | 21 | static final String OUT_PARAM = "param"; 22 | 23 | 24 | 25 | @Override 26 | protected Integer executeInternal(FlowContext ctx) throws Exception { 27 | 28 | String name = (String)ctx.get(IN_PARAM1); 29 | 30 | String message = "Hello, " + name; 31 | 32 | ctx.put(OUT_PARAM, message); 33 | return NEXT; 34 | } 35 | 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /netflix-hystrix-adapter/src/test/resources/application.conf: -------------------------------------------------------------------------------- 1 | neuro4j{ 2 | 3 | hystrix{ 4 | 5 | TestGroupKey1{ 6 | threadpoolSize = 10 7 | queueSize = 10 8 | maxWait = 1000 9 | } 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /neuro4j-typesafeconfig/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /.DS_Store 7 | -------------------------------------------------------------------------------- /neuro4j-typesafeconfig/README.md: -------------------------------------------------------------------------------- 1 | TypeSaveConfig plugin. 2 | ======== 3 | 4 | neuro4j-typesafeconfig plugin allows to use typesafe library to configure workflow processor from config file 5 | 6 | * add file ```application.conf``` to classpath 7 | * add new configuration 8 | ``` 9 | neuro4j{ 10 | 11 | // will not use cache - can be used for dev env 12 | workflowCache = emptyMap 13 | 14 | aliases { 15 | // will map myflow -> org.neuro4j.MyFlow-Start 16 | myflow=org.neuro4j.MyFlow-Start 17 | myflow2=org.neuro4j.workflow.MyFlow-StartNode2 18 | "/homepage.htm"=org.neuro4j.workflow.HomePage-Start 19 | } 20 | 21 | // pool setting for parallel execution 22 | threadPoolTaskConfig{ 23 | 24 | corePoolSize = 4 25 | 26 | maxPoolSize = 2147483647 27 | 28 | keepAliveSeconds = 65 29 | 30 | queueCapacity = 2147483647 31 | 32 | allowCoreThreadTimeOut = false 33 | } 34 | 35 | } 36 | ``` 37 | * Create configuration with WorkflowConfigFactory 38 | ``` 39 | ConfigBuilder config = WorkflowConfigFactory.load(); 40 | // add specific configuration 41 | WorkflowEngine engine = new WorkflowEngine(config); 42 | 43 | ``` 44 | -------------------------------------------------------------------------------- /neuro4j-typesafeconfig/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.neuro4j 7 | workflow 8 | 3.5.1-SNAPSHOT 9 | ../pom.xml 10 | 11 | TypeSafeConfig for WorkflowProcessor 12 | neuro4j-typesafeconfig 13 | 14 | 15 | 16 | com.typesafe 17 | config 18 | 19 | 20 | org.neuro4j 21 | neuro4j-workflow-core 22 | ${project.version} 23 | 24 | 25 | junit 26 | junit 27 | test 28 | 29 | 30 | 31 | 32 | 33 | src/main/java 34 | 35 | **/** 36 | 37 | 38 | 39 | src/main/resources 40 | 41 | **/** 42 | 43 | 44 | 45 | 46 | 47 | src/test/java 48 | 49 | **/** 50 | 51 | 52 | 53 | src/test/resources 54 | 55 | **/** 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /neuro4j-typesafeconfig/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | neuro4j{ 2 | 3 | workflowCache = concurrentMap 4 | 5 | aliases { 6 | 7 | } 8 | 9 | threadPoolTaskConfig{ 10 | 11 | corePoolSize = 4 12 | 13 | maxPoolSize = 2147483647 14 | 15 | keepAliveSeconds = 65 16 | 17 | queueCapacity = 2147483647 18 | 19 | allowCoreThreadTimeOut = false 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /neuro4j-typesafeconfig/src/test/resources/application.conf: -------------------------------------------------------------------------------- 1 | neuro4j{ 2 | 3 | workflowCache = emptyMap 4 | 5 | aliases { 6 | myflow=org.neuro4j.MyFlow-Start 7 | myflow2=org.neuro4j.workflow.MyFlow-StartNode2 8 | "/homepage.htm"=org.neuro4j.workflow.HomePage-Start 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /neuro4j-workflow-common/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /neuro4j-workflow-common/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.neuro4j 7 | workflow 8 | 3.5.1-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | neuro4j-workflow-common 13 | 14 | 15 | org.neuro4j 16 | neuro4j-workflow-core 17 | ${project.version} 18 | 19 | 20 | 21 | 22 | 23 | src/main/java 24 | 25 | **/** 26 | 27 | true 28 | 29 | **/*.java 30 | 31 | 32 | 33 | src/main/resources 34 | 35 | **/** 36 | 37 | 38 | 39 | 40 | 41 | src/test/java 42 | 43 | **/** 44 | 45 | 46 | 47 | src/test/resources 48 | 49 | **/** 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /neuro4j-workflow-common/src/main/java/org/neuro4j/workflow/core/SystemOutBlock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.core; 18 | 19 | import org.neuro4j.workflow.FlowContext; 20 | import org.neuro4j.workflow.common.FlowExecutionException; 21 | import org.neuro4j.workflow.common.ParameterDefinition; 22 | import org.neuro4j.workflow.common.ParameterDefinitionList; 23 | import org.neuro4j.workflow.node.CustomBlock; 24 | 25 | @ParameterDefinitionList(input = { @ParameterDefinition(name = "varToPrint", isOptional = true, type = "java.lang.Object") }) 26 | public class SystemOutBlock extends CustomBlock { 27 | 28 | final static String VAR_TO_PRINT = "varToPrint"; 29 | 30 | public int execute(FlowContext ctx) throws FlowExecutionException { 31 | 32 | Object mName = (Object) ctx.get(VAR_TO_PRINT); 33 | 34 | if (mName != null) 35 | { 36 | System.out.println(mName.toString()); 37 | } 38 | 39 | return NEXT; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /neuro4j-workflow-common/src/main/java/org/neuro4j/workflow/log/PrintFlowContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.log; 18 | 19 | import java.util.Map; 20 | 21 | import org.neuro4j.workflow.FlowContext; 22 | import org.neuro4j.workflow.common.FlowExecutionException; 23 | import org.neuro4j.workflow.common.ParameterDefinitionList; 24 | import org.neuro4j.workflow.node.CustomBlock; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | /** 29 | * Print all parameters in FlowContext 30 | * 31 | */ 32 | @ParameterDefinitionList(input = {}, output = {}) 33 | public class PrintFlowContext extends CustomBlock { 34 | 35 | private static final Logger Logger = LoggerFactory.getLogger(PrintFlowContext.class); 36 | 37 | 38 | public int execute(FlowContext ctx) throws FlowExecutionException { 39 | 40 | Map parameters = ctx.getParameters(); 41 | 42 | for (String key : parameters.keySet()) { 43 | Logger.info(" \n Key: {} value: {} ", new Object[] { key, parameters.get(key) }); 44 | } 45 | 46 | return NEXT; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/ActionBlock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow; 18 | 19 | import org.neuro4j.workflow.common.FlowExecutionException; 20 | 21 | /** 22 | * Base interface for executable blocks. 23 | * 24 | */ 25 | public interface ActionBlock { 26 | 27 | public static final int NEXT = 1; 28 | public static final int ERROR = 2; 29 | 30 | /** 31 | * @param context input context 32 | * @return 1 (NEXT) or 2 (ERROR) exit 33 | * @throws FlowExecutionException in case of error during execution 34 | */ 35 | public int execute(FlowContext context) throws FlowExecutionException; 36 | 37 | /** 38 | * Processor run this method once during initialization. 39 | * @throws FlowExecutionException if there is an error 40 | */ 41 | public default void init() throws FlowExecutionException{ 42 | 43 | }; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/ActionHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow; 18 | 19 | import org.neuro4j.workflow.node.WorkflowNode.NodeInfo; 20 | 21 | public interface ActionHandler { 22 | 23 | public default void preExecute(NodeInfo nodeInfo, FlowContext context, ActionBlock actionBlock){ 24 | 25 | } 26 | 27 | public default void postExecute(NodeInfo nodeInfo, FlowContext context, ActionBlock actionBlock){ 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/async/CallableTask.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | import org.neuro4j.workflow.ExecutionResult; 6 | import org.neuro4j.workflow.WorkflowRequest; 7 | import org.neuro4j.workflow.node.WorkflowProcessor; 8 | 9 | public class CallableTask implements Callable { 10 | 11 | private final WorkflowProcessor processor; 12 | private final String flow; 13 | private final WorkflowRequest request; 14 | 15 | public CallableTask(final WorkflowProcessor processor, final String flow, final WorkflowRequest request) { 16 | this.processor = processor; 17 | this.flow = flow; 18 | this.request = request; 19 | } 20 | 21 | @Override 22 | public ExecutionResult call() throws Exception { 23 | return processor.execute(flow, request); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/cache/EmptyWorkflowCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.cache; 18 | 19 | import org.neuro4j.workflow.common.FlowExecutionException; 20 | import org.neuro4j.workflow.common.Workflow; 21 | import org.neuro4j.workflow.loader.WorkflowLoader; 22 | 23 | /** 24 | * Default cache implementation 25 | * 26 | */ 27 | public enum EmptyWorkflowCache implements WorkflowCache { 28 | INSTANCE; 29 | 30 | 31 | @Override 32 | public Workflow get(WorkflowLoader loader, String flowName) throws FlowExecutionException { 33 | return loader.load(flowName); 34 | } 35 | 36 | @Override 37 | public void clearAll() { 38 | } 39 | 40 | @Override 41 | public void clear(String key) { 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/cache/WorkflowCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.cache; 18 | 19 | import org.neuro4j.workflow.common.FlowExecutionException; 20 | import org.neuro4j.workflow.common.Workflow; 21 | import org.neuro4j.workflow.loader.WorkflowLoader; 22 | 23 | /** 24 | * Base interface for cache 25 | * 26 | */ 27 | public interface WorkflowCache { 28 | 29 | public void clearAll(); 30 | 31 | public void clear(String key); 32 | 33 | public Workflow get(WorkflowLoader loader, String flow) throws FlowExecutionException; 34 | } 35 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/FlowExecutionException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | public class FlowExecutionException extends Exception { 20 | 21 | /** 22 | * 23 | */ 24 | private static final long serialVersionUID = 1L; 25 | 26 | public FlowExecutionException(String msg) { 27 | super(msg); 28 | } 29 | 30 | public FlowExecutionException(String string, Exception e1) { 31 | super(string, e1); 32 | } 33 | 34 | public FlowExecutionException(Throwable cause) { 35 | super(cause); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/JSONWorkflowConverter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | import java.io.Reader; 20 | 21 | public class JSONWorkflowConverter implements WorkflowConverter{ 22 | 23 | @Override 24 | public Workflow convert(Reader stream, String name) throws FlowExecutionException { 25 | throw new UnsupportedOperationException("Not supported yet"); 26 | } 27 | 28 | @Override 29 | public String getFileExt() { 30 | throw new UnsupportedOperationException("Not supported yet"); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/ParameterDefinition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @Target(ElementType.TYPE) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | public @interface ParameterDefinition { 27 | public String name(); 28 | 29 | public String type() default "java.lang.String"; 30 | 31 | public boolean isOptional() default true; 32 | } 33 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/ParameterDefinitionImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | import java.lang.annotation.Annotation; 20 | 21 | public class ParameterDefinitionImpl implements ParameterDefinition { 22 | 23 | private String name; 24 | private String type; 25 | private Boolean optional; 26 | 27 | public ParameterDefinitionImpl(String name, String type, Boolean optional) 28 | { 29 | this.name = name; 30 | this.type = type; 31 | this.optional = optional; 32 | } 33 | 34 | public Class annotationType() { 35 | return ParameterDefinition.class; 36 | } 37 | 38 | public String name() { 39 | return name; 40 | } 41 | 42 | public String type() { 43 | return type; 44 | } 45 | 46 | public boolean isOptional() { 47 | return optional; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/ParameterDefinitionList.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @Target(ElementType.TYPE) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | public @interface ParameterDefinitionList { 27 | 28 | ParameterDefinition[] input() default { }; 29 | 30 | ParameterDefinition[] output() default { }; 31 | } 32 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/WorkflowConverter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | import java.io.Reader; 20 | 21 | /** 22 | * Converts xml/json/... representation of workflow into java object 23 | * 24 | */ 25 | public interface WorkflowConverter { 26 | 27 | public final static String DEFAULT_EXT = ".n4j"; 28 | 29 | Workflow convert(Reader reader, String name) throws FlowExecutionException; 30 | 31 | String getFileExt(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/common/XmlWorkflowConverter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.common; 18 | 19 | import java.io.Reader; 20 | 21 | import org.neuro4j.workflow.loader.f4j.FlowConverter; 22 | import org.neuro4j.workflow.utils.Validation; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | public class XmlWorkflowConverter implements WorkflowConverter{ 27 | 28 | private static final Logger logger = LoggerFactory.getLogger(XmlWorkflowConverter.class); 29 | 30 | final String fileExt; 31 | 32 | public XmlWorkflowConverter(final String ext){ 33 | this.fileExt = ext; 34 | } 35 | 36 | public XmlWorkflowConverter(){ 37 | this(DEFAULT_EXT); 38 | } 39 | 40 | @Override 41 | public Workflow convert(Reader stream, String name) throws FlowExecutionException { 42 | Validation.requireNonNull(stream, () -> new FlowExecutionException("InputStream can not be null")); 43 | 44 | logger.debug("Converting workflow {} from xml to java object", name); 45 | 46 | return FlowConverter.xml2workflow(stream, name); 47 | } 48 | 49 | @Override 50 | public String getFileExt() { 51 | return this.fileExt; 52 | } 53 | 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/debug/DebugService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.debug; 18 | 19 | import org.neuro4j.workflow.WorkflowRequest; 20 | import org.neuro4j.workflow.node.WorkflowNode; 21 | 22 | public class DebugService { 23 | 24 | private static DebugService service = new DebugService(); 25 | 26 | private DebugService() 27 | { 28 | } 29 | 30 | public static DebugService getInstance() { 31 | return service; 32 | } 33 | 34 | public void onNodeCall(WorkflowNode node, WorkflowRequest request) { 35 | 36 | } 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/enums/ActionBlockCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.enums; 18 | 19 | /** 20 | * Defines cache's types which can be applied to ActionNode 21 | * 22 | */ 23 | public enum ActionBlockCache { 24 | /** Creates just one instance of ActionBlock per WorkflowEngine */ 25 | SINGLETON, 26 | 27 | /** Creates one instance of ActionBlock for each uuid */ 28 | NODE, 29 | 30 | /** Creates new instance of ActionBlock for each call */ 31 | NONE 32 | 33 | }; 34 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/enums/CachedNode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.enums; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @Target(ElementType.TYPE) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | public @interface CachedNode { 27 | ActionBlockCache type() default ActionBlockCache.NONE; 28 | } -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/enums/FlowVisibility.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.enums; 18 | 19 | /** 20 | * Flow can be public or private. 21 | * Public flow can be called by from outside. 22 | * Private flow can be called just by other flow. 23 | */ 24 | public enum FlowVisibility { 25 | Public, 26 | Private; 27 | 28 | private static String[] opNames = new String[] { Public.name(), Private.name() }; 29 | 30 | public static FlowVisibility getDefault() 31 | { 32 | return Public; 33 | } 34 | 35 | public static String[] types() { 36 | return opNames; 37 | } 38 | 39 | public static FlowVisibility getByName(String name) 40 | { 41 | for (FlowVisibility d : values()) 42 | { 43 | if (d.name().equalsIgnoreCase(name)) 44 | { 45 | return d; 46 | } 47 | } 48 | return null; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/ClasspathWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader; 18 | 19 | import java.io.IOException; 20 | import java.net.URL; 21 | 22 | import org.neuro4j.workflow.common.WorkflowConverter; 23 | 24 | /** 25 | * Loads workflow from classpath. 26 | * 27 | */ 28 | public class ClasspathWorkflowLoader extends URLWorkflowLoader{ 29 | 30 | 31 | public ClasspathWorkflowLoader(final WorkflowConverter converter){ 32 | super(converter); 33 | } 34 | 35 | @Override 36 | protected URL getResource(String name) throws IOException { 37 | String location = normalize(name); 38 | return getClass().getClassLoader().getResource(location + converter.getFileExt()); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/CustomBlockInitStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader; 18 | 19 | import org.neuro4j.workflow.ActionBlock; 20 | import org.neuro4j.workflow.common.FlowExecutionException; 21 | 22 | /** 23 | * Defines method to load CustomBlock 24 | * 25 | */ 26 | public interface CustomBlockInitStrategy { 27 | 28 | public ActionBlock loadCustomBlock(String className) throws FlowExecutionException; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/FileWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader; 18 | 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.net.URL; 22 | 23 | import org.neuro4j.workflow.common.FlowExecutionException; 24 | import org.neuro4j.workflow.common.WorkflowConverter; 25 | 26 | /** 27 | * Loads workflow from external folder. 28 | * 29 | */ 30 | public class FileWorkflowLoader extends URLWorkflowLoader { 31 | 32 | final URLWorkflowLoader delegate; 33 | final File baseDir; 34 | 35 | public FileWorkflowLoader(final WorkflowConverter converter, URLWorkflowLoader loader, File baseDir) 36 | throws FlowExecutionException { 37 | super(converter); 38 | if (baseDir == null || !baseDir.exists() || !baseDir.isDirectory()) { 39 | throw new FlowExecutionException("BaseDir is not valid : " + baseDir); 40 | } 41 | this.delegate = loader; 42 | this.baseDir = baseDir; 43 | } 44 | 45 | 46 | @Override 47 | protected URL getResource(final String name) throws IOException { 48 | String location = normalize(name); 49 | File file = new File(baseDir , location + converter.getFileExt()); 50 | return file.exists() ? file.toURI().toURL() : delegate.getResource(location); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/InMemoryWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader; 18 | 19 | import java.util.concurrent.ConcurrentHashMap; 20 | import java.util.concurrent.ConcurrentMap; 21 | 22 | import org.neuro4j.workflow.common.FlowExecutionException; 23 | import org.neuro4j.workflow.common.Workflow; 24 | 25 | /** 26 | * Loads workflow from memory. 27 | * 28 | */ 29 | public class InMemoryWorkflowLoader implements WorkflowLoader{ 30 | 31 | private final ConcurrentMap cache = new ConcurrentHashMap<>(); 32 | private final WorkflowLoader delegate; 33 | 34 | public InMemoryWorkflowLoader(final WorkflowLoader loader){ 35 | this.delegate = loader; 36 | } 37 | 38 | @Override 39 | public Workflow load(String name) throws FlowExecutionException { 40 | Workflow workflow = cache.get(name); 41 | if (workflow == null){ 42 | workflow = delegate.load(name); 43 | } 44 | return workflow; 45 | } 46 | 47 | public void register(Workflow workflow){ 48 | cache.put(workflow.getFlowName(), workflow); 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/WorkflowLoader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader; 18 | 19 | import org.neuro4j.workflow.common.FlowExecutionException; 20 | import org.neuro4j.workflow.common.Workflow; 21 | 22 | /** 23 | * Base interface to load workflow. 24 | */ 25 | public interface WorkflowLoader { 26 | 27 | /** 28 | * Loads workflow by name 29 | * @param name of workflow 30 | * @return Workflow 31 | * @throws FlowExecutionException in case of workflow can not be loaded 32 | */ 33 | public Workflow load(final String name) throws FlowExecutionException; 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/f4j/FlowXML.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader.f4j; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import javax.xml.bind.annotation.XmlAttribute; 23 | import javax.xml.bind.annotation.XmlElement; 24 | import javax.xml.bind.annotation.XmlElementWrapper; 25 | import javax.xml.bind.annotation.XmlRootElement; 26 | 27 | @XmlRootElement(name = "flow") 28 | public class FlowXML { 29 | 30 | @XmlAttribute 31 | public String visibility; 32 | 33 | @XmlElementWrapper(name = "nodes") 34 | @XmlElement(name = "node") 35 | public List nodes = new ArrayList(); 36 | 37 | public FlowXML() 38 | { 39 | 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/f4j/NodeType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader.f4j; 18 | 19 | public enum NodeType { 20 | START,END,CALL,SWITCH,MAP,DECISION,LOOP,CUSTOM,JOIN,VIEW,NOTE 21 | } 22 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/f4j/ParameterXML.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader.f4j; 18 | 19 | import javax.xml.bind.annotation.XmlAttribute; 20 | import javax.xml.bind.annotation.XmlRootElement; 21 | 22 | @XmlRootElement(name = "parameter") 23 | public class ParameterXML { 24 | 25 | @XmlAttribute 26 | public String key; 27 | 28 | @XmlAttribute 29 | public String value; 30 | 31 | @XmlAttribute(name="input", required=false) 32 | public Boolean input; 33 | 34 | public ParameterXML() { 35 | super(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/loader/f4j/TransitionXML.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.loader.f4j; 18 | 19 | import javax.xml.bind.annotation.XmlAttribute; 20 | import javax.xml.bind.annotation.XmlRootElement; 21 | 22 | import org.neuro4j.workflow.node.Transition; 23 | import org.neuro4j.workflow.node.WorkflowNode; 24 | 25 | @XmlRootElement(name = "transition") 26 | public class TransitionXML { 27 | 28 | @XmlAttribute 29 | public String uuid; 30 | 31 | @XmlAttribute 32 | public String name; 33 | 34 | @XmlAttribute 35 | public String toNode; 36 | 37 | public String fromNode; 38 | 39 | public TransitionXML() { 40 | super(); 41 | } 42 | 43 | 44 | public Transition createTransition(WorkflowNode node) { 45 | Transition transition = new Transition(); 46 | transition.setFromNode(node); 47 | transition.setName(this.name); 48 | return transition; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/node/CustomBlock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.node; 18 | 19 | import org.neuro4j.workflow.ActionBlock; 20 | import org.neuro4j.workflow.FlowContext; 21 | import org.neuro4j.workflow.common.FlowExecutionException; 22 | 23 | /** 24 | * 25 | * CustomBlock provides base implementation for user's blocks. 26 | * Users should extend this class during developing own blocks. 27 | * 28 | */ 29 | public abstract class CustomBlock implements ActionBlock { 30 | 31 | /** 32 | * Default constructor. 33 | */ 34 | public CustomBlock() { 35 | super(); 36 | } 37 | 38 | @Override 39 | public abstract int execute(FlowContext context) throws FlowExecutionException; 40 | 41 | @Override 42 | public void init() throws FlowExecutionException { 43 | 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/node/EndNode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.node; 18 | 19 | /** 20 | * EndBlock stops flow execution and passes execution to called workflow 21 | * 22 | */ 23 | public final class EndNode extends WorkflowNode { 24 | 25 | public EndNode(String name, String uuid) { 26 | super(name, uuid); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/node/StartNode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.node; 18 | 19 | import org.neuro4j.workflow.WorkflowRequest; 20 | import org.neuro4j.workflow.common.FlowExecutionException; 21 | import org.neuro4j.workflow.enums.StartNodeTypes; 22 | 23 | public class StartNode extends WorkflowNode { 24 | 25 | StartNodeTypes type; 26 | 27 | Transition nextNode = null; 28 | 29 | private static final String NEXT = "NEXT"; 30 | 31 | public StartNode(String name, String uuid) 32 | { 33 | super(name, uuid); 34 | } 35 | 36 | public void setType(StartNodeTypes type) { 37 | this.type = type; 38 | } 39 | 40 | public boolean isPublic() 41 | { 42 | return StartNodeTypes.PUBLIC.equals(this.type); 43 | } 44 | 45 | 46 | @Override 47 | public Transition execute(final WorkflowProcessor processor, WorkflowRequest request) throws FlowExecutionException { 48 | request.setNextRelation(nextNode); 49 | return nextNode; 50 | } 51 | 52 | @Override 53 | public void init() throws FlowExecutionException { 54 | super.init(); 55 | nextNode = getExitByName(NEXT); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/node/Transition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.node; 18 | 19 | public class Transition { 20 | 21 | private String name; 22 | private WorkflowNode fromNode; 23 | private WorkflowNode toNode; 24 | 25 | public Transition() { 26 | } 27 | 28 | public void setFromNode(WorkflowNode fromNode) { 29 | this.fromNode = fromNode; 30 | } 31 | 32 | public WorkflowNode getToNode() { 33 | return toNode; 34 | } 35 | 36 | public void setToNode(WorkflowNode toNode) { 37 | this.toNode = toNode; 38 | } 39 | 40 | public boolean isValid() { 41 | if (fromNode == null || toNode == null) { 42 | return false; 43 | } 44 | 45 | return true; 46 | } 47 | 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Transition [name=" + name + ", fromNode=" + fromNode + ", toNode=" + toNode + "]"; 60 | } 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/main/java/org/neuro4j/workflow/utils/Validation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.workflow.utils; 18 | 19 | import java.util.function.Supplier; 20 | 21 | /** 22 | * Provides helper methods for validation 23 | * 24 | */ 25 | public final class Validation { 26 | 27 | public static void requireNonNull(Object value, Supplier exceptionSupplier) throws X { 28 | if (value == null) { 29 | throw exceptionSupplier.get(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/custom/OutParametersTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.flows.custom; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | import org.junit.After; 23 | import org.junit.Assert; 24 | import org.junit.Test; 25 | import org.neuro4j.tests.base.BaseFlowTestCase; 26 | import org.neuro4j.workflow.ExecutionResult; 27 | 28 | public class OutParametersTestCase extends BaseFlowTestCase { 29 | 30 | 31 | 32 | @After 33 | public void tearDown() throws Exception { 34 | } 35 | 36 | @Test 37 | public void testMappingOutParameter() { 38 | 39 | Map params = new HashMap(); 40 | String int1 = "123"; 41 | params.put("in1", int1); 42 | 43 | ExecutionResult result = executeFlowAndReturnResult("org.neuro4j.flows.custom.FlowWithParameters-StartNode6", params); 44 | String out2 = (String)result.getFlowContext().get("out2"); 45 | Assert.assertEquals(int1, out2); 46 | 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/custom/TestBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | package org.neuro4j.flows.custom; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class TestBean { 10 | 11 | private boolean booleanVar = false; 12 | String stringVar = "Hello"; 13 | Integer integerVar = new Integer(123); 14 | List list = new ArrayList(); 15 | 16 | TestBean bean; 17 | 18 | public boolean isBooleanVar() { 19 | return booleanVar; 20 | } 21 | 22 | public void setBooleanVar(boolean booleanVar) { 23 | this.booleanVar = booleanVar; 24 | } 25 | 26 | public String getStringVar() { 27 | return stringVar; 28 | } 29 | 30 | public void setStringVar(String stringVar) { 31 | this.stringVar = stringVar; 32 | } 33 | 34 | public Integer getIntegerVar() { 35 | return integerVar; 36 | } 37 | 38 | public void setIntegerVar(Integer integerVar) { 39 | this.integerVar = integerVar; 40 | } 41 | 42 | public List getList() { 43 | return list; 44 | } 45 | 46 | public void setList(List list) { 47 | this.list = list; 48 | } 49 | 50 | public TestBean getBean() { 51 | return bean; 52 | } 53 | 54 | public void setBean(TestBean bean1) { 55 | this.bean = bean1; 56 | } 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/custom/blocks/BlockWithMandatoryInputParameter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.flows.custom.blocks; 18 | 19 | import org.neuro4j.workflow.FlowContext; 20 | import org.neuro4j.workflow.common.FlowExecutionException; 21 | import org.neuro4j.workflow.common.ParameterDefinition; 22 | import org.neuro4j.workflow.common.ParameterDefinitionList; 23 | import org.neuro4j.workflow.node.CustomBlock; 24 | 25 | @ParameterDefinitionList(input = { @ParameterDefinition(name = "mandatoryParameter", isOptional = false, type = "java.lang.String") }, output = { }) 26 | public class BlockWithMandatoryInputParameter extends CustomBlock { 27 | 28 | public int execute(FlowContext ctx) 29 | throws FlowExecutionException { 30 | System.out.println(getClass().getCanonicalName()); 31 | return NEXT; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/custom/blocks/BlockWithStaticInputName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.flows.custom.blocks; 18 | 19 | import static org.neuro4j.flows.custom.blocks.BlockWithStaticInputName.IN_NAME1; 20 | 21 | import org.neuro4j.workflow.FlowContext; 22 | import org.neuro4j.workflow.common.FlowExecutionException; 23 | import org.neuro4j.workflow.common.ParameterDefinition; 24 | import org.neuro4j.workflow.common.ParameterDefinitionList; 25 | import org.neuro4j.workflow.node.CustomBlock; 26 | 27 | @ParameterDefinitionList(input = { @ParameterDefinition(name = IN_NAME1, isOptional = true, type = "java.lang.String") }, output = { }) 28 | public class BlockWithStaticInputName extends CustomBlock { 29 | 30 | static final String IN_NAME1 = "name1"; 31 | 32 | public int execute(FlowContext ctx) throws FlowExecutionException { 33 | 34 | Object name1 = ctx.get(IN_NAME1); 35 | 36 | // TODO: put your code here 37 | 38 | if (/* error != */false) 39 | { 40 | return ERROR; 41 | } 42 | 43 | return NEXT; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/custom/blocks/CustomWithInOutParam.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.flows.custom.blocks; 2 | 3 | 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinition; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | import org.neuro4j.workflow.node.CustomBlock; 9 | import static org.neuro4j.flows.custom.blocks.CustomWithInOutParam.*; 10 | 11 | @ParameterDefinitionList(input={ 12 | @ParameterDefinition(name=IN_IN1, isOptional=true, type= "java.lang.String")}, 13 | output={ 14 | @ParameterDefinition(name=OUT_OUT1, isOptional=true, type= "java.lang.String")}) 15 | public class CustomWithInOutParam extends CustomBlock { 16 | 17 | static final String IN_IN1 = "in1"; 18 | 19 | static final String OUT_OUT1 = "out1"; 20 | 21 | 22 | @Override 23 | public int execute(FlowContext ctx) throws FlowExecutionException { 24 | 25 | Object in1 = ctx.get(IN_IN1); 26 | 27 | 28 | ctx.put(OUT_OUT1, in1); 29 | 30 | 31 | return NEXT; 32 | } 33 | 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/example/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.flows.example; 2 | 3 | import static org.neuro4j.flows.example.HelloWorld.IN_NAME; 4 | import static org.neuro4j.flows.example.HelloWorld.OUT_MESSAGE; 5 | 6 | import org.neuro4j.workflow.ActionBlock; 7 | import org.neuro4j.workflow.FlowContext; 8 | import org.neuro4j.workflow.common.FlowExecutionException; 9 | import org.neuro4j.workflow.common.ParameterDefinition; 10 | import org.neuro4j.workflow.common.ParameterDefinitionList; 11 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 12 | import org.neuro4j.workflow.enums.CachedNode; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | /** 17 | * HelloWorld block receives name as input parameter and returns message as output parameters. 18 | * 19 | */ 20 | @ParameterDefinitionList(input = { @ParameterDefinition(name = IN_NAME, isOptional = true, type = "java.lang.String") }, 21 | output = { @ParameterDefinition(name = OUT_MESSAGE, isOptional = true, type = "java.lang.String") }) 22 | 23 | // will create just one instance of HelloWorld's class in workflow 24 | @CachedNode(type=SINGLETON) 25 | public class HelloWorld implements ActionBlock { 26 | 27 | private static final Logger logger = LoggerFactory.getLogger(HelloWorld.class); 28 | 29 | static final String IN_NAME = "name"; 30 | 31 | static final String OUT_MESSAGE = "message"; 32 | 33 | public int execute(FlowContext ctx) throws FlowExecutionException { 34 | 35 | String name = (String) ctx.get(IN_NAME); 36 | 37 | String message = "Hello World! "; 38 | 39 | if (name != null) { 40 | message += name; 41 | } 42 | 43 | logger.debug("Message: {}", message); 44 | 45 | ctx.put(OUT_MESSAGE, message); 46 | 47 | return NEXT; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/flows/tests/AllTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.flows.tests; 18 | 19 | import org.junit.runner.RunWith; 20 | import org.junit.runners.Suite; 21 | import org.junit.runners.Suite.SuiteClasses; 22 | import org.neuro4j.flows.common.WorkflowEngineTestCase; 23 | import org.neuro4j.flows.custom.FlowContextTestCase; 24 | import org.neuro4j.flows.custom.InputParametersTestCase; 25 | import org.neuro4j.flows.custom.OutParametersTestCase; 26 | import org.neuro4j.flows.network.NetworkTestCase; 27 | import org.neuro4j.flows.nodes.callnode.CallNodeTestCase; 28 | import org.neuro4j.flows.nodes.decisionnode.DecisionNodeTestCase; 29 | import org.neuro4j.flows.nodes.loopnode.LoopNodeTestCase; 30 | import org.neuro4j.flows.nodes.mappernode.MapperNodeTestCase; 31 | import org.neuro4j.flows.nodes.switchnode.SwitchNodeTestCase; 32 | import org.neuro4j.flows.nodes.viewnode.SetViewTemplateNodeTestCase; 33 | 34 | @RunWith(Suite.class) 35 | @SuiteClasses({WorkflowEngineTestCase.class, DecisionNodeTestCase.class, SwitchNodeTestCase.class, 36 | LoopNodeTestCase.class, MapperNodeTestCase.class, CallNodeTestCase.class, SetViewTemplateNodeTestCase.class, InputParametersTestCase.class,OutParametersTestCase.class, NetworkTestCase.class, FlowContextTestCase.class }) 37 | public class AllTests { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/async/CustomBlockSleep.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinition; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | import org.neuro4j.workflow.enums.CachedNode; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.neuro4j.workflow.ActionBlock; 12 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 13 | import static org.neuro4j.workflow.async.CustomBlockSleep.*; 14 | 15 | @ParameterDefinitionList(input={ 16 | @ParameterDefinition(name=IN_TIMETOSLEE, isOptional=true, type= "java.lang.Integer")}, 17 | output={ 18 | }) 19 | @CachedNode(type=NONE) 20 | public class CustomBlockSleep implements ActionBlock { 21 | 22 | private static final Logger logger = LoggerFactory.getLogger(CustomBlockSleep.class); 23 | 24 | static final String IN_TIMETOSLEE = "timeToSlee"; 25 | 26 | 27 | 28 | 29 | public int execute(FlowContext ctx) throws FlowExecutionException { 30 | 31 | Integer timeToSlee = (Integer)ctx.get(IN_TIMETOSLEE); 32 | 33 | try { 34 | Thread.sleep(timeToSlee); 35 | } catch (InterruptedException e) { 36 | logger.error(e.getMessage(), e); 37 | } 38 | 39 | return NEXT; 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/async/SleepRandom.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.async; 2 | 3 | 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinition; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | import org.neuro4j.workflow.enums.CachedNode; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.neuro4j.workflow.ActionBlock; 12 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 13 | 14 | import java.util.concurrent.ThreadLocalRandom; 15 | 16 | import static org.neuro4j.workflow.async.SleepRandom.*; 17 | 18 | @ParameterDefinitionList(input={ 19 | }, 20 | output={ 21 | }) 22 | @CachedNode(type=NONE) 23 | public class SleepRandom implements ActionBlock { 24 | 25 | private static final Logger logger = LoggerFactory.getLogger(SleepRandom.class); 26 | 27 | 28 | 29 | 30 | 31 | public int execute(FlowContext ctx) throws FlowExecutionException { 32 | 33 | try { 34 | Thread.sleep(ThreadLocalRandom.current().nextInt(100, 2000)); 35 | } catch (InterruptedException e) { 36 | logger.error(e.getMessage(), e); 37 | } 38 | 39 | return NEXT; 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockEmptyCache.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | 4 | import static org.neuro4j.workflow.core.CustomBlockEmptyCache.IN_PARAM; 5 | 6 | import java.util.concurrent.atomic.AtomicInteger; 7 | 8 | import org.neuro4j.workflow.ActionBlock; 9 | import org.neuro4j.workflow.FlowContext; 10 | import org.neuro4j.workflow.common.FlowExecutionException; 11 | import org.neuro4j.workflow.common.ParameterDefinition; 12 | import org.neuro4j.workflow.common.ParameterDefinitionList; 13 | 14 | 15 | @ParameterDefinitionList(input={ 16 | @ParameterDefinition(name=IN_PARAM, isOptional=true, type= "java.lang.String")}, 17 | output={ 18 | }) 19 | public class CustomBlockEmptyCache implements ActionBlock { 20 | 21 | static final String IN_PARAM = "param"; 22 | 23 | 24 | private final AtomicInteger executeCounter = new AtomicInteger(); 25 | 26 | private final AtomicInteger initCounter = new AtomicInteger(); 27 | 28 | 29 | public int execute(FlowContext ctx) throws FlowExecutionException { 30 | 31 | executeCounter.getAndIncrement(); 32 | 33 | Object param = ctx.get(IN_PARAM); 34 | 35 | 36 | //TODO: put your code here 37 | 38 | if (/*error != */false) 39 | { 40 | return ERROR; 41 | } 42 | 43 | 44 | 45 | return NEXT; 46 | } 47 | 48 | @Override 49 | public void init() throws FlowExecutionException { 50 | initCounter.getAndIncrement(); 51 | } 52 | 53 | public AtomicInteger getExecuteCounter() { 54 | return executeCounter; 55 | } 56 | 57 | public AtomicInteger getInitCounter() { 58 | return initCounter; 59 | } 60 | 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockNoDefaultConstructor.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | import static org.neuro4j.workflow.core.CustomBlockNoDefaultConstructor.IN_PARAM; 4 | 5 | import java.util.concurrent.atomic.AtomicInteger; 6 | 7 | import org.neuro4j.workflow.ActionBlock; 8 | import org.neuro4j.workflow.FlowContext; 9 | import org.neuro4j.workflow.common.FlowExecutionException; 10 | import org.neuro4j.workflow.common.ParameterDefinition; 11 | import org.neuro4j.workflow.common.ParameterDefinitionList; 12 | 13 | @ParameterDefinitionList(input = { 14 | @ParameterDefinition(name = IN_PARAM, isOptional = true, type = "java.lang.String") }, output = {}) 15 | public class CustomBlockNoDefaultConstructor implements ActionBlock { 16 | 17 | public CustomBlockNoDefaultConstructor(String param){ 18 | 19 | } 20 | 21 | static final String IN_PARAM = "param"; 22 | 23 | private final AtomicInteger executeCounter = new AtomicInteger(); 24 | 25 | private final AtomicInteger initCounter = new AtomicInteger(); 26 | 27 | public int execute(FlowContext ctx) throws FlowExecutionException { 28 | 29 | executeCounter.getAndIncrement(); 30 | 31 | Object param = ctx.get(IN_PARAM); 32 | 33 | // TODO: put your code here 34 | 35 | if (/* error != */false) { 36 | return ERROR; 37 | } 38 | 39 | return NEXT; 40 | } 41 | 42 | @Override 43 | public void init() throws FlowExecutionException { 44 | initCounter.getAndIncrement(); 45 | } 46 | 47 | public AtomicInteger getExecuteCounter() { 48 | return executeCounter; 49 | } 50 | 51 | public AtomicInteger getInitCounter() { 52 | return initCounter; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockNodeCached.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinition; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | 9 | import org.neuro4j.workflow.enums.CachedNode; 10 | import static org.neuro4j.workflow.core.CustomBlockNodeCached.*; 11 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 12 | 13 | import java.util.concurrent.atomic.AtomicInteger; 14 | 15 | import org.neuro4j.workflow.ActionBlock; 16 | 17 | 18 | @ParameterDefinitionList(input={ 19 | @ParameterDefinition(name=IN_PARAM, isOptional=true, type= "java.lang.String")}, 20 | output={ 21 | }) 22 | @CachedNode(type=NODE) 23 | public class CustomBlockNodeCached implements ActionBlock { 24 | 25 | static final String IN_PARAM = "param"; 26 | 27 | private final AtomicInteger executeCounter = new AtomicInteger(0); 28 | private final AtomicInteger initCounter = new AtomicInteger(0); 29 | 30 | public int execute(FlowContext ctx) throws FlowExecutionException { 31 | 32 | Object param = ctx.get(IN_PARAM); 33 | 34 | 35 | //TODO: put your code here 36 | 37 | if (/*error != */false) 38 | { 39 | return ERROR; 40 | } 41 | 42 | 43 | 44 | return NEXT; 45 | } 46 | 47 | @Override 48 | public void init() throws FlowExecutionException { 49 | initCounter.getAndIncrement(); 50 | } 51 | 52 | public AtomicInteger getExecuteCounter() { 53 | return executeCounter; 54 | } 55 | 56 | public AtomicInteger getInitCounter() { 57 | return initCounter; 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockNoneCached.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinition; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | 9 | import org.neuro4j.workflow.enums.CachedNode; 10 | import static org.neuro4j.workflow.core.CustomBlockNoneCached.*; 11 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 12 | 13 | import org.neuro4j.workflow.ActionBlock; 14 | 15 | 16 | @ParameterDefinitionList(input={ 17 | @ParameterDefinition(name=IN_PARAM, isOptional=true, type= "java.lang.String")}, 18 | output={ 19 | }) 20 | @CachedNode(type=NONE) 21 | public class CustomBlockNoneCached implements ActionBlock { 22 | 23 | static final String IN_PARAM = "param"; 24 | 25 | 26 | 27 | 28 | public int execute(FlowContext ctx) throws FlowExecutionException { 29 | 30 | Object param = ctx.get(IN_PARAM); 31 | 32 | 33 | //TODO: put your code here 34 | 35 | if (/*error != */false) 36 | { 37 | return ERROR; 38 | } 39 | 40 | 41 | 42 | return NEXT; 43 | } 44 | 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockWithEmptyList.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | import org.neuro4j.workflow.ActionBlock; 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.ParameterDefinitionList; 7 | 8 | @ParameterDefinitionList 9 | public class CustomBlockWithEmptyList implements ActionBlock { 10 | 11 | public int execute(FlowContext ctx) throws FlowExecutionException { 12 | 13 | return NEXT; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockWithErrorExit.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | 4 | import static org.neuro4j.workflow.core.CustomBlockWithErrorExit.IN_PARAM; 5 | 6 | import java.util.concurrent.atomic.AtomicInteger; 7 | 8 | import org.neuro4j.workflow.ActionBlock; 9 | import org.neuro4j.workflow.FlowContext; 10 | import org.neuro4j.workflow.common.FlowExecutionException; 11 | import org.neuro4j.workflow.common.ParameterDefinition; 12 | import org.neuro4j.workflow.common.ParameterDefinitionList; 13 | 14 | 15 | @ParameterDefinitionList(input={ 16 | @ParameterDefinition(name=IN_PARAM, isOptional=true, type= "java.lang.String")}, 17 | output={ 18 | }) 19 | public class CustomBlockWithErrorExit implements ActionBlock { 20 | 21 | static final String IN_PARAM = "param"; 22 | 23 | 24 | private final AtomicInteger executeCounter = new AtomicInteger(); 25 | 26 | private final AtomicInteger initCounter = new AtomicInteger(); 27 | 28 | 29 | public int execute(FlowContext ctx) throws FlowExecutionException { 30 | 31 | executeCounter.getAndIncrement(); 32 | 33 | 34 | //TODO: put your code here 35 | 36 | if (/*error != */true) 37 | { 38 | return ERROR; 39 | } 40 | 41 | 42 | 43 | return NEXT; 44 | } 45 | 46 | @Override 47 | public void init() throws FlowExecutionException { 48 | initCounter.getAndIncrement(); 49 | } 50 | 51 | public AtomicInteger getExecuteCounter() { 52 | return executeCounter; 53 | } 54 | 55 | public AtomicInteger getInitCounter() { 56 | return initCounter; 57 | } 58 | 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/CustomBlockWithNoAnotations.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.core; 2 | 3 | import org.neuro4j.workflow.ActionBlock; 4 | import org.neuro4j.workflow.FlowContext; 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | 7 | public class CustomBlockWithNoAnotations implements ActionBlock { 8 | 9 | public int execute(FlowContext ctx) throws FlowExecutionException { 10 | 11 | return NEXT; 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/core/SystemOutBlock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.core; 18 | 19 | import org.neuro4j.workflow.FlowContext; 20 | import org.neuro4j.workflow.common.FlowExecutionException; 21 | import org.neuro4j.workflow.common.ParameterDefinition; 22 | import org.neuro4j.workflow.common.ParameterDefinitionList; 23 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 24 | import org.neuro4j.workflow.enums.CachedNode; 25 | import org.neuro4j.workflow.node.CustomBlock; 26 | 27 | @CachedNode(type=SINGLETON) 28 | @ParameterDefinitionList(input = { @ParameterDefinition(name = "varToPrint", isOptional = true, type = "java.lang.Object") }) 29 | public class SystemOutBlock extends CustomBlock { 30 | 31 | final static String VAR_TO_PRINT = "varToPrint"; 32 | 33 | public int execute(FlowContext ctx) throws FlowExecutionException { 34 | 35 | Object mName = (Object) ctx.get(VAR_TO_PRINT); 36 | 37 | if (mName != null) 38 | { 39 | System.out.println(mName.toString()); 40 | } 41 | 42 | return NEXT; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/java/org/neuro4j/workflow/loader/CounterWorkflowLoader.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.loader; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.neuro4j.workflow.common.FlowExecutionException; 6 | import org.neuro4j.workflow.common.Workflow; 7 | 8 | public class CounterWorkflowLoader implements WorkflowLoader{ 9 | 10 | AtomicInteger counter = new AtomicInteger(0); 11 | 12 | private final WorkflowLoader delegate; 13 | 14 | public CounterWorkflowLoader(WorkflowLoader delegate){ 15 | this.delegate = delegate; 16 | } 17 | 18 | @Override 19 | public Workflow load(String name) throws FlowExecutionException { 20 | counter.incrementAndGet(); 21 | return delegate.load(name); 22 | } 23 | 24 | public AtomicInteger getCounter(){ 25 | return counter; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/resources/file1.n4j: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/neuro4j-workflow-core/src/test/resources/file1.n4j -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/resources/org/mydomain/FlowForFileWorkflowLoader.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -50, 36, 5, -107|-55, 108, 0, -35| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 35, -50, -142|0, 133, -50, -44| 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/resources/org/neuro4j/workflow/flows/RemoteFlow.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -50, 36, 2, -117|-52, 118, 0, -35| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 35, -51, -137|1, 128, -50, -44| 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /neuro4j-workflow-core/src/test/resources/somefolder/org/mydomain/FlowForFileWorkflowLoader.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -50, 36, 3, -76|-53, 77, 0, -35| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 35, -53, -87|3, 78, -50, -44| 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /spring-context-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /spring-context-adapter/src/test/java/org/neuro4j/workflow/spring/CustomBlockNoComponent.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2013-2016, Neuro4j 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.neuro4j.workflow.spring; 19 | 20 | import org.neuro4j.workflow.ActionBlock; 21 | import org.neuro4j.workflow.FlowContext; 22 | import org.neuro4j.workflow.common.FlowExecutionException; 23 | 24 | public class CustomBlockNoComponent implements ActionBlock { 25 | 26 | public int execute(FlowContext ctx) throws FlowExecutionException { 27 | ctx.put("somekey", "somevalue"); 28 | return NEXT; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /spring-context-adapter/src/test/java/org/neuro4j/workflow/spring/CustomBlockWithService.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2013-2016, Neuro4j 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.neuro4j.workflow.spring; 19 | 20 | 21 | import static org.neuro4j.workflow.spring.CustomBlockWithService.OUT_OUT1; 22 | 23 | import org.neuro4j.workflow.ActionBlock; 24 | import org.neuro4j.workflow.FlowContext; 25 | import org.neuro4j.workflow.common.FlowExecutionException; 26 | import org.neuro4j.workflow.common.ParameterDefinition; 27 | import org.neuro4j.workflow.common.ParameterDefinitionList; 28 | import org.neuro4j.workflow.spring.service.MessageService; 29 | import org.springframework.beans.factory.annotation.Autowired; 30 | import org.springframework.stereotype.Component; 31 | 32 | 33 | @ParameterDefinitionList(input={}, 34 | output={ 35 | @ParameterDefinition(name=OUT_OUT1, isOptional=true, type= "java.lang.String")}) 36 | @Component 37 | public class CustomBlockWithService implements ActionBlock { 38 | 39 | static final String OUT_OUT1 = "out1"; 40 | 41 | @Autowired 42 | public MessageService service; 43 | 44 | public int execute(FlowContext ctx) throws FlowExecutionException { 45 | String message = this.service.sendMessage("Hi", "Mister"); 46 | ctx.put(OUT_OUT1, message); 47 | return NEXT; 48 | } 49 | 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /spring-context-adapter/src/test/java/org/neuro4j/workflow/spring/Flow.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 0, 32, -1, -181|1, 185, 0, -28| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 29, 1, -186|-1, 181, 0, -34| 28 | 29 | 30 | 31 | 32 | This flow demonstrates how to use Google Guice for dependency injection in CustomBlock 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /spring-context-adapter/src/test/java/org/neuro4j/workflow/spring/SampleApplication.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.spring; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.context.annotation.ComponentScan; 5 | 6 | @SpringBootApplication 7 | @ComponentScan({"org.neuro4j"}) 8 | public class SampleApplication { 9 | 10 | 11 | } -------------------------------------------------------------------------------- /spring-context-adapter/src/test/java/org/neuro4j/workflow/spring/service/MessageService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.spring.service; 2 | /* 3 | * Copyright (c) 2013-2016, Neuro4j 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | 20 | public interface MessageService { 21 | String sendMessage(String msg, String receipient); 22 | } -------------------------------------------------------------------------------- /spring-context-adapter/src/test/java/org/neuro4j/workflow/spring/service/MyMessageService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.spring.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | /* 6 | * Copyright (c) 2013-2016, Neuro4j 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /** 22 | * Test service. 23 | * 24 | */ 25 | 26 | @Component 27 | public class MyMessageService implements MessageService { 28 | 29 | public String sendMessage(String msg, String receipient) { 30 | String message = "Message to " + receipient + " = " + msg; 31 | System.out.println(message); 32 | return message; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /spring-jms-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /spring-jms-adapter/README.md: -------------------------------------------------------------------------------- 1 | spring-jms-adapter - allows to integrate SpringJMS with Neuro4j Workflow. 2 | ------- 3 | This plugin provides base functionality to send/receive messages using SpringJMS 4 | 5 | ![springjms-workflow-example-higlevel](https://raw.githubusercontent.com/neuro4j/workflow/master/doc/images/tutorials/SpringJmsExample/result.png "How to send and receive messages using SpringJMS + workflow") 6 | 7 | More information about how to use this plugin avaliable at http://neuro4j.org/articles/tutorial-spring-jms-workflow 8 | 9 | -------------------------------------------------------------------------------- /spring-jms-adapter/src/main/java/org/neuro4j/springframework/jms/CloseApplicationContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2013-2016, Neuro4j 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 | */ 17 | package org.neuro4j.springframework.jms; 18 | 19 | import static org.neuro4j.springframework.jms.CloseApplicationContext.IN_APPCONTEXT; 20 | 21 | import org.neuro4j.workflow.ActionBlock; 22 | import org.neuro4j.workflow.FlowContext; 23 | import org.neuro4j.workflow.common.FlowExecutionException; 24 | import org.neuro4j.workflow.common.ParameterDefinition; 25 | import org.neuro4j.workflow.common.ParameterDefinitionList; 26 | import org.springframework.context.ConfigurableApplicationContext; 27 | 28 | /** 29 | * Close application Context. 30 | * 31 | */ 32 | @ParameterDefinitionList(input = { @ParameterDefinition(name = IN_APPCONTEXT, isOptional = true, type = "org.springframework.context.ConfigurableApplicationContext") }, output = {}) 33 | public class CloseApplicationContext implements ActionBlock { 34 | 35 | static final String IN_APPCONTEXT = "appContext"; 36 | 37 | public int execute(FlowContext ctx) throws FlowExecutionException { 38 | 39 | ConfigurableApplicationContext appContext = (ConfigurableApplicationContext) ctx 40 | .get(IN_APPCONTEXT); 41 | 42 | if (appContext != null) { 43 | appContext.close(); 44 | } 45 | 46 | 47 | return NEXT; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /spring-jms-adapter/src/main/resources/org/neuro4j/springframework/jms/JMSMessageListener.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/spring-jms-adapter/src/main/resources/org/neuro4j/springframework/jms/JMSMessageListener.png -------------------------------------------------------------------------------- /spring-jms-adapter/src/main/resources/org/neuro4j/springframework/jms/JMSQueueSender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/spring-jms-adapter/src/main/resources/org/neuro4j/springframework/jms/JMSQueueSender.png -------------------------------------------------------------------------------- /spring-mail-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /spring-mail-adapter/src/main/resources/org/neuro4j/springintegration/mail/HandleInputMessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/spring-mail-adapter/src/main/resources/org/neuro4j/springintegration/mail/HandleInputMessage.png -------------------------------------------------------------------------------- /tools/eclipse/README.md: -------------------------------------------------------------------------------- 1 | Neuro4j Studio Installer 2 | ================= 3 | 4 | Simple installation script for Neuro4j Studio (Linux only). 5 | 6 | 7 | Based on https://github.com/bepcyc/eclipse_installer - Thank you! 8 | 9 | Just download the .zip distribution of Studio from http://static.neuro4j.org/download/studio/. 10 | 11 | 12 | INSTALL 13 | ======= 14 | 15 | Save file n4jstudio_installer.sh 16 | 17 | RUN 18 | === 19 | 20 | Chmod if you need it: 21 | 22 | ```bash 23 | chmod +x n4jstudio_installer.sh 24 | ``` 25 | 26 | Put downloaded .zip file into the same directory as script. 27 | Run the script: 28 | 29 | ```bash 30 | ./n4jstudio_installer.sh 31 | ``` 32 | 33 | or 34 | 35 | ```bash 36 | ./n4jstudio_installer.sh --quiet 37 | ``` 38 | 39 | If you don't want it to be verbose. 40 | 41 | Run the Studio: 42 | 43 | ```bash 44 | /usr/bin/n4jstudio -clean & 45 | ``` 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tutorials/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /.DS_Store 7 | -------------------------------------------------------------------------------- /tutorials/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | workflow-tutorials 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /bin/ 7 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.core.resources.prefs 2 | /org.eclipse.m2e.core.prefs 3 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | org.neuro4j.workflow.tutorial 5 | GuiceWorkflowExample 6 | jar 7 | 1.0-SNAPSHOT 8 | GuiceWorkflowExample 9 | http://maven.apache.org 10 | 11 | 12 | UTF-8 13 | 3.4.1 14 | 1.8 15 | 16 | 17 | 18 | 19 | com.google.inject 20 | guice 21 | 3.0 22 | 23 | 24 | org.neuro4j 25 | guice-workflow-adapter 26 | ${org.neuro4j.version} 27 | 28 | 29 | 30 | 31 | 32 | src/main/java 33 | 34 | **/*.n4j 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-compiler-plugin 43 | 3.1 44 | 45 | ${java.version} 46 | ${java.version} 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/src/main/java/org/neuro4j/workflow/guice/App.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.neuro4j.workflow.guice; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import org.neuro4j.workflow.ExecutionResult; 12 | import org.neuro4j.workflow.common.WorkflowEngine; 13 | import org.neuro4j.workflow.common.WorkflowEngine.ConfigBuilder; 14 | import org.neuro4j.workflow.guice.service.MessageService; 15 | import org.neuro4j.workflow.guice.service.MyMessageService; 16 | 17 | import com.google.inject.AbstractModule; 18 | import com.google.inject.Module; 19 | 20 | /** 21 | * 22 | * 23 | */ 24 | public class App { 25 | 26 | public static void main(String[] args) { 27 | 28 | AbstractModule module = new AbstractModule() { 29 | 30 | @Override 31 | protected void configure() { 32 | bind(MessageService.class).to(MyMessageService.class); 33 | } 34 | 35 | }; 36 | 37 | List modules = new ArrayList(); 38 | modules.add(module); 39 | 40 | WorkflowEngine engine = new WorkflowEngine(new ConfigBuilder().withCustomBlockInitStrategy(new GuiceCustomBlockInitStrategy(modules))); 41 | 42 | Map parameters = new HashMap(); 43 | parameters.put("name", "Mister"); 44 | 45 | ExecutionResult result = engine.execute("org.neuro4j.workflow.guice.flows.Flow-Start", parameters); 46 | 47 | if (result.getException() == null) { 48 | String message = (String) result.getFlowContext().get("message"); 49 | System.out.println("Message: " + message); 50 | 51 | } else { 52 | result.print(); 53 | } 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/src/main/java/org/neuro4j/workflow/guice/flows/CustomBlockWithService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.guice.flows; 2 | 3 | import static org.neuro4j.workflow.guice.flows.CustomBlockWithService.IN_NAME; 4 | import static org.neuro4j.workflow.guice.flows.CustomBlockWithService.OUT_MESSAGE; 5 | 6 | import org.neuro4j.workflow.ActionBlock; 7 | import org.neuro4j.workflow.FlowContext; 8 | import org.neuro4j.workflow.common.FlowExecutionException; 9 | import org.neuro4j.workflow.common.ParameterDefinition; 10 | import org.neuro4j.workflow.common.ParameterDefinitionList; 11 | import org.neuro4j.workflow.guice.service.MessageService; 12 | 13 | import com.google.inject.Inject; 14 | 15 | /** 16 | * This custom block uses Google Guice library for dependency injection. 17 | * 18 | */ 19 | 20 | @ParameterDefinitionList( 21 | input = { @ParameterDefinition(name = IN_NAME, isOptional = true, type = "java.lang.String") }, 22 | output = { @ParameterDefinition(name = OUT_MESSAGE, isOptional = true, type = "java.lang.String") }) 23 | public class CustomBlockWithService implements ActionBlock { 24 | 25 | static final String IN_NAME = "name"; 26 | 27 | static final String OUT_MESSAGE = "message"; 28 | 29 | private MessageService service; 30 | 31 | public int execute(FlowContext ctx) throws FlowExecutionException { 32 | 33 | String name = (String) ctx.get(IN_NAME); 34 | 35 | String message = null; 36 | 37 | if (name != null) { 38 | message = this.service.sendMessage("Hi", name); 39 | } 40 | 41 | ctx.put(OUT_MESSAGE, message); 42 | return NEXT; 43 | } 44 | 45 | @Inject 46 | public void setService(MessageService svc) { 47 | this.service = svc; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/src/main/java/org/neuro4j/workflow/guice/flows/Flow.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 0, 32, -1, -181|1, 185, 0, -28| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0, 29, 1, -186|-1, 181, 0, -34| 28 | 29 | 30 | 31 | 32 | This flow demonstrates how to use Google Guice for dependency injection in CustomBlock 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/src/main/java/org/neuro4j/workflow/guice/service/MessageService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | package org.neuro4j.workflow.guice.service; 18 | 19 | /** 20 | * 21 | */ 22 | public interface MessageService { 23 | 24 | String sendMessage(String msg, String receipient); 25 | 26 | } -------------------------------------------------------------------------------- /tutorials/GuiceWorkflowExample/src/main/java/org/neuro4j/workflow/guice/service/MyMessageService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016, Neuro4j 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 | 17 | 18 | package org.neuro4j.workflow.guice.service; 19 | 20 | /** 21 | * Test service. 22 | * 23 | */ 24 | public class MyMessageService implements MessageService { 25 | 26 | public String sendMessage(String msg, String receipient) { 27 | String message = "Message to " + receipient + " = " + msg; 28 | System.out.println(message); 29 | return message; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/java/org/neuro4j/example/AppConfig.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import org.neuro4j.springframework.context.SpringContextInitStrategy; 4 | import org.neuro4j.workflow.common.WorkflowEngine; 5 | import org.neuro4j.workflow.common.WorkflowEngine.ConfigBuilder; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Scope; 10 | 11 | @Configuration 12 | public class AppConfig { 13 | 14 | @Autowired 15 | SpringContextInitStrategy initStrategy; 16 | 17 | @Bean 18 | @Scope("singleton") 19 | public WorkflowEngine getWorkflowEngine() { 20 | return new WorkflowEngine(new ConfigBuilder().withCustomBlockInitStrategy(initStrategy)); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/java/org/neuro4j/example/HystrixServletDefinitions.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; 8 | 9 | @Configuration 10 | public class HystrixServletDefinitions { 11 | 12 | @Bean(name = "hystrixRegistrationBean") 13 | public ServletRegistrationBean servletRegistrationBean() { 14 | ServletRegistrationBean registration = new ServletRegistrationBean( 15 | new HystrixMetricsStreamServlet(), "/metrics/hystrix.stream"); 16 | registration.setName("hystrixServlet"); 17 | registration.setLoadOnStartup(1); 18 | return registration; 19 | } 20 | } -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/java/org/neuro4j/example/SampleApplication.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard; 8 | 9 | 10 | @SpringBootApplication 11 | @ComponentScan({"org.neuro4j"}) 12 | @EnableHystrixDashboard 13 | public class SampleApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(SampleApplication.class, args); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/java/org/neuro4j/example/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.neuro4j.workflow.common.FlowExecutionException; 8 | import org.neuro4j.workflow.common.WorkflowEngine; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.servlet.view.RedirectView; 15 | 16 | @Controller 17 | public class WelcomeController { 18 | 19 | private static final Logger Logger = LoggerFactory.getLogger(WelcomeController.class); 20 | 21 | @Autowired 22 | private WorkflowEngine engine; 23 | 24 | @RequestMapping("/") 25 | public String welcome(Map model) { 26 | return "welcome"; 27 | } 28 | 29 | @RequestMapping("/download") 30 | public RedirectView download(Map model) { 31 | 32 | 33 | 34 | List urls = new ArrayList<>(); 35 | 36 | for (int i =0; i < 20; i++){ 37 | urls.add("https://en.m.wikipedia.org/wiki/Antarctica/Rothera#/random"); 38 | urls.add("https://en.m.wikipedia.org/wiki/Bengal_tiger"); 39 | urls.add("https://en.m.wikipedia.org/wiki/Bengal"); 40 | urls.add("https://en.wikipedia.org/wiki/List_of_Swedish_monarchs"); 41 | urls.add("https://en.wikipedia.org/wiki/Monarchy_of_Sweden"); 42 | 43 | } 44 | 45 | model.put("urls", urls); 46 | 47 | 48 | try { 49 | engine.executeAsync("org.neuro4j.workflow.DownloadPages-Start", model); 50 | } catch (FlowExecutionException e) { 51 | Logger.error(e.getMessage(), e); 52 | } 53 | 54 | return new RedirectView("/hystrix/monitor?stream=http%3A%2F%2Flocalhost%3A8080%2Fmetrics%2Fhystrix.stream"); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/java/org/neuro4j/example/services/DownloadService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example.services; 2 | 3 | import java.io.IOException; 4 | 5 | public interface DownloadService { 6 | 7 | public String download(String url) throws IOException; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/java/org/neuro4j/example/services/JsoupDownloadService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example.services; 2 | 3 | import java.io.IOException; 4 | 5 | import org.jsoup.Jsoup; 6 | import org.jsoup.nodes.Document; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class JsoupDownloadService implements DownloadService{ 11 | 12 | @Override 13 | public String download(String url) throws IOException { 14 | Document doc = Jsoup.connect(url).validateTLSCertificates(false).get(); 15 | if (doc != null) { 16 | String content = doc.html(); 17 | return content; 18 | } 19 | return ""; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/resources/application.conf: -------------------------------------------------------------------------------- 1 | neuro4j{ 2 | 3 | hystrix{ 4 | 5 | TestGroupKey{ 6 | threadpoolSize = 10 7 | queueSize = 10 8 | maxWait = 1000 9 | } 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mvc.view.prefix: / 2 | spring.mvc.view.suffix: .jsp -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorials/HystrixExample/src/main/webapp/welcome.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

SpringBoot + NetflixHystrix + Neuro4jWorkflow

6 | Click on link to download webpages Run 7 | 8 | 9 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /.DS_Store 7 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/java/org/neuro4j/example/AppConfig.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import org.neuro4j.springframework.context.SpringContextInitStrategy; 4 | import org.neuro4j.workflow.common.WorkflowEngine; 5 | import org.neuro4j.workflow.common.WorkflowEngine.ConfigBuilder; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Scope; 10 | 11 | @Configuration 12 | public class AppConfig { 13 | 14 | @Autowired 15 | SpringContextInitStrategy initStrategy; 16 | 17 | @Bean 18 | @Scope("singleton") 19 | public WorkflowEngine getWorkflowEngine() { 20 | return new WorkflowEngine(new ConfigBuilder().withCustomBlockInitStrategy(initStrategy)); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/java/org/neuro4j/example/SampleApplication.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | @SpringBootApplication 8 | @ComponentScan({"org.neuro4j"}) 9 | public class SampleApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SampleApplication.class, args); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/java/org/neuro4j/example/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example; 2 | 3 | import java.util.Map; 4 | 5 | import org.neuro4j.workflow.ExecutionResult; 6 | import org.neuro4j.workflow.WorkflowRequest; 7 | import org.neuro4j.workflow.common.WorkflowEngine; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | 12 | @Controller 13 | public class WelcomeController { 14 | 15 | @Autowired 16 | private WorkflowEngine engine; 17 | 18 | @RequestMapping("/") 19 | public String welcome(Map model) { 20 | return "welcome"; 21 | } 22 | 23 | @RequestMapping("/download") 24 | public String download(Map model) { 25 | 26 | WorkflowRequest request = new WorkflowRequest(model); 27 | 28 | request.addParameter("url1", "https://en.m.wikipedia.org/wiki/Antarctica/Rothera#/random"); 29 | request.addParameter("url2", "https://en.m.wikipedia.org/wiki/Bengal_tiger"); 30 | request.addParameter("url3", "https://en.m.wikipedia.org/wiki/Bengal"); 31 | 32 | ExecutionResult result = engine.execute("org.neuro4j.workflow.DownloadPages-Start", request); 33 | model.putAll(result.getFlowContext().getParameters()); 34 | return "download"; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/java/org/neuro4j/example/services/DownloadService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example.services; 2 | 3 | import java.io.IOException; 4 | 5 | public interface DownloadService { 6 | 7 | public String download(String url) throws IOException; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/java/org/neuro4j/example/services/JsoupDownloadService.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.example.services; 2 | 3 | import java.io.IOException; 4 | 5 | import org.jsoup.Jsoup; 6 | import org.jsoup.nodes.Document; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class JsoupDownloadService implements DownloadService{ 11 | 12 | @Override 13 | public String download(String url) throws IOException { 14 | Document doc = Jsoup.connect(url).validateTLSCertificates(false).get(); 15 | if (doc != null) { 16 | String content = doc.html(); 17 | return content; 18 | } 19 | return ""; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/resources/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.mvc.view.prefix: / 2 | spring.mvc.view.suffix: .jsp -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/resources/org/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/resources/org/neuro4j/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/resources/org/neuro4j/workflow/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/webapp/download.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

SpringBoot with Neuro4jWorkflow

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
Downloaded in Thread1Downloaded in Thread2Downloaded in Thread3
${content1}${content2}${content3}
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /tutorials/ParallelProcessingExample/src/main/webapp/welcome.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

SpringBoot with Neuro4jWorkflow

6 | Click on link to download webpages Run 7 | 8 | 9 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.jdt.core.prefs 2 | /org.eclipse.m2e.core.prefs 3 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/src/main/java/org/neuro4j/springframework/email/example/GmailImapIdleTestApp.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.springframework.email.example; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | /** 7 | * 8 | * 9 | */ 10 | public class GmailImapIdleTestApp { 11 | public static void main (String[] args) throws Exception { 12 | ApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/gmail-imap-idle-config.xml"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/src/main/java/org/neuro4j/springframework/email/example/GmailPop3TestApp.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.springframework.email.example; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | 7 | public class GmailPop3TestApp { 8 | 9 | public static void main (String[] args) throws Exception { 10 | ApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/gmail-pop3-config.xml"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/src/main/resources/META-INF/spring/integration/controllers.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | org.neuro4j.springframework.email.example.GetMailsFromGmail-HandleMessage 18 | 19 | 20 | 21 | false 22 | true 23 | 995 24 | javax.net.ssl.SSLSocketFactory 25 | 995 26 | 27 | 28 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/src/main/resources/META-INF/spring/integration/gmail-imap-idle-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/src/main/resources/META-INF/spring/integration/gmail-pop3-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tutorials/SpringEmailExample/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tutorials/SpringJmsExample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /tutorials/SpringJmsExample/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.jdt.core.prefs 2 | /org.eclipse.m2e.core.prefs 3 | -------------------------------------------------------------------------------- /tutorials/SpringJmsExample/src/main/java/org/neuro4j/springframework/jms/example/DoSomething.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.springframework.jms.example; 2 | 3 | import static org.neuro4j.springframework.jms.example.DoSomething.IN_MESSAGE; 4 | 5 | import javax.jms.Message; 6 | 7 | import org.neuro4j.workflow.FlowContext; 8 | import org.neuro4j.workflow.common.FlowExecutionException; 9 | import org.neuro4j.workflow.common.ParameterDefinition; 10 | import org.neuro4j.workflow.common.ParameterDefinitionList; 11 | import org.neuro4j.workflow.node.CustomBlock; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | 15 | @ParameterDefinitionList(input = { @ParameterDefinition(name = IN_MESSAGE, isOptional = true, type = "javax.jms.Message") }, output = {}) 16 | public class DoSomething extends CustomBlock { 17 | private static final Logger Logger = LoggerFactory.getLogger(DoSomething.class); 18 | 19 | static final String IN_MESSAGE = "message"; 20 | 21 | public int execute(FlowContext ctx) throws FlowExecutionException { 22 | 23 | Message message = (Message) ctx.get(IN_MESSAGE); 24 | 25 | Logger.info("Working with message {}", message); 26 | 27 | return NEXT; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /tutorials/SpringJmsExample/src/main/java/org/neuro4j/springframework/jms/example/RemoveJmsTmpFiles.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.springframework.jms.example; 2 | 3 | import java.io.File; 4 | 5 | import org.neuro4j.workflow.FlowContext; 6 | import org.neuro4j.workflow.common.FlowExecutionException; 7 | import org.neuro4j.workflow.common.ParameterDefinitionList; 8 | import org.neuro4j.workflow.node.CustomBlock; 9 | import org.springframework.util.FileSystemUtils; 10 | 11 | /** 12 | * Remove tmp files. 13 | * 14 | */ 15 | @ParameterDefinitionList(input = {}, output = {}) 16 | public class RemoveJmsTmpFiles extends CustomBlock { 17 | 18 | public int execute(FlowContext ctx) throws FlowExecutionException { 19 | 20 | FileSystemUtils.deleteRecursively(new File("activemq-data")); 21 | 22 | return NEXT; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /tutorials/SpringJmsExample/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/.settings/.gitignore: -------------------------------------------------------------------------------- 1 | /org.eclipse.jdt.core.prefs 2 | /org.eclipse.m2e.core.prefs 3 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/src/main/java/org/neuro4j/springframework/timer/example/App.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.springframework.timer.example; 2 | 3 | import org.springframework.context.support.AbstractApplicationContext; 4 | import org.springframework.context.support.ClassPathXmlApplicationContext; 5 | 6 | public class App { 7 | 8 | public static void main(String[] args) { 9 | AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartz-context.xml"); 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/src/main/java/org/neuro4j/springframework/timer/example/TimerFlow.n4j: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 0, 36, 1, -157|-1, 165, 0, -28| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 0, 29, -1, -177|1, 172, 0, -34| 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/src/main/resources/quartz-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tutorials/SpringTimerExample/src/main/resources/quartz-context.xml.example: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.externalToolBuilders/ 4 | .classpath 5 | .project 6 | /.DS_Store 7 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/java/org/neuro4j/workflow/tutorial/App.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.tutorial; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.neuro4j.workflow.ExecutionResult; 7 | import org.neuro4j.workflow.common.WorkflowEngine; 8 | import org.neuro4j.workflow.common.WorkflowEngine.ConfigBuilder; 9 | 10 | /** 11 | * This is client's class. 12 | */ 13 | public class App 14 | { 15 | 16 | 17 | public static void main( String[] args ) 18 | { 19 | 20 | // create engine with default configuration 21 | WorkflowEngine engine = new WorkflowEngine(new ConfigBuilder()); 22 | 23 | // put input parameters 24 | Map parameters = new HashMap(); 25 | parameters.put("name", "Workflow"); 26 | 27 | //execute flow 28 | //run flow - engine.execute("-", parameters); 29 | ExecutionResult result = engine.execute("org.neuro4j.workflow.tutorial.HelloFlow-Start", parameters); 30 | 31 | if (result.getException() == null) 32 | { 33 | String message = (String) result.getFlowContext().get("message"); 34 | System.out.println("Message: " + message); 35 | 36 | } else { 37 | result.print(); 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/java/org/neuro4j/workflow/tutorial/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.tutorial; 2 | 3 | import static org.neuro4j.workflow.tutorial.HelloWorld.IN_NAME; 4 | import static org.neuro4j.workflow.tutorial.HelloWorld.OUT_MESSAGE; 5 | 6 | import org.neuro4j.workflow.ActionBlock; 7 | import org.neuro4j.workflow.FlowContext; 8 | import org.neuro4j.workflow.common.FlowExecutionException; 9 | import org.neuro4j.workflow.common.ParameterDefinition; 10 | import org.neuro4j.workflow.common.ParameterDefinitionList; 11 | import static org.neuro4j.workflow.enums.ActionBlockCache.*; 12 | import org.neuro4j.workflow.enums.CachedNode; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | /** 17 | * HelloWorld block receives name as input parameter and returns message as output parameters. 18 | * 19 | */ 20 | @ParameterDefinitionList(input = { @ParameterDefinition(name = IN_NAME, isOptional = true, type = "java.lang.String") }, 21 | output = { @ParameterDefinition(name = OUT_MESSAGE, isOptional = true, type = "java.lang.String") }) 22 | 23 | // will create just one instance of HelloWorld's class in workflow 24 | @CachedNode(type=SINGLETON) 25 | public class HelloWorld implements ActionBlock { 26 | 27 | private static final Logger logger = LoggerFactory.getLogger(HelloWorld.class); 28 | 29 | static final String IN_NAME = "name"; 30 | 31 | static final String OUT_MESSAGE = "message"; 32 | 33 | public int execute(FlowContext ctx) throws FlowExecutionException { 34 | 35 | String name = (String) ctx.get(IN_NAME); 36 | 37 | String message = "Hello World! "; 38 | 39 | if (name != null) { 40 | message += name; 41 | } 42 | 43 | logger.debug("Message: {}", message); 44 | 45 | ctx.put(OUT_MESSAGE, message); 46 | 47 | return NEXT; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/resources/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/resources/org/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/resources/org/neuro4j/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/resources/org/neuro4j/workflow/.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/main/resources/org/neuro4j/workflow/tutorial/HelloWorld_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eternita/workflow/a9ca896848983aba4893f1af017a64de3541573e/tutorials/WorkflowExample/src/main/resources/org/neuro4j/workflow/tutorial/HelloWorld_.png -------------------------------------------------------------------------------- /tutorials/WorkflowExample/src/test/java/org/neuro4j/workflow/tutorial/HelloWorldTest.java: -------------------------------------------------------------------------------- 1 | package org.neuro4j.workflow.tutorial; 2 | 3 | import static org.junit.Assert.*; 4 | import org.junit.Test; 5 | import org.neuro4j.workflow.ActionBlock; 6 | import org.neuro4j.workflow.FlowContext; 7 | import org.neuro4j.workflow.common.FlowExecutionException; 8 | 9 | public class HelloWorldTest { 10 | 11 | @Test 12 | public void testHelloWorld(){ 13 | 14 | HelloWorld helloWorld = new HelloWorld(); 15 | 16 | FlowContext context = new FlowContext(); 17 | context.put("name", "John"); 18 | 19 | try { 20 | int result = helloWorld.execute(context); 21 | context.get("message"); 22 | assertEquals(ActionBlock.NEXT, result); 23 | 24 | assertEquals("Hello World! John", context.get("message")); 25 | 26 | } catch (FlowExecutionException e) { 27 | e.printStackTrace(); 28 | } 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /tutorials/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | org.neuro4j 7 | workflow-tutorials 8 | 3.5.1-SNAPSHOT 9 | pom 10 | Workflow Tuturials 11 | http://neuro4j.org 12 | 13 | 14 | WorkflowExample 15 | GuiceWorkflowExample 16 | SpringJmsExample 17 | SpringTimerExample 18 | SpringEmailExample 19 | ParallelProcessingExample 20 | HystrixExample 21 | 22 | 23 | 24 | 25 | UTF-8 26 | 1.8 27 | 1.8 28 | 1.8 29 | 30 | 31 | 32 | 33 | 34 | 35 | --------------------------------------------------------------------------------