diff --git a/pom.xml b/pom.xml
index 43f4e39..62a4d75 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@
vrml-metric
vrml-netty
vrml-reactor
+ vrml-reflect
vrml-request
vrml-resource
vrml-shutdown
@@ -167,6 +168,11 @@
vrml-reactor
${project.version}
+
+ group.rxcloud
+ vrml-reflect
+ ${project.version}
+
group.rxcloud
vrml-request
diff --git a/vrml-all/pom.xml b/vrml-all/pom.xml
index adba295..2ebc8f1 100644
--- a/vrml-all/pom.xml
+++ b/vrml-all/pom.xml
@@ -71,6 +71,10 @@
group.rxcloud
vrml-reactor
+
+ group.rxcloud
+ vrml-reflect
+
group.rxcloud
vrml-request
diff --git a/vrml-reactor/src/main/java/group/rxcloud/vrml/reactor/VrFlux.java b/vrml-reactor/src/main/java/group/rxcloud/vrml/reactor/VrFlux.java
index 204efb9..32c1646 100644
--- a/vrml-reactor/src/main/java/group/rxcloud/vrml/reactor/VrFlux.java
+++ b/vrml-reactor/src/main/java/group/rxcloud/vrml/reactor/VrFlux.java
@@ -42,16 +42,64 @@ public static void subscribeAfterInit(Flux flux, Duration firstLoad, Cons
}
/**
- * ้ๅฟ
้กป็
+ * Flux: Subscribe after init not essential.
+ *
+ * @param the type parameter
+ * @param flux the flux
+ * @param consumer the consumer
+ * @return {@code true} if subscribe success.
*/
- public static void subscribeAfterInitNonEssential(Flux flux, Consumer super T> consumer) {
- T t = null;
+ public static boolean subscribeAfterInitNonEssential(Flux flux, Consumer super T> consumer) {
try {
- t = flux.blockFirst();
+ T t = flux.blockFirst();
+ if (t != null) {
+ consumer.accept(t);
+ }
} catch (Exception e) {
- throw new RuntimeException(e);
+ if (log.isWarnEnabled()) {
+ log.warn("[Vrml.flux] [subscribeAfterInitNonEssential] blockFirst error", e);
+ }
+ }
+ try {
+ flux.subscribe(consumer);
+ return true;
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("[Vrml.flux] [subscribeAfterInitNonEssential] subscribe error", e);
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Flux: Subscribe after init not essential.
+ *
+ * @param the type parameter
+ * @param flux the flux
+ * @param firstLoad the first load timeout
+ * @param consumer the consumer
+ * @return {@code true} if subscribe success.
+ */
+ public static boolean subscribeAfterInitNonEssential(Flux flux, Duration firstLoad, Consumer super T> consumer) {
+ try {
+ T t = flux.blockFirst(firstLoad);
+ if (t != null) {
+ consumer.accept(t);
+ }
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("[Vrml.flux] [subscribeAfterInitNonEssential] blockFirst error, firstLoad[{}]",
+ firstLoad, e);
+ }
+ }
+ try {
+ flux.subscribe(consumer);
+ return true;
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn("[Vrml.flux] [subscribeAfterInitNonEssential] subscribe error", e);
+ }
+ return false;
}
- consumer.accept(t);
- flux.subscribe(consumer);
}
}
diff --git a/vrml-reflect/pom.xml b/vrml-reflect/pom.xml
new file mode 100644
index 0000000..9dac50f
--- /dev/null
+++ b/vrml-reflect/pom.xml
@@ -0,0 +1,19 @@
+
+
+ 4.0.0
+
+
+ vrml
+ group.rxcloud
+ 1.1.2
+
+
+ vrml-reflect
+ jar
+
+
+
+
+
\ No newline at end of file
diff --git a/vrml-reflect/src/main/java/group/rxcloud/vrml/reflect/VrReflectUtils.java b/vrml-reflect/src/main/java/group/rxcloud/vrml/reflect/VrReflectUtils.java
new file mode 100644
index 0000000..c7512cb
--- /dev/null
+++ b/vrml-reflect/src/main/java/group/rxcloud/vrml/reflect/VrReflectUtils.java
@@ -0,0 +1,25 @@
+package group.rxcloud.vrml.reflect;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * The Vrml reflect utils.
+ */
+public class VrReflectUtils {
+
+ /**
+ * Create obj by class object.
+ *
+ * @param clazz the clazz
+ * @return the object
+ * @throws NoSuchMethodException the no such method exception
+ * @throws InvocationTargetException the invocation target exception
+ * @throws InstantiationException the instantiation exception
+ * @throws IllegalAccessException the illegal access exception
+ */
+ public static T createObjByClass(Class clazz) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
+ Constructor constructor = clazz.getConstructor();
+ return constructor.newInstance();
+ }
+}