剥离核心core完全解耦第三方框架
This commit is contained in:
parent
fb2a585dd1
commit
3fd59f7f09
@ -1,15 +1 @@
|
||||
description "Spring Boot 启动模块"
|
||||
|
||||
dependencies {
|
||||
// api project(":flowlong-annotation")
|
||||
|
||||
compileOnly("org.springframework.boot:spring-boot-starter-json")
|
||||
compileOnly("org.springframework:spring-context")
|
||||
compileOnly("com.baomidou:mybatis-plus-extension")
|
||||
|
||||
testCompileOnly("org.springframework.boot:spring-boot-starter-json")
|
||||
testCompileOnly("org.springframework:spring-web")
|
||||
testCompileOnly("org.springframework:spring-jdbc")
|
||||
testCompileOnly("com.baomidou:mybatis-plus-extension")
|
||||
testCompileOnly("mysql:mysql-connector-java")
|
||||
}
|
||||
description "flowLong core"
|
||||
|
@ -15,11 +15,11 @@
|
||||
package com.flowlong.bpm.engine.core;
|
||||
|
||||
import com.flowlong.bpm.engine.*;
|
||||
import com.flowlong.bpm.engine.assist.Assert;
|
||||
import com.flowlong.bpm.engine.cache.FlowCache;
|
||||
import com.flowlong.bpm.engine.cache.FlowSimpleCache;
|
||||
import com.flowlong.bpm.engine.exception.FlowLongException;
|
||||
import com.flowlong.bpm.engine.handler.FlowJsonHandler;
|
||||
import com.flowlong.bpm.engine.handler.impl.JacksonHandlerFlow;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -53,7 +53,8 @@ public class FlowLongContext {
|
||||
* 流程 JSON 处理器,默认 jackson 实现
|
||||
* 使用其它json框架可在初始化时赋值该静态属性
|
||||
*/
|
||||
public static FlowJsonHandler JSON_HANDLER = new JacksonHandlerFlow();
|
||||
@Setter
|
||||
private static FlowJsonHandler flowJsonHandler;
|
||||
|
||||
/**
|
||||
* 流程缓存处理类,默认 ConcurrentHashMap 实现
|
||||
@ -61,6 +62,18 @@ public class FlowLongContext {
|
||||
*/
|
||||
public static FlowCache FLOW_CACHE = new FlowSimpleCache();
|
||||
|
||||
public static <T> T fromJson(String jsonString, Class<T> clazz) {
|
||||
return getFlowJsonHandler().fromJson(jsonString, clazz);
|
||||
}
|
||||
public static String toJson(Object object) {
|
||||
return getFlowJsonHandler().toJson(object);
|
||||
}
|
||||
|
||||
private static FlowJsonHandler getFlowJsonHandler() {
|
||||
Assert.isNull(flowJsonHandler, "Please implement the FlowJsonHandler interface class");
|
||||
return flowJsonHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认初始化流程引擎上下文
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ public class FlwInstance extends FlowEntity {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, Object> getVariableMap() {
|
||||
Map<String, Object> map = FlowLongContext.JSON_HANDLER.fromJson(this.variable, Map.class);
|
||||
Map<String, Object> map = FlowLongContext.fromJson(this.variable, Map.class);
|
||||
if (map == null) return Collections.emptyMap();
|
||||
return map;
|
||||
}
|
||||
@ -86,6 +86,6 @@ public class FlwInstance extends FlowEntity {
|
||||
}
|
||||
|
||||
public void setVariable(Map<String, Object> args) {
|
||||
this.variable = FlowLongContext.JSON_HANDLER.toJson(args);
|
||||
this.variable = FlowLongContext.toJson(args);
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class FlwTask extends FlowEntity {
|
||||
}
|
||||
|
||||
public Map<String, Object> variableMap() {
|
||||
Map<String, Object> map = FlowLongContext.JSON_HANDLER.fromJson(this.variable, Map.class);
|
||||
Map<String, Object> map = FlowLongContext.fromJson(this.variable, Map.class);
|
||||
return null == map ? Collections.emptyMap() : map;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public class FlwTask extends FlowEntity {
|
||||
}
|
||||
|
||||
public void setVariable(Map<String, Object> args) {
|
||||
this.variable = FlowLongContext.JSON_HANDLER.toJson(args);
|
||||
this.variable = FlowLongContext.toJson(args);
|
||||
}
|
||||
|
||||
public FlwTask cloneTask(FlwHisTaskActor flwHisTaskActor) {
|
||||
|
@ -71,7 +71,7 @@ public class ProcessModel {
|
||||
}
|
||||
|
||||
private static ProcessModel parseProcessModel(String content) {
|
||||
ProcessModel processModel = FlowLongContext.JSON_HANDLER.fromJson(content, ProcessModel.class);
|
||||
ProcessModel processModel = FlowLongContext.fromJson(content, ProcessModel.class);
|
||||
Assert.isNull(processModel, "process model json parser error");
|
||||
processModel.buildParentNode(processModel.getNodeConfig());
|
||||
return processModel;
|
||||
|
@ -1,4 +1,4 @@
|
||||
description "Spring Boot 启动模块"
|
||||
description "flowLong mybatis-plus spring-boot starter"
|
||||
|
||||
dependencies {
|
||||
api project(":flowlong-core")
|
||||
@ -10,5 +10,9 @@ dependencies {
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
|
||||
testCompileOnly("org.springframework.boot:spring-boot-starter-test")
|
||||
testCompileOnly("org.springframework.boot:spring-boot-starter-json")
|
||||
testCompileOnly("org.springframework:spring-jdbc")
|
||||
testCompileOnly("com.baomidou:mybatis-plus-extension")
|
||||
testCompileOnly("mysql:mysql-connector-java")
|
||||
testCompileOnly("junit:junit")
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ import com.flowlong.bpm.engine.*;
|
||||
import com.flowlong.bpm.engine.core.FlowLongContext;
|
||||
import com.flowlong.bpm.engine.scheduling.JobLock;
|
||||
import com.flowlong.bpm.engine.scheduling.LocalLock;
|
||||
import com.flowlong.bpm.engine.scheduling.SpringBootScheduler;
|
||||
import com.flowlong.bpm.engine.scheduling.TaskReminder;
|
||||
import com.flowlong.bpm.spring.FlowJacksonHandler;
|
||||
import com.flowlong.bpm.spring.SpringBootScheduler;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@ -39,8 +40,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan("com.flowlong.bpm.engine.core.mapper")
|
||||
@ComponentScan(basePackages = {"com.flowlong.bpm.engine.core.service"})
|
||||
@MapperScan("com.flowlong.bpm.mybatisplus.mapper")
|
||||
@ComponentScan(basePackages = {"com.flowlong.bpm.mybatisplus.service"})
|
||||
@EnableConfigurationProperties(FlowLongProperties.class)
|
||||
public class FlowLongAutoConfiguration {
|
||||
|
||||
@ -48,6 +49,9 @@ public class FlowLongAutoConfiguration {
|
||||
@ConditionalOnMissingBean
|
||||
public FlowLongContext flowLongContext(ProcessService processService, QueryService queryService,
|
||||
RuntimeService runtimeService, TaskService taskService) {
|
||||
// 静态注入 Jackson 解析 JSON 处理器
|
||||
FlowLongContext.setFlowJsonHandler(new FlowJacksonHandler());
|
||||
// 注入 FlowLong 上下文
|
||||
FlowLongContext flc = new FlowLongContext();
|
||||
flc.setProcessService(processService);
|
||||
flc.setQueryService(queryService);
|
||||
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.flowlong.bpm.engine.entity.FlwHisInstance;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.flowlong.bpm.engine.assist.Assert;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.flowlong.bpm.engine.entity.FlwInstance;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.flowlong.bpm.engine.entity.FlwProcess;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.flowlong.bpm.engine.entity.FlwTaskCc;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.mapper;
|
||||
package com.flowlong.bpm.mybatisplus.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.service;
|
||||
package com.flowlong.bpm.mybatisplus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.flowlong.bpm.engine.ProcessService;
|
||||
@ -22,10 +22,10 @@ import com.flowlong.bpm.engine.assist.DateUtils;
|
||||
import com.flowlong.bpm.engine.assist.ObjectUtils;
|
||||
import com.flowlong.bpm.engine.core.FlowCreator;
|
||||
import com.flowlong.bpm.engine.core.enums.FlowState;
|
||||
import com.flowlong.bpm.engine.core.mapper.FlwProcessMapper;
|
||||
import com.flowlong.bpm.engine.entity.FlwProcess;
|
||||
import com.flowlong.bpm.engine.exception.FlowLongException;
|
||||
import com.flowlong.bpm.engine.model.ProcessModel;
|
||||
import com.flowlong.bpm.mybatisplus.mapper.FlwProcessMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -12,12 +12,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.service;
|
||||
package com.flowlong.bpm.mybatisplus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.flowlong.bpm.engine.QueryService;
|
||||
import com.flowlong.bpm.engine.core.mapper.*;
|
||||
import com.flowlong.bpm.engine.entity.*;
|
||||
import com.flowlong.bpm.mybatisplus.mapper.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.service;
|
||||
package com.flowlong.bpm.mybatisplus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.flowlong.bpm.engine.QueryService;
|
||||
@ -24,14 +24,14 @@ import com.flowlong.bpm.engine.assist.ObjectUtils;
|
||||
import com.flowlong.bpm.engine.core.FlowCreator;
|
||||
import com.flowlong.bpm.engine.core.enums.EventType;
|
||||
import com.flowlong.bpm.engine.core.enums.InstanceState;
|
||||
import com.flowlong.bpm.engine.core.mapper.FlwHisInstanceMapper;
|
||||
import com.flowlong.bpm.engine.core.mapper.FlwInstanceMapper;
|
||||
import com.flowlong.bpm.engine.entity.FlwHisInstance;
|
||||
import com.flowlong.bpm.engine.entity.FlwInstance;
|
||||
import com.flowlong.bpm.engine.entity.FlwProcess;
|
||||
import com.flowlong.bpm.engine.entity.FlwTask;
|
||||
import com.flowlong.bpm.engine.listener.InstanceListener;
|
||||
import com.flowlong.bpm.engine.model.ProcessModel;
|
||||
import com.flowlong.bpm.mybatisplus.mapper.FlwHisInstanceMapper;
|
||||
import com.flowlong.bpm.mybatisplus.mapper.FlwInstanceMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core.service;
|
||||
package com.flowlong.bpm.mybatisplus.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.flowlong.bpm.engine.TaskAccessStrategy;
|
||||
@ -26,7 +26,7 @@ import com.flowlong.bpm.engine.core.enums.EventType;
|
||||
import com.flowlong.bpm.engine.core.enums.PerformType;
|
||||
import com.flowlong.bpm.engine.core.enums.TaskState;
|
||||
import com.flowlong.bpm.engine.core.enums.TaskType;
|
||||
import com.flowlong.bpm.engine.core.mapper.*;
|
||||
import com.flowlong.bpm.mybatisplus.mapper.*;
|
||||
import com.flowlong.bpm.engine.entity.*;
|
||||
import com.flowlong.bpm.engine.exception.FlowLongException;
|
||||
import com.flowlong.bpm.engine.listener.TaskListener;
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.handler.impl;
|
||||
package com.flowlong.bpm.spring;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
@ -31,7 +31,7 @@ import com.flowlong.bpm.engine.handler.FlowJsonHandler;
|
||||
* @author hubin
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JacksonHandlerFlow implements FlowJsonHandler {
|
||||
public class FlowJacksonHandler implements FlowJsonHandler {
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
static {
|
@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.flowlong.bpm.engine.core;
|
||||
package com.flowlong.bpm.spring;
|
||||
|
||||
import com.flowlong.bpm.engine.Expression;
|
||||
import org.springframework.expression.EvaluationContext;
|
@ -1,10 +1,13 @@
|
||||
package com.flowlong.bpm.engine.scheduling;
|
||||
package com.flowlong.bpm.spring;
|
||||
|
||||
import com.flowlong.bpm.engine.TaskService;
|
||||
import com.flowlong.bpm.engine.assist.DateUtils;
|
||||
import com.flowlong.bpm.engine.assist.ObjectUtils;
|
||||
import com.flowlong.bpm.engine.core.FlowLongContext;
|
||||
import com.flowlong.bpm.engine.entity.FlwTask;
|
||||
import com.flowlong.bpm.engine.scheduling.JobLock;
|
||||
import com.flowlong.bpm.engine.scheduling.RemindParam;
|
||||
import com.flowlong.bpm.engine.scheduling.TaskReminder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
@ -1,6 +1,6 @@
|
||||
package test;
|
||||
|
||||
import com.flowlong.bpm.engine.core.SpelExpression;
|
||||
import com.flowlong.bpm.spring.SpelExpression;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -9,7 +9,6 @@ import java.util.Map;
|
||||
|
||||
public class TestSpelExpression {
|
||||
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SpelExpression expression = new SpelExpression();
|
@ -17,7 +17,6 @@ package test.mysql;
|
||||
import com.flowlong.bpm.engine.QueryService;
|
||||
import com.flowlong.bpm.engine.core.FlowCreator;
|
||||
import com.flowlong.bpm.engine.entity.FlwTask;
|
||||
import com.flowlong.bpm.engine.entity.FlwHisTaskActor;
|
||||
import com.flowlong.bpm.engine.entity.FlwTaskActor;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import com.flowlong.bpm.engine.*;
|
||||
import com.flowlong.bpm.engine.core.FlowLongContext;
|
||||
import com.flowlong.bpm.engine.impl.GeneralAccessStrategy;
|
||||
import com.flowlong.bpm.spring.FlowJacksonHandler;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
@ -35,7 +36,7 @@ import javax.sql.DataSource;
|
||||
*/
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@MapperScan("com.flowlong.bpm.engine.core.mapper")
|
||||
@MapperScan("com.flowlong.bpm.mybatisplus.mapper")
|
||||
public class MysqlConfig {
|
||||
|
||||
|
||||
@ -70,6 +71,8 @@ public class MysqlConfig {
|
||||
flc.setRuntimeService(runtimeService);
|
||||
flc.setTaskService(taskService);
|
||||
flc.setExpression(expression);
|
||||
// 静态注入 Jackson 解析 JSON 处理器
|
||||
FlowLongContext.setFlowJsonHandler(new FlowJacksonHandler());
|
||||
return flc.build();
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:component-scan base-package="com.flowlong.bpm.engine.core.service"/>
|
||||
<context:component-scan base-package="com.flowlong.bpm.mybatisplus.service"/>
|
||||
<context:component-scan base-package="test.mysql.config"/>
|
||||
<context:property-placeholder location="jdbc.properties"/>
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
|
||||
@ -15,6 +15,6 @@
|
||||
<property name="password" value="${jdbc.password}"></property>
|
||||
</bean>
|
||||
<!-- 表达式引擎配置 -->
|
||||
<bean class="com.flowlong.bpm.engine.core.SpelExpression"/>
|
||||
<bean class="com.flowlong.bpm.spring.SpelExpression"/>
|
||||
|
||||
</beans>
|
Loading…
x
Reference in New Issue
Block a user