Nanning Aspects -


Apache
跨平台
Java

软件简介

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();