日期:2014-05-19  浏览次数:21736 次

use interceptor to log informations (J2EE 6 利用interceptor 打Log)

?

import javax.interceptor.AroundInvoke;

import javax.interceptor.Interceptor;

import javax.interceptor.InvocationContext;

?

?

Here is the example :

? ? ? ? 1.Define the annotation for interceptor

//@Inheritedto specify that the annotation can

//be inherited from superclasses

@Inherited

@InterceptorBinding

@Retention(RetentionPolicy.RUNTIME)

@Target({TYPE, METHOD})

public @interface Logged {

}

?

2. Define the interceptor

@Logged

@Interceptor

public class LoggedInterceptor implements Serializable {

友情链接: 爱易网 云虚拟主机技术 云服务器技术 程序设计技术 开发网站 APP开发教程
Copyright © 2013-2026 爱易网页 当前在线:174人  网站在8时39分19秒内访问总人数:73113人 8秒前 56.00%  粤ICP备18100884号-2