diff --git a/dorive-api/pom.xml b/dorive-api/pom.xml
index 89f533b286e3bda889b9bdf3777b349e01b2a7c3..4e2324b0f253c23ce4bf8e2b4c560571607dad14 100644
--- a/dorive-api/pom.xml
+++ b/dorive-api/pom.xml
@@ -6,7 +6,7 @@
com.gitee.digital-engine
dorive
- 3.5.0.3
+ 3.5.0.4
dorive-api
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Aggregate.java b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Aggregate.java
index d4146e859b7fb860970f1d546ee8fe03dca8f7be..6e67f6f3559eaa05c6d9b23957d4cadd21efa2d2 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Aggregate.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Aggregate.java
@@ -46,7 +46,7 @@ public @interface Aggregate {
* @see Entity
*/
@AliasFor(annotation = Entity.class)
- Class> source() default Object.class;
+ Class> dataSource() default Object.class;
/**
* @see Entity
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Entity.java b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Entity.java
index bdcab97ff057a65c2f526dcdb192f6d77e2253aa..07fde6fba9c4490366ad476d9d9e8601c6ba697b 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Entity.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Entity.java
@@ -34,9 +34,9 @@ public @interface Entity {
String name() default "";
/**
- * 数据来源
+ * 数据源
*/
- Class> source() default Object.class;
+ Class> dataSource() default Object.class;
/**
* 实体工厂
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Repository.java b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Repository.java
index 8a28c5da909e8e8d0d2461aa5dfe66491f5312b4..2e747edba484d4b0e2fe8ef56eb6b4d6df4e7b26 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Repository.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/core/Repository.java
@@ -35,4 +35,10 @@ public @interface Repository {
@AliasFor(annotation = Component.class)
String value() default "";
+ Class>[] derived() default {};
+
+ Class>[] events() default {};
+
+ Class>[] queries() default {};
+
}
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/event/EnableEvent.java b/dorive-api/src/main/java/com/gitee/dorive/api/annotation/event/EnableEvent.java
deleted file mode 100644
index aa885bc6a25ffbd8018ed44591fdc942bf830ee3..0000000000000000000000000000000000000000
--- a/dorive-api/src/main/java/com/gitee/dorive/api/annotation/event/EnableEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.gitee.dorive.api.annotation.event;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Inherited
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface EnableEvent {
-}
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/FieldEntityDefinition.java b/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/FieldEntityDefinition.java
index b4f45fbd67bac93c9413a2ec68c4defa9c67b32d..6e23921e3bd4bf8dd6c526a4995b98baaddcf3d2 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/FieldEntityDefinition.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/FieldEntityDefinition.java
@@ -31,6 +31,10 @@ public class FieldEntityDefinition extends EntityDefinition {
private List bindingDefs;
private OrderDef orderDef;
+ public java.lang.reflect.Field getJavaField() {
+ return field != null ? field.getField() : null;
+ }
+
public boolean isCollection() {
return field != null && field.isCollection();
}
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/EntityDef.java b/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/EntityDef.java
index 43ba82e2060225197a9d1826fa4ca81cc5df8a12..bc3e65237ec1bd7e65648568904044717798e9ed 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/EntityDef.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/EntityDef.java
@@ -32,7 +32,7 @@ import java.util.Map;
@AllArgsConstructor
public class EntityDef {
private String name;
- private Class> source;
+ private Class> dataSource;
private Class> factory;
private Class> repository;
private int priority;
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/entity/query/def/EnableQueryDef.java b/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/RepositoryDef.java
similarity index 59%
rename from dorive-api/src/main/java/com/gitee/dorive/api/entity/query/def/EnableQueryDef.java
rename to dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/RepositoryDef.java
index 5d2c8afe2ebb081fa274dec987e8b72a68e799fd..45acb40630d96904d9f7af166b5610750a0a5ae3 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/entity/query/def/EnableQueryDef.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/entity/core/def/RepositoryDef.java
@@ -15,9 +15,9 @@
* limitations under the License.
*/
-package com.gitee.dorive.api.entity.query.def;
+package com.gitee.dorive.api.entity.core.def;
-import com.gitee.dorive.api.annotation.query.EnableQuery;
+import com.gitee.dorive.api.annotation.core.Repository;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -28,15 +28,21 @@ import java.lang.reflect.AnnotatedElement;
@Data
@NoArgsConstructor
@AllArgsConstructor
-public class EnableQueryDef {
+public class RepositoryDef {
+ private String value;
+ private Class>[] derived;
+ private Class>[] events;
private Class>[] queries;
- public static EnableQueryDef fromElement(AnnotatedElement element) {
- EnableQuery enableQuery = AnnotatedElementUtils.getMergedAnnotation(element, EnableQuery.class);
- if (enableQuery != null) {
- EnableQueryDef enableQueryDef = new EnableQueryDef();
- enableQueryDef.setQueries(enableQuery.queries());
- return enableQueryDef;
+ public static RepositoryDef fromElement(AnnotatedElement element) {
+ Repository repository = AnnotatedElementUtils.getMergedAnnotation(element, Repository.class);
+ if (repository != null) {
+ RepositoryDef repositoryDef = new RepositoryDef();
+ repositoryDef.setValue(repository.value());
+ repositoryDef.setDerived(repository.derived());
+ repositoryDef.setEvents(repository.events());
+ repositoryDef.setQueries(repository.queries());
+ return repositoryDef;
}
return null;
}
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/impl/core/EntityDefinitionResolver.java b/dorive-api/src/main/java/com/gitee/dorive/api/impl/core/EntityDefinitionResolver.java
index 911c2e32bb94a2651d8e027e16b4d4909e9840f4..d705c6ea80c02523c95639d0a28b765ada6f3b23 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/impl/core/EntityDefinitionResolver.java
+++ b/dorive-api/src/main/java/com/gitee/dorive/api/impl/core/EntityDefinitionResolver.java
@@ -156,9 +156,9 @@ public class EntityDefinitionResolver {
if (StringUtils.isNotBlank(name)) {
newEntityDef.setName(name);
}
- Class> source = entityAnnotation.source();
- if (source != Object.class) {
- newEntityDef.setSource(source);
+ Class> dataSource = entityAnnotation.dataSource();
+ if (dataSource != Object.class) {
+ newEntityDef.setDataSource(dataSource);
}
Class> factory = entityAnnotation.factory();
if (factory != Object.class) {
diff --git a/dorive-core/pom.xml b/dorive-core/pom.xml
index 1228baa4145b20edadbf5ecd9f83c840e0de8571..c79b5973c055f84bdb90d4afd5b03cccce02374f 100644
--- a/dorive-core/pom.xml
+++ b/dorive-core/pom.xml
@@ -6,7 +6,7 @@
com.gitee.digital-engine
dorive
- 3.5.0.3
+ 3.5.0.4
dorive-core
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/api/context/Options.java b/dorive-core/src/main/java/com/gitee/dorive/core/api/context/Options.java
index 87fb517bd0127501d160d83128aa281cc202057d..81e96e13528a336a2f338a3a128d3cdcef89fc0a 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/api/context/Options.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/api/context/Options.java
@@ -18,14 +18,14 @@
package com.gitee.dorive.core.api.context;
import com.gitee.dorive.core.entity.context.EnumOptions;
-import com.gitee.dorive.core.entity.enums.SelectType;
+import com.gitee.dorive.core.entity.enums.MatcherType;
import java.util.Map;
public interface Options {
- Options ROOT = new EnumOptions(SelectType.class, SelectType.ROOT);
- Options ALL = new EnumOptions(SelectType.class, SelectType.ALL);
+ Options ROOT = new EnumOptions(MatcherType.class, MatcherType.ROOT);
+ Options ALL = new EnumOptions(MatcherType.class, MatcherType.ALL);
Map, Object> getOptions();
diff --git a/dorive-api/src/main/java/com/gitee/dorive/api/constant/event/Event.java b/dorive-core/src/main/java/com/gitee/dorive/core/api/executor/EntityOpHandler.java
similarity index 76%
rename from dorive-api/src/main/java/com/gitee/dorive/api/constant/event/Event.java
rename to dorive-core/src/main/java/com/gitee/dorive/core/api/executor/EntityOpHandler.java
index 903ad9e1343ffddc303537829acc15f204af10d1..0269f3f564efc082992fd4e687277432ec889446 100644
--- a/dorive-api/src/main/java/com/gitee/dorive/api/constant/event/Event.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/api/executor/EntityOpHandler.java
@@ -15,10 +15,13 @@
* limitations under the License.
*/
-package com.gitee.dorive.api.constant.event;
+package com.gitee.dorive.core.api.executor;
+
+import com.gitee.dorive.core.api.context.Context;
+import com.gitee.dorive.core.entity.operation.EntityOp;
+
+public interface EntityOpHandler {
+
+ long handle(Context context, EntityOp entityOp);
-public interface Event {
- String INSERT = "INSERT";
- String UPDATE = "UPDATE";
- String DELETE = "DELETE";
}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractContext.java b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractContext.java
index 9f9e444df3ecb2d7000af44544aba21a112d4028..618d646e7af5da6c9f98898547f735d33ff43c6a 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractContext.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractContext.java
@@ -19,67 +19,44 @@ package com.gitee.dorive.core.entity.context;
import com.gitee.dorive.core.api.context.Context;
import com.gitee.dorive.core.api.context.Options;
+import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
-import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
@Getter
@Setter
-public abstract class AbstractContext extends LinkedHashMap implements Context {
+@NoArgsConstructor
+@AllArgsConstructor
+public abstract class AbstractContext extends AbstractOptions implements Context {
- protected Map, Object> options = new LinkedHashMap<>(4);
-
- public AbstractContext() {
- super(8);
- }
+ private Map attachments = new ConcurrentHashMap<>(8);
public AbstractContext(Options options) {
- this();
- this.options.putAll(options.getOptions());
- }
-
- public AbstractContext(Context anotherContext) {
- this();
- this.options.putAll(anotherContext.getOptions());
- putAll(anotherContext.getAttachments());
- }
-
- @Override
- public void setOption(Class type, T value) {
- options.put(type, value);
+ super(options);
}
- @Override
- @SuppressWarnings("unchecked")
- public T getOption(Class type) {
- return (T) options.get(type);
- }
-
- @Override
- public void removeOption(Class> type) {
- options.remove(type);
- }
-
- @Override
- public Map getAttachments() {
- return this;
+ public AbstractContext(Context context) {
+ super(context);
+ this.attachments.putAll(context.getAttachments());
}
@Override
public void setAttachment(String name, Object value) {
- put(name, value);
+ attachments.put(name, value);
}
@Override
public Object getAttachment(String name) {
- return get(name);
+ return attachments.get(name);
}
@Override
public void removeAttachment(String name) {
- remove(name);
+ attachments.remove(name);
}
}
diff --git a/dorive-event/src/main/java/com/gitee/dorive/event/impl/listener/adapter/RouteListenerAdapter.java b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractOptions.java
similarity index 49%
rename from dorive-event/src/main/java/com/gitee/dorive/event/impl/listener/adapter/RouteListenerAdapter.java
rename to dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractOptions.java
index cd1f7023734848557dab91a8ef8be2460ecbc708..65a85afdd716e1a09103f7994e94d1c7fec3244f 100644
--- a/dorive-event/src/main/java/com/gitee/dorive/event/impl/listener/adapter/RouteListenerAdapter.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractOptions.java
@@ -15,35 +15,43 @@
* limitations under the License.
*/
-package com.gitee.dorive.event.impl.listener.adapter;
+package com.gitee.dorive.core.entity.context;
-import cn.hutool.core.util.ArrayUtil;
-import com.gitee.dorive.api.entity.event.def.ListenerDef;
-import com.gitee.dorive.event.api.EntityEventListener;
-import com.gitee.dorive.event.entity.EntityEvent;
+import com.gitee.dorive.core.api.context.Options;
import lombok.AllArgsConstructor;
-import lombok.Data;
+import lombok.Getter;
import lombok.NoArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
+import lombok.Setter;
-@Data
-@Slf4j
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+@Getter
+@Setter
@NoArgsConstructor
@AllArgsConstructor
-public class RouteListenerAdapter implements EntityEventListener {
+public abstract class AbstractOptions implements Options {
+
+ private Map, Object> options = new ConcurrentHashMap<>(4);
- private ListenerDef listenerDef;
- private EntityEventListener entityEventListener;
+ public AbstractOptions(Options options) {
+ this.options.putAll(options.getOptions());
+ }
+
+ @Override
+ public void setOption(Class type, T value) {
+ options.put(type, value);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T getOption(Class type) {
+ return (T) options.get(type);
+ }
@Override
- public void onEntityEvent(EntityEvent entityEvent) {
- boolean matchPublisher = ArrayUtil.contains(listenerDef.getPublishers(), entityEvent.getPublisher());
- boolean matchEvent = ArrayUtil.contains(listenerDef.getEvents(), entityEvent.getName());
- boolean matchOnlyRoot = !listenerDef.isOnlyRoot() || entityEvent.isRoot();
-
- if (matchPublisher && matchEvent && matchOnlyRoot) {
- entityEventListener.onEntityEvent(entityEvent);
- }
+ public void removeOption(Class> type) {
+ options.remove(type);
}
}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractProxyContext.java b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractProxyContext.java
new file mode 100644
index 0000000000000000000000000000000000000000..35e1c81f706b3a1f0f2da4ff881514c420a6b82b
--- /dev/null
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/AbstractProxyContext.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.gitee.dorive.core.entity.context;
+
+import com.gitee.dorive.core.api.context.Context;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+@Getter
+@Setter
+@AllArgsConstructor
+public abstract class AbstractProxyContext implements Context {
+
+ protected Context context;
+
+ @Override
+ public Map, Object> getOptions() {
+ return context.getOptions();
+ }
+
+ @Override
+ public void setOption(Class type, T value) {
+ context.setOption(type, value);
+ }
+
+ @Override
+ public T getOption(Class type) {
+ return context.getOption(type);
+ }
+
+ @Override
+ public void removeOption(Class> type) {
+ context.removeOption(type);
+ }
+
+ @Override
+ public Map getAttachments() {
+ return context.getAttachments();
+ }
+
+ @Override
+ public void setAttachment(String name, Object value) {
+ context.setAttachment(name, value);
+ }
+
+ @Override
+ public Object getAttachment(String name) {
+ return context.getAttachment(name);
+ }
+
+ @Override
+ public void removeAttachment(String name) {
+ context.removeAttachment(name);
+ }
+
+}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/BoundedContext.java b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/BoundedContext.java
index 9174f4454e6a43c4cf5a68006bdd7e11e221d77c..d2466535dfcf32e4305600f8c5fb118924c289b4 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/BoundedContext.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/BoundedContext.java
@@ -28,8 +28,8 @@ public class BoundedContext extends AbstractContext {
super(options);
}
- public BoundedContext(Context anotherContext) {
- super(anotherContext);
+ public BoundedContext(Context context) {
+ super(context);
}
}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/InnerContext.java b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/InnerContext.java
index b70e6f8a96899575d669e1481836631afe8866ce..d7982a48453cb3c3e4fc0ad61c75dea7d9933e29 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/InnerContext.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/entity/context/InnerContext.java
@@ -28,8 +28,8 @@ public class InnerContext extends AbstractContext {
super(options);
}
- public InnerContext(Context anotherContext) {
- super(anotherContext);
+ public InnerContext(Context context) {
+ super(context);
}
}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/entity/enums/SelectType.java b/dorive-core/src/main/java/com/gitee/dorive/core/entity/enums/MatcherType.java
similarity index 97%
rename from dorive-core/src/main/java/com/gitee/dorive/core/entity/enums/SelectType.java
rename to dorive-core/src/main/java/com/gitee/dorive/core/entity/enums/MatcherType.java
index e96e7bac7b410fd16ee0391a068877c1c5f65ef4..647121949f072f522acabed1bc8cef1cbdddf206 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/entity/enums/SelectType.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/entity/enums/MatcherType.java
@@ -17,7 +17,7 @@
package com.gitee.dorive.core.entity.enums;
-public enum SelectType {
+public enum MatcherType {
NONE,
ROOT,
ALL,
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AbstractSelector.java b/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AbstractSelector.java
index 9b6bff638c2624a67bfd63ae4870fda4a9d4236c..aa72cbb52bdb539c5a4143527d8b46e8cc5e0937 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AbstractSelector.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AbstractSelector.java
@@ -18,39 +18,14 @@
package com.gitee.dorive.core.impl.context;
import com.gitee.dorive.core.api.context.Selector;
-import com.gitee.dorive.core.entity.enums.SelectType;
+import com.gitee.dorive.core.entity.context.AbstractOptions;
+import com.gitee.dorive.core.entity.enums.MatcherType;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public abstract class AbstractSelector implements Selector {
-
- private final Map, Object> options = new LinkedHashMap<>(3);
+public abstract class AbstractSelector extends AbstractOptions implements Selector {
public AbstractSelector() {
- this.options.put(SelectType.class, SelectType.SELECTOR);
- this.options.put(Selector.class, this);
- }
-
- @Override
- public Map, Object> getOptions() {
- return options;
- }
-
- @Override
- public void setOption(Class type, T value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T getOption(Class type) {
- return (T) options.get(type);
- }
-
- @Override
- public void removeOption(Class> type) {
- throw new UnsupportedOperationException();
+ setOption(MatcherType.class, MatcherType.SELECTOR);
+ setOption(Selector.class, this);
}
}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/SelectTypeMatcher.java b/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AdaptiveMatcher.java
similarity index 72%
rename from dorive-core/src/main/java/com/gitee/dorive/core/impl/context/SelectTypeMatcher.java
rename to dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AdaptiveMatcher.java
index cd22d00c3f65ae305ce9267a0c2e43b85287c607..1b3ceab8840ce77d92c094ebfa5d00bc46abdddd 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/SelectTypeMatcher.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/impl/context/AdaptiveMatcher.java
@@ -20,7 +20,7 @@ package com.gitee.dorive.core.impl.context;
import com.gitee.dorive.core.api.context.Matcher;
import com.gitee.dorive.core.api.context.Options;
import com.gitee.dorive.core.api.context.Selector;
-import com.gitee.dorive.core.entity.enums.SelectType;
+import com.gitee.dorive.core.entity.enums.MatcherType;
import com.gitee.dorive.core.repository.CommonRepository;
import lombok.Getter;
import lombok.Setter;
@@ -34,24 +34,24 @@ import java.util.Set;
*/
@Getter
@Setter
-public class SelectTypeMatcher implements Matcher {
+public class AdaptiveMatcher implements Matcher {
private CommonRepository repository;
- private Map matcherMap = new LinkedHashMap<>(8);
+ private Map matcherTypeMatcherMap = new LinkedHashMap<>(6);
- public SelectTypeMatcher(CommonRepository repository) {
+ public AdaptiveMatcher(CommonRepository repository) {
this.repository = repository;
- this.matcherMap.put(SelectType.NONE, options -> false);
- this.matcherMap.put(SelectType.ROOT, options -> repository.isRoot());
- this.matcherMap.put(SelectType.ALL, options -> true);
- this.matcherMap.put(SelectType.SELECTOR, new SelectorMatcher());
+ this.matcherTypeMatcherMap.put(MatcherType.NONE, options -> false);
+ this.matcherTypeMatcherMap.put(MatcherType.ROOT, options -> repository.isRoot());
+ this.matcherTypeMatcherMap.put(MatcherType.ALL, options -> true);
+ this.matcherTypeMatcherMap.put(MatcherType.SELECTOR, new SelectorMatcher());
}
@Override
public boolean matches(Options options) {
- SelectType selectType = options.getOption(SelectType.class);
- if (selectType != null) {
- Matcher matcher = matcherMap.get(selectType);
+ MatcherType matcherType = options.getOption(MatcherType.class);
+ if (matcherType != null) {
+ Matcher matcher = matcherTypeMatcherMap.get(matcherType);
if (matcher != null) {
return matcher.matches(options);
}
diff --git a/dorive-core/src/main/java/com/gitee/dorive/core/impl/executor/ContextExecutor.java b/dorive-core/src/main/java/com/gitee/dorive/core/impl/executor/ContextExecutor.java
index f89a8ad9560981a9cc72dab2f2e8799a628db46b..1f41721a7877e09d5f912970c79909bc1624839e 100644
--- a/dorive-core/src/main/java/com/gitee/dorive/core/impl/executor/ContextExecutor.java
+++ b/dorive-core/src/main/java/com/gitee/dorive/core/impl/executor/ContextExecutor.java
@@ -18,23 +18,15 @@
package com.gitee.dorive.core.impl.executor;
import cn.hutool.core.lang.Assert;
-import cn.hutool.core.lang.Pair;
-import com.gitee.dorive.api.entity.core.EntityElement;
import com.gitee.dorive.core.api.context.Context;
import com.gitee.dorive.core.api.executor.EntityHandler;
+import com.gitee.dorive.core.api.executor.EntityOpHandler;
import com.gitee.dorive.core.entity.executor.Result;
import com.gitee.dorive.core.entity.operation.EntityOp;
import com.gitee.dorive.core.entity.operation.Operation;
import com.gitee.dorive.core.entity.operation.cop.Query;
-import com.gitee.dorive.core.entity.operation.eop.Delete;
-import com.gitee.dorive.core.entity.operation.eop.Insert;
-import com.gitee.dorive.core.entity.operation.eop.InsertOrUpdate;
-import com.gitee.dorive.core.entity.operation.eop.Update;
-import com.gitee.dorive.core.impl.factory.OperationFactory;
-import com.gitee.dorive.core.impl.resolver.DerivedResolver;
import com.gitee.dorive.core.repository.AbstractContextRepository;
import com.gitee.dorive.core.repository.CommonRepository;
-import com.gitee.dorive.core.util.CollectionUtils;
import lombok.Getter;
import lombok.Setter;
@@ -42,14 +34,16 @@ import java.util.List;
@Getter
@Setter
-public class ContextExecutor extends AbstractExecutor {
+public class ContextExecutor extends AbstractExecutor implements EntityHandler, EntityOpHandler {
private final AbstractContextRepository, ?> repository;
private final EntityHandler entityHandler;
+ private final EntityOpHandler entityOpHandler;
- public ContextExecutor(AbstractContextRepository, ?> repository, EntityHandler entityHandler) {
+ public ContextExecutor(AbstractContextRepository, ?> repository, EntityHandler entityHandler, EntityOpHandler entityOpHandler) {
this.repository = repository;
this.entityHandler = entityHandler;
+ this.entityOpHandler = entityOpHandler;
}
@Override
@@ -60,27 +54,16 @@ public class ContextExecutor extends AbstractExecutor {
Result