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

📄 defaultcontainerbuilder.java

📁 Java/J2EE框架Jdon-Framework系统的Sample
💻 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.controller.container;

import java.util.*;

import org.picocontainer.*;
import com.jdon.aop.*;
import com.jdon.bussinessproxy.*;
import com.jdon.bussinessproxy.KeyConstants;
import com.jdon.controller.*;
import com.jdon.controller.cache.*;
import com.jdon.model.*;
import com.jdon.servicelocator.*;
import com.jdon.util.*;

/**
 * 实现每个组件向容器注册
 *
 * <p>Copyright: Jdon.com Copyright (c) 2005</p>
 * <p></p>
 * @author banq
 * @version JdonFramework 2005 v1.0
 */
public class DefaultContainerBuilder implements ContainerBuilder, KeyConstants {
  public final static String module = DefaultContainerBuilder.class.getName();
  private ContainerWrapper cw;
  private boolean startup;

  public DefaultContainerBuilder(MutablePicoContainer mc) {
    cw = new DefaultContainerWrapper(mc);
  }

  public ContainerWrapper getContainerWrapper() {
    if (startup)
      return cw;
    else
      return null;
  }

  public void XmlConfiguresRegiste(Collection configList) {
    Debug.logVerbose(" note: XmlConfiguresRegiste()", module);
    Collection confAllList = (Collection) cw.lookup(CONFIG_NAME);
    if (confAllList == null) {
      cw.register(CONFIG_NAME, configList);
    } else {
      confAllList.addAll(configList);
    }
  }

  //注册ServiceLocator ServiceLocator本身有全局缓存
  //所有的组件都可能使用到。是非常通用的
  //应该是最新注册
  public void serviceLocatorRegiste() {
    Debug.logVerbose(" note: serviceLocatorRegiste()", module);
    ContainerRegistry sr = new ServiceLocatorRegistry(cw);
    sr.register();
  }

  //注册LRU缓存
  //缓存组件,也是通用的的
  public void cacheFactoryRegiste() {
    Debug.logVerbose(" note: cacheFactoryRegiste()", module);
    ContainerRegistry cacheR = new CacheFactoryRegistry(cw);
    cacheR.register();
  }

  //注册Model框架
  public void modelManagerRegiste() {
    Debug.logVerbose(" note: modelManagerRegiste()", module);
    ContainerRegistry mr = new ModelManagerRegistry(cw);
    mr.register();
  }

  //注册AOP子容器(所有的拦截器)
  public void aopInterceptorRegiste() {
    Debug.logVerbose(" note: aopInterceptorRegiste()", module);
    ContainerRegistry ar = new AopInterceptorRegistry(cw);
    ar.register();
  }

  //注册动态Service框架businessproxy
  public void serviceRegiste() {
    Debug.logVerbose(" note: serviceRegiste()", module);
    ContainerRegistry serviceR = new ServiceRegistry(cw);
    serviceR.register();
  }

  public void userServiceRegiste(){
    ContainerRegistry serviceR = new UserServiceRegistry(cw);
    serviceR.register();

  }

  public void setStartup(boolean startup) {
    this.startup = startup;
  }

  public boolean isStartup() {
    return startup;
  }

}

⌨️ 快捷键说明

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