📄 joinpointfactory.java
字号:
/**
* Copyright 2005 Jdon.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jdon.aop.joinpoint;
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInvocation;
import com.jdon.bussinessproxy.MethodInvoker;
import com.jdon.bussinessproxy.cache.ComponentCacheVisitor;
import com.jdon.bussinessproxy.TargetMetaDef;
import com.jdon.util.Debug;
import java.util.Collection;
import com.jdon.aop.*;
import com.jdon.bussinessproxy.meta.MethodMetaArgs;
/**
* 生成Joinpoint工厂类
*
* 创建ProxyMethodInvocation实例,ProxyMethodInvocation生命周期
* 是Request,在每个Request中,以每个方法为Key,逐个访问interceptors集合
* 中的每个拦截器
* @author banq
* @version 1.0
*/
public class JoinpointFactory implements Advisor {
private final static String module = JoinpointFactory.class.getName();
private Collection interceptors ;
protected MethodInvoker methodInvoker;
public Collection getInterceptors() {
return interceptors;
}
public JoinpointFactory(Collection interceptors, MethodInvoker methodInvoker) {
this.interceptors = interceptors;
this.methodInvoker = methodInvoker;
}
/**
* 每次动态代理的方法调用激活本方法
*
*
* @param targetMethodInvoker MethodInvoker
* @param session HttpSession
* @param targetMetaDef TargetMetaDef
* @param m Method
* @param arguments Object[]
* @throws Exception
* @return MethodInvocation
*/
public MethodInvocation createJoinpoint(ComponentCacheVisitor cm,
TargetMetaDef targetMetaDef) throws
Exception {
Debug.logVerbose(" enter createJoinpoint ", module);
MethodMetaArgs methodMetaDef = targetMetaDef.getMethodMetaArgs();
ProxyMethodInvocation proxyMethodInvocation = new
ProxyMethodInvocation(cm, methodInvoker, interceptors, targetMetaDef);
//每次调用的是同一个proxyMethodInvocation
//但是不同的是参数 和指针
proxyMethodInvocation.setArguments(methodMetaDef.getArgs());
proxyMethodInvocation.resetIterator();
return proxyMethodInvocation;
}
public Advice getAdvice() {
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -