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

📄 containerregistry.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.container.builder;

import com.jdon.aop.interceptor.InterceptorsChain;
import com.jdon.bussinessproxy.meta.POJOTargetMetaDef;
import com.jdon.container.ContainerWrapper;
import com.jdon.container.config.ComponentMetaDef;
import com.jdon.container.config.aspect.AspectComponentsMetaDef;
import com.jdon.container.config.app.AppConfigureCollection;
import com.jdon.controller.cache.InstanceCache;
import com.jdon.util.Debug;

/**
 * all register methods for the container
 * by a class manage all register implemention.
 * ContainerBuilder is its client.
 * 
 * @author <a href="mailto:banqiao@jdon.com">banq</a>
 *
 */
public class ContainerRegistry {
    public final static String module = ContainerRegistry.class.getName();
    
    private ContainerWrapper containerWrapper;
    
    public ContainerRegistry(ContainerWrapper containerWrapper){
        this.containerWrapper = containerWrapper;
    }

    
    public void registerAppConfigureFiles(){
        containerWrapper.register(AppConfigureCollection.NAME, AppConfigureCollection.class);
    }
  
    
    public void registerComponentMetaDef(ComponentMetaDef componentMetaDef){
        try{
            String name = componentMetaDef.getName();
            String[] construtors = componentMetaDef.getConstructors();   
            String className = componentMetaDef.getClassName();        
            Class cclass = createClass(className);
            containerWrapper.register(name, cclass, construtors);
        }catch(Exception ex){
            Debug.logError(" registerComponentMetaDef error:" + ex, module);
        }
        
    }

    public void registerPOJOTargetMetaDef(POJOTargetMetaDef pOJOTargetMetaDef){
        try{        
            String name = pOJOTargetMetaDef.getName();
            String className = pOJOTargetMetaDef.getClassName();
            Class cclass = createClass(className);
            String[] construtors = pOJOTargetMetaDef.getConstructors();  
            containerWrapper.register(name, cclass, construtors);
        }catch(Exception ex){
            Debug.logError(" registerPOJOTargetMetaDef error:" + ex, module);
        }        
    }
    
    
    public void registerAspectComponentMetaDef(AspectComponentsMetaDef componentMetaDef){
        registerComponentMetaDef(componentMetaDef);
    }    

  
    private Class createClass(String className){
      Class classService = null;
      try{
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        classService = classLoader.loadClass(className);
      }catch(Exception ex){
        Debug.logError(" createClass:" + ex, module);
      }
      return classService;

    }    
}

⌨️ 快捷键说明

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