mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
初步完成 liteflow-solon-plugin 适配
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.yomahub.liteflow.solon;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeBreakComponent;
|
||||
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
|
||||
import org.noear.solon.core.BeanWrap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author noear
|
||||
* @since 1.11
|
||||
*/
|
||||
public class NodeBreakComponentOfMethod extends NodeBreakComponent {
|
||||
final BeanWrap beanWrap;
|
||||
final Method method;
|
||||
final LiteFlowMethodEnum methodEnum;
|
||||
|
||||
public NodeBreakComponentOfMethod(BeanWrap beanWrap, Method method, LiteFlowMethodEnum methodEnum) {
|
||||
this.beanWrap = beanWrap;
|
||||
this.method = method;
|
||||
this.methodEnum = methodEnum;
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeBreakComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != Boolean.class) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeBreakComponent method returnType can only be boolean: " + methodFullName);
|
||||
}
|
||||
}
|
||||
|
||||
private Object exec() throws Exception {
|
||||
if (method.getParameterCount() == 0) {
|
||||
return method.invoke(beanWrap.get());
|
||||
} else {
|
||||
return method.invoke(beanWrap.get(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processBreak() throws Exception {
|
||||
return (boolean) exec();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,24 @@ public class NodeComponentOfMethod extends NodeComponent {
|
||||
this.beanWrap = beanWrap;
|
||||
this.method = method;
|
||||
this.methodEnum = methodEnum;
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != Void.class) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeComponent method returnType can only be void: " + methodFullName);
|
||||
}
|
||||
}
|
||||
|
||||
private void exec() throws Exception {
|
||||
if (method.getParameterCount() == 0) {
|
||||
method.invoke(beanWrap.get());
|
||||
} else {
|
||||
method.invoke(beanWrap.get(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,14 +46,7 @@ public class NodeComponentOfMethod extends NodeComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
if (method.getParameterCount() == 0) {
|
||||
method.invoke(beanWrap.get());
|
||||
} else if (method.getParameterCount() == 1) {
|
||||
method.invoke(beanWrap.get(), this);
|
||||
} else {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
exec();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,13 +55,29 @@ public class NodeComponentOfMethod extends NodeComponent {
|
||||
if(methodEnum != LiteFlowMethodEnum.BEFORE_PROCESS){
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
exec();
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void afterProcess(String nodeId, Slot slot) {
|
||||
if(methodEnum != LiteFlowMethodEnum.AFTER_PROCESS){
|
||||
if (methodEnum != LiteFlowMethodEnum.AFTER_PROCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
exec();
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +86,9 @@ public class NodeComponentOfMethod extends NodeComponent {
|
||||
if(methodEnum != LiteFlowMethodEnum.ON_ERROR){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
exec();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,5 +96,7 @@ public class NodeComponentOfMethod extends NodeComponent {
|
||||
if(methodEnum != LiteFlowMethodEnum.ON_SUCCESS){
|
||||
return;
|
||||
}
|
||||
|
||||
exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yomahub.liteflow.solon;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeForComponent;
|
||||
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
|
||||
import org.noear.solon.core.BeanWrap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author noear
|
||||
* @since 1.11
|
||||
*/
|
||||
public class NodeForComponentOfMethod extends NodeForComponent {
|
||||
final BeanWrap beanWrap;
|
||||
final Method method;
|
||||
final LiteFlowMethodEnum methodEnum;
|
||||
|
||||
public NodeForComponentOfMethod(BeanWrap beanWrap, Method method, LiteFlowMethodEnum methodEnum) {
|
||||
this.beanWrap = beanWrap;
|
||||
this.method = method;
|
||||
this.methodEnum = methodEnum;
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeForComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != Integer.class) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeForComponent method returnType can only be int: " + methodFullName);
|
||||
}
|
||||
}
|
||||
|
||||
private Object exec() throws Exception {
|
||||
if (method.getParameterCount() == 0) {
|
||||
return method.invoke(beanWrap.get());
|
||||
} else {
|
||||
return method.invoke(beanWrap.get(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int processFor() throws Exception {
|
||||
return (int)exec();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yomahub.liteflow.solon;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeIfComponent;
|
||||
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
|
||||
import org.noear.solon.core.BeanWrap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author noear
|
||||
* @since 1.11
|
||||
*/
|
||||
public class NodeIfComponentOfMethod extends NodeIfComponent {
|
||||
final BeanWrap beanWrap;
|
||||
final Method method;
|
||||
final LiteFlowMethodEnum methodEnum;
|
||||
|
||||
public NodeIfComponentOfMethod(BeanWrap beanWrap, Method method, LiteFlowMethodEnum methodEnum) {
|
||||
this.beanWrap = beanWrap;
|
||||
this.method = method;
|
||||
this.methodEnum = methodEnum;
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeIfComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != Boolean.class) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeIfComponent method returnType can only be boolean: " + methodFullName);
|
||||
}
|
||||
}
|
||||
|
||||
private Object exec() throws Exception {
|
||||
if (method.getParameterCount() == 0) {
|
||||
return method.invoke(beanWrap.get());
|
||||
} else {
|
||||
return method.invoke(beanWrap.get(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processIf() throws Exception {
|
||||
return (boolean) exec();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yomahub.liteflow.solon;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeSwitchComponent;
|
||||
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
|
||||
import org.noear.solon.core.BeanWrap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author noear
|
||||
* @since 1.11
|
||||
*/
|
||||
public class NodeSwitchComponentOfMethod extends NodeSwitchComponent {
|
||||
final BeanWrap beanWrap;
|
||||
final Method method;
|
||||
final LiteFlowMethodEnum methodEnum;
|
||||
|
||||
public NodeSwitchComponentOfMethod(BeanWrap beanWrap, Method method, LiteFlowMethodEnum methodEnum) {
|
||||
this.beanWrap = beanWrap;
|
||||
this.method = method;
|
||||
this.methodEnum = methodEnum;
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeSwitchComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != String.class) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeSwitchComponent method returnType can only be string: " + methodFullName);
|
||||
}
|
||||
}
|
||||
|
||||
private Object exec() throws Exception {
|
||||
if (method.getParameterCount() == 0) {
|
||||
return method.invoke(beanWrap.get());
|
||||
} else {
|
||||
return method.invoke(beanWrap.get(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
return (String) exec();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yomahub.liteflow.solon;
|
||||
|
||||
import com.yomahub.liteflow.core.NodeWhileComponent;
|
||||
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
|
||||
import org.noear.solon.core.BeanWrap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author noear
|
||||
* @since 1.11
|
||||
*/
|
||||
public class NodeWhileComponentOfMethod extends NodeWhileComponent {
|
||||
final BeanWrap beanWrap;
|
||||
final Method method;
|
||||
final LiteFlowMethodEnum methodEnum;
|
||||
|
||||
public NodeWhileComponentOfMethod(BeanWrap beanWrap, Method method, LiteFlowMethodEnum methodEnum) {
|
||||
this.beanWrap = beanWrap;
|
||||
this.method = method;
|
||||
this.methodEnum = methodEnum;
|
||||
|
||||
if (method.getParameterCount() > 1) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeWhileComponent method parameter cannot be more than one: " + methodFullName);
|
||||
}
|
||||
|
||||
if (method.getReturnType() != Boolean.class) {
|
||||
String methodFullName = beanWrap.clz().getName() + "::" + method.getName();
|
||||
throw new RuntimeException("NodeWhileComponent method returnType can only be boolean: " + methodFullName);
|
||||
}
|
||||
}
|
||||
|
||||
private Object exec() throws Exception {
|
||||
if (method.getParameterCount() == 0) {
|
||||
return method.invoke(beanWrap.get());
|
||||
} else {
|
||||
return method.invoke(beanWrap.get(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processWhile() throws Exception {
|
||||
return (boolean) exec();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user