diff --git a/src/main/java/org/redkale/annotation/Async.java b/src/main/java/org/redkale/annotation/Async.java deleted file mode 100644 index e74bbe1ef..000000000 --- a/src/main/java/org/redkale/annotation/Async.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * - */ -package org.redkale.annotation; - -import java.lang.annotation.*; - -/** - * 异步模式标记。 - * - *

- * 详情见: https://redkale.org - * - * @author zhangjx - * - * @since 2.8.0 - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Async { - - boolean value() default true; -} diff --git a/src/main/java/org/redkale/annotation/NonBlocking.java b/src/main/java/org/redkale/annotation/NonBlocking.java new file mode 100644 index 000000000..2fdf29dc3 --- /dev/null +++ b/src/main/java/org/redkale/annotation/NonBlocking.java @@ -0,0 +1,28 @@ +/* + * + */ +package org.redkale.annotation; + +import java.lang.annotation.*; + +/** + * 非阻塞模式标记, 标记在Service类和方法、Filter类、HttpServlet类上
+ * 一般情况下,没有显注此注解的方法视为阻塞时, 以下两种情况除外:
+ * 1、返回类型是CompletableFuture
+ * 2、返回类型是void且参数存在CompletionHandler类型
+ * 阻塞模式的方法会在work线程池中运行, 非阻塞在IO线程中运行。 + * + * + *

+ * 详情见: https://redkale.org + * + * @author zhangjx + * + * @since 2.8.0 + */ +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface NonBlocking { + + boolean value() default true; +} diff --git a/src/main/java/org/redkale/net/DispatcherServlet.java b/src/main/java/org/redkale/net/DispatcherServlet.java index ccf8025ca..cc66d8c2c 100644 --- a/src/main/java/org/redkale/net/DispatcherServlet.java +++ b/src/main/java/org/redkale/net/DispatcherServlet.java @@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.function.Predicate; import java.util.logging.Level; import java.util.stream.Stream; -import org.redkale.annotation.Async; +import org.redkale.annotation.NonBlocking; import org.redkale.boot.Application; import org.redkale.util.*; @@ -210,15 +210,15 @@ public abstract class DispatcherServlet { - - @Override - public Class type() { - return long.class; - } - - @Override - public Class declaringClass() { - return SncpTestBean.class; - } - - @Override - public String field() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Long get(SncpTestBean obj) { - System.out.println("返回ID: " + obj.getId()); - return obj.getId(); - } - - @Override - public void set(SncpTestBean obj, Long value) { - System.out.println("设置ID: " + value); - obj.setId(value); - } - - } - @Override public SncpTestBean insert(SncpTestBean bean) { bean.setId(System.currentTimeMillis());