微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Nanning Aspects

程序名称:Nanning Aspects

授权协议: Apache

操作系统: 跨平台

开发语言: Java

Nanning Aspects 介绍

Nanning Aspects 是一个简单的可扩展的面向方面的 Java 框架。

示例代码

Method method = Interface.class.getmethod("call", null);  
AspectInstance aspectInstance = new AspectInstance();  
Mixin mixin = new Mixin(Interface.class, new Target());  
mixin.addInterceptor(method, new MethodInterceptor() {  
    public void invoke(Invocation invocation) {  
        System.out.println("Hello world from an interceptor on " + invocation.getmethod());  
        Object result = invocation.invokeNext(); // passes call on to next interceptor or target  
        return result: // result will be passed on to the caller as the return value of the call  
    }  
});  
aspectInstance.addMixin(mixin);  
Interface proxy = (Interface) aspectInstance.getProxy();  
proxy.call();

Nanning Aspects 官网

http://nanning.codehaus.org/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐