Skip to content

Commit

Permalink
New for AOP
Browse files Browse the repository at this point in the history
  • Loading branch information
silentbalanceyh committed Jun 3, 2023
1 parent 2340df1 commit cf2df95
Show file tree
Hide file tree
Showing 89 changed files with 212 additions and 181 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.horizon.eon.em;

/**
* @author lang : 2023-06-03
*/
public final class EmAop {
private EmAop() {
}

/**
* 执行AOP的作用时间,全环境通用,使用单词 Effect 代表影响的意思,
* 副作用、影响表示其组件生命周期的发生时间戳
*/
public enum Effect {
BEFORE, // 之前执行
AFTER, // 之后执行
AROUND, // 前后执行
NONE, // 关闭不执行
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.horizon.eon.em;

/**
* @author lang : 2023-06-03
*/
public final class EmDict {
private EmDict() {
}

public enum Type {
CATEGORY, // The category data ( tree ) definition,
TABULAR, // The tabular data ( list ) definition,
ASSIST, // The adminicle data ( dynamic ) came from definition
DAO, // The standard Dao Dict for capture
NONE, // None for source define
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.horizon.eon.em.uca;
package io.horizon.eon.em.app;

/**
* @author <a href="http://www.origin-x.cn">Lang</a>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ public enum HttpStatusCode {
REQUEST_URI_TOO_LONG(414, "Request-URI Too Long"),

/**
* 415 Unsupported Media Type
* 415 Unsupported Media Effect
**/
UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Type"),
UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Effect"),

/**
* 416 Requested Range Not Satisfiable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,25 @@ interface HPCAop {
* </code></pre>
*/
String PLUGIN_COMPONENT_JOB = "plugin.component.job";
/**
* <value>plugin.config</value>, 和 Before/After 相关的组件静态配置,数据类型为 {@link io.vertx.core.json.JsonObject}
*
* 该组件配置为`name = Json`的核心结构,Json中存储了和组件相关的配置数据,配置如下:
*
* <pre><code>
* {
* "plugin.config": {
* "component1": {
*
* },
* "component2": {
*
* }
* }
* }
* </code></pre>
*
* 上述片段中 component1 和 component2 是组件名称(Java类全名)
*/
String PLUGIN_CONFIG = "plugin.config";
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private IoStream() {
* @param message The java object that will be converted from.
* @param <T> Target java object that will be converted to.
*
* @return Target java object ( Generic Type )
* @return Target java object ( Generic Effect )
*/
static <T> byte[] to(final T message) {
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Expand All @@ -48,7 +48,7 @@ static <T> byte[] to(final T message) {
*
* @param pos The position of reading
* @param buffer The buffer to hold the data from reading.
* @param <T> The converted java object type, Generic Type
* @param <T> The converted java object type, Generic Effect
*
* @return Return to converted java object.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

/**
* 「切面分流器」
* 根据既定规则对AOP部分的配置执行分流操作,分类规则
* 根据既定规则对AOP部分的配置执行分流操作,分类规则参考如下配置:
* <pre><code>
* {
* "plugin.switcher": {
* "field": "type"
* }
* }
* </code></pre>
*
* @author lang : 2023-06-03
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.horizon.uca.cache;

import io.horizon.eon.em.uca.CcMode;
import io.horizon.eon.em.app.CcMode;
import io.horizon.exception.internal.CcModeNullException;
import io.horizon.util.HUt;
import io.vertx.core.Future;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.horizon.uca.cache;

import io.horizon.eon.em.uca.CcMode;
import io.horizon.eon.em.app.CcMode;
import io.horizon.exception.internal.OperationException;
import io.vertx.core.Future;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static Vs create(final String identifier, final ConcurrentMap<String, HMe

// ============================ Static Comparing Change ===============================
public static boolean isValue(final Object value, final Class<?> type) {
// Fix Null Pointer Exception for Unknown Type comparing.
// Fix Null Pointer Exception for Unknown Effect comparing.
final VsSame same = VsSame.get(type);
return Objects.isNull(same) ? Objects.nonNull(value) : same.ok(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ interface HMeta {
Set<String> joins();

/*
* Type
* Effect
*/
ConcurrentMap<String, Class<?>> types();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface ARGS {
String MIME_DIRECT = "$$DIRECT$$";
/*
* Flow used here
* IGNORE -> Flow.TYPED ( Extract by Type )
* IGNORE -> Flow.TYPED ( Extract by Effect )
*/
String MIME_IGNORE = "$$IGNORE$$";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@ public enum ActPhase {
ERROR, // Error phase
}

/**
* 数据域 DataRegion 的触发时间
* - BEFORE: 在请求之前触发 DataRegion
* - AFTER:在请求之后触发 DataRegion
* - AROUND:在请求之前和之后都触发 DataRegion
* - NONE:不触发,直接禁用,方便热部署时禁用
*
* @author <a href="http://www.origin-x.cn">Lang</a>
*/
public enum ActTime {
BEFORE, // DataRegion before
AFTER, // DataRegion after
AROUND, // Around execution
NONE, // Disable dual mapping execution
}

/**
* Wall type for security
*/
Expand All @@ -88,27 +72,27 @@ public enum AuthWall {
* defined key that could be read configuration data from `vertx-secure.yml` etc.
*/
EXTENSION("extension");

private static final ConcurrentMap<String, AuthWall> TYPE_MAP = new ConcurrentHashMap<>();

static {
Arrays.stream(AuthWall.values()).forEach(wall -> TYPE_MAP.put(wall.key(), wall));
}

private transient final String configKey;

AuthWall(final String configKey) {
this.configKey = configKey;
}

public static AuthWall from(final String configKey) {
return TYPE_MAP.getOrDefault(configKey, null);
}

public static Set<String> keys() {
return TYPE_MAP.keySet();
}

public String key() {
return this.configKey;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* This class is ClusterOptions assist tool
*
* * enabled: Boolean Type
* * enabled: Boolean Effect
* * manager: String class and it will be converted to `ClusterManager`
* * options: JsonObject
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void init(final JsonObject input) {
final String typeFlag = Objects.isNull(toArray[1]) ? "" : toArray[1].trim();
if (Objects.nonNull(toField)) {
/*
* Type here
* Effect here
*/
final Class<?> type = BType.type(typeFlag);
/* mapping type */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.vertx.up.atom.exchange;

import io.horizon.eon.em.uca.AopType;
import io.horizon.eon.em.EmAop;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.up.util.Ut;
Expand Down Expand Up @@ -36,7 +36,7 @@ public class BTree implements Serializable {
/*
* Configured `MappingMode` and `Class<?>`
*/
private AopType mode = AopType.NONE;
private EmAop.Effect mode = EmAop.Effect.NONE;
private Class<?> component;

public BTree() {
Expand Down Expand Up @@ -82,15 +82,15 @@ public BTree init(final JsonObject input) {
* 3) DualMapping ( Bind Life Cycle )
* 4) valid() -> boolean Check whether the mapping is enabled.
*/
public AopType getMode() {
public EmAop.Effect getMode() {
return this.mode;
}

public Class<?> getComponent() {
return this.component;
}

public BTree bind(final AopType mode) {
public BTree bind(final EmAop.Effect mode) {
this.mode = mode;
return this;
}
Expand All @@ -101,7 +101,7 @@ public BTree bind(final Class<?> component) {
}

public boolean valid() {
return AopType.NONE != this.mode;
return EmAop.Effect.NONE != this.mode;
}

// ------------- Get by identifier ----------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.concurrent.ConcurrentMap;

/*
* Type Mapping here
* Effect Mapping here
* Definition for type conversation of `DualItem`
*/
class BType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.vertx.up.atom.exchange;

import io.horizon.eon.em.uca.DictType;
import io.horizon.eon.em.EmDict;
import io.horizon.specification.typed.TCopy;
import io.horizon.uca.log.Annal;
import io.vertx.core.json.JsonArray;
Expand Down Expand Up @@ -31,7 +31,7 @@ public class DSource implements Serializable, TCopy<DSource> {
/*
* SourceType of current source definition
*/
private DictType source;
private EmDict.Type source;
/*
* Another source of ASSIST here
*/
Expand All @@ -44,8 +44,8 @@ public DSource(final JsonObject definition) {
* Source normalize for `source type`
*/
final String source = definition.getString("source");
this.source = Ut.toEnum(() -> source, DictType.class, DictType.NONE);
if (DictType.CATEGORY == this.source || DictType.TABULAR == this.source) {
this.source = Ut.toEnum(() -> source, EmDict.Type.class, EmDict.Type.NONE);
if (EmDict.Type.CATEGORY == this.source || EmDict.Type.TABULAR == this.source) {
/*
* Different definition for
* 1) CATEGORY / TABULAR
Expand All @@ -56,7 +56,7 @@ public DSource(final JsonObject definition) {
.map(item -> (String) item)
.forEach(this.types::add);
}
} else if (DictType.ASSIST == this.source) {
} else if (EmDict.Type.ASSIST == this.source) {
/*
* Different definition for
* ASSIST
Expand All @@ -79,7 +79,7 @@ public DSource(final JsonObject definition) {
private DSource() {
}

public DictType getSourceType() {
public EmDict.Type getSourceType() {
return this.source;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* - key : System Primary Key
* - code : System Code
* - name : System Name
* - type : System Type
* - type : System Effect
* - category : System Category
* - serial : System Number & Serialization
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ public long waitUntil() {
* Fix issue of delay < 1ms, the default should be 1
* Cannot schedule a timer with delay < 1 ms
*
* Type = ONCE
* Effect = ONCE
*/
return 1;
} else {
/*
* Type != ONCE
* Effect != ONCE
*/
final Instant start = Instant.now();
final long delay = ChronoUnit.MILLIS.between(start, end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static <T> void verifyItem(final T input, final JsonObject rule) throws
reference.flumen(data, rule);
// EmType
reference = CC_INSURER.pick(TypedInsurer::new, "A-EmType");
// Fn.po?lThread(POOL_INSURER, TypedInsurer::new, "A-Type");
// Fn.po?lThread(POOL_INSURER, TypedInsurer::new, "A-Effect");
reference.flumen(data, rule);
// Forbidden
reference = CC_INSURER.pick(ForbiddenInsurer::new, "A-Forbidden");
Expand All @@ -119,8 +119,8 @@ private static <T> void verifyItem(final T input, final JsonObject rule) throws
// Fn.po?lThread(POOL_INSURER, RequiredInsurer::new, "J-Required");
reference.flumen(data, rule);
// EmType
reference = CC_INSURER.pick(TypedInsurer::new, "J-Type");
// Fn.po?lThread(POOL_INSURER, TypedInsurer::new, "J-Type");
reference = CC_INSURER.pick(TypedInsurer::new, "J-Effect");
// Fn.po?lThread(POOL_INSURER, TypedInsurer::new, "J-Effect");
reference.flumen(data, rule);
// Forbidden
reference = CC_INSURER.pick(ForbiddenInsurer::new, "J-Forbidden");
Expand Down
Loading

0 comments on commit cf2df95

Please sign in to comment.