From d2f7f63d6773fa6f50964ba84e0d601ad59934bc Mon Sep 17 00:00:00 2001 From: wentch <22250530@qq.com> Date: Tue, 15 Dec 2015 15:13:49 +0800 Subject: [PATCH] --- src/org/redkale/net/http/AuthIgnore.java | 23 -------- .../redkale/net/http/BasedHttpServlet.java | 53 +++++++++++++++++++ src/org/redkale/net/http/HttpCacheable.java | 27 ---------- src/org/redkale/net/http/WebAction.java | 22 -------- 4 files changed, 53 insertions(+), 72 deletions(-) delete mode 100644 src/org/redkale/net/http/AuthIgnore.java delete mode 100644 src/org/redkale/net/http/HttpCacheable.java delete mode 100644 src/org/redkale/net/http/WebAction.java diff --git a/src/org/redkale/net/http/AuthIgnore.java b/src/org/redkale/net/http/AuthIgnore.java deleted file mode 100644 index 526cb1c08..000000000 --- a/src/org/redkale/net/http/AuthIgnore.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.http; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * 配合 BasedHttpServlet 使用, 当标记为 @AuthIgnore 的方法不会再调用之前调用authenticate 方法。 - * - * @author zhangjx - */ -@Inherited -@Documented -@Target({METHOD, TYPE}) -@Retention(RUNTIME) -public @interface AuthIgnore { - -} diff --git a/src/org/redkale/net/http/BasedHttpServlet.java b/src/org/redkale/net/http/BasedHttpServlet.java index 6ce094eaf..d632b92b1 100644 --- a/src/org/redkale/net/http/BasedHttpServlet.java +++ b/src/org/redkale/net/http/BasedHttpServlet.java @@ -10,6 +10,9 @@ import org.redkale.net.Request; import org.redkale.net.Context; import org.redkale.util.AnyValue; import java.io.IOException; +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.reflect.Method; import java.nio.*; import java.util.*; @@ -23,6 +26,56 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; */ public abstract class BasedHttpServlet extends HttpServlet { + /** + * 配合 BasedHttpServlet 使用。 + * 当标记为 @AuthIgnore 的方法不会再调用之前调用authenticate 方法。 + * + * @author zhangjx + */ + @Inherited + @Documented + @Target({METHOD, TYPE}) + @Retention(RUNTIME) + public static @interface AuthIgnore { + + } + + /** + * 配合 BasedHttpServlet 使用。 + * 用于对@WebServlet对应的url进行细分。 其 url + * + * @author zhangjx + */ + @Target({ElementType.METHOD}) + @Retention(RetentionPolicy.RUNTIME) + @Documented + public static @interface WebAction { + + int actionid() default 0; + + String url(); + } + + /** + * 配合 BasedHttpServlet 使用。 + * 当标记为 @HttpCacheable 的方法使用response.finish的参数将被缓存一定时间(默认值timeout=15秒)。 + * 通常情况下 @HttpCacheable 需要与 @AuthIgnore 一起使用,因为没有标记@AuthIgnore的方法一般输出的结果与当前用户信息有关。 + * + * @author zhangjx + */ + @Target({ElementType.METHOD}) + @Retention(RetentionPolicy.RUNTIME) + @Documented + public static @interface HttpCacheable { + + /** + * 超时的秒数 + * + * @return + */ + int timeout() default 15; + } + private Map.Entry[] actions; public boolean preExecute(HttpRequest request, HttpResponse response) throws IOException { diff --git a/src/org/redkale/net/http/HttpCacheable.java b/src/org/redkale/net/http/HttpCacheable.java deleted file mode 100644 index 25142c9e0..000000000 --- a/src/org/redkale/net/http/HttpCacheable.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.http; - -import java.lang.annotation.*; - -/** - * 配合 BasedHttpServlet 使用, 当标记为 @HttpCacheable 的方法使用response.finish的参数将被缓存一定时间(默认值timeout=15秒)。 - * 通常情况下 @HttpCacheable 需要与 @AuthIgnore 一起使用,因为没有标记@AuthIgnore的方法一般输出的结果与当前用户信息有关。 - * - * @author zhangjx - */ -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface HttpCacheable { - - /** - * 超时的秒数 - * - * @return - */ - int timeout() default 15; -} diff --git a/src/org/redkale/net/http/WebAction.java b/src/org/redkale/net/http/WebAction.java deleted file mode 100644 index 3a7fc68f4..000000000 --- a/src/org/redkale/net/http/WebAction.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package org.redkale.net.http; - -import java.lang.annotation.*; - -/** - * - * @author zhangjx - */ -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface WebAction { - - int actionid() default 0; - - String url(); -}