⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advisorchainfactory.java

📁 一个非常好的FRAMWRK!是一个外国组织做的!不!
💻 JAVA
字号:
/**
 * Copyright 2003-2005 the original author or authors.
 * 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 java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.aopalliance.intercept.MethodInterceptor;

import com.jdon.aop.interceptor.InterceptorsChain;
import com.jdon.bussinessproxy.TargetMetaDef;
import com.jdon.util.Debug;


/**
 * create the all interceptor instances
 * @author banq
 */
public class AdvisorChainFactory {
    
  private final static String module = AdvisorChainFactory.class.getName();

  private InterceptorsChain interceptorsChain;
    
    /**
     * @param interceptorsChain
     */
  public AdvisorChainFactory(InterceptorsChain interceptorsChain) {
      super();
      this.interceptorsChain = interceptorsChain;
  }
    
  /**
   * create the all interceptor instances, and put them into interceptorsChain;
   * the interceptors that prointcut is for SERVIERS are in the front,
   * and then the EJB Interceptors , in the back there are POJO interceptors.
   * you can change the orders bu replacing this class in container.xml  
   * 
   */	
  public List create(TargetMetaDef targetMetaDef) throws Exception {
    Debug.logVerbose(" enter  create PointcutAdvisor  " , module);
    List interceptors = new ArrayList(interceptorsChain.size()); 
    interceptors.addAll(interceptorsChain.getInterceptors(Pointcut.TARGET_PROPS_SERVICES));
    Debug.logVerbose(" find all service's interceptos size=" +  interceptors.size(), module);
    if (targetMetaDef.isEJB()){
        List ejbInterceptors = interceptorsChain.getInterceptors(Pointcut.EJB_TARGET_PROPS_SERVICES);
        if ((ejbInterceptors != null) && (ejbInterceptors.size() > 0)){
            interceptors.addAll(ejbInterceptors);
            Debug.logVerbose(" find ejbService's interceptos size=" +  interceptors.size(), module);
        }
    }else{
        List pojoInterceptors = interceptorsChain.getInterceptors(Pointcut.POJO_TARGET_PROPS_SERVICES);
        
        Iterator iter = pojoInterceptors.iterator();
        while(iter.hasNext()){
            MethodInterceptor i = (MethodInterceptor)iter.next();
            Debug.logVerbose(" iterator: " +  i.getClass().getName(), module);
            
        }
        
        if ((pojoInterceptors != null) && (pojoInterceptors.size() > 0)){
            interceptors.addAll(pojoInterceptors);
            Debug.logVerbose(" find pojoService's interceptos size=" +  interceptors.size(), module);
        }
    }
    return interceptors;
  }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -