📄 serviceregistry.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.bussinessproxy;
import com.jdon.bussinessproxy.web.DefaultServiceAdapter;
import com.jdon.bussinessproxy.method.EJBMethodInvoker;
import com.jdon.bussinessproxy.target.EJBTargetService;
import com.jdon.controller.ContainerRegistry;
import com.jdon.controller.ContainerWrapper;
import com.jdon.bussinessproxy.config.TargetMetaDefXmlLoader;
import java.util.List;
import com.jdon.aop.joinpoint.JoinpointFactory;
import org.picocontainer.defaults.ComponentParameter;
import org.picocontainer.Parameter;
import java.util.Collection;
import org.picocontainer.MutablePicoContainer;
import com.jdon.aop.AopInterceptorRegistry;
import com.jdon.bussinessproxy.cache.VisitorFactory;
import com.jdon.bussinessproxy.cache.VisitableFactory;
import org.picocontainer.defaults.DuplicateComponentKeyRegistrationException;
import java.util.Map;
import java.util.Iterator;
import com.jdon.util.Debug;
/**
* ServiceFactory
*
* 利用Picocontainer生成Service
*
* <p>Copyright: Jdon.com Copyright (c) 2003</p>
* <p></p>
* @author banq
* @version 1.0
*/
public class ServiceRegistry implements ContainerRegistry, KeyConstants {
private final static String module = ServiceRegistry.class.getName();
private ContainerWrapper containerWrapper;
public ContainerWrapper getContainerWrapper() {
return containerWrapper;
}
public ServiceRegistry(ContainerWrapper containerWrapper) {
this.containerWrapper = containerWrapper;
}
/**
* 从后向前逐个注册。
* 1. 终端target
* 2. AOP
* 3. BusinessProxy
* 4. VisitorCache
* 5. 面向客户端的ServiceAdapter
*/
public void register() {
registerTatgetService();
registerAOPService();
registerBusinessProxyService();
//注册面向客户端调用的Service
containerWrapper.register(SERVICE_NAME, DefaultServiceAdapter.class);
registerXmlConfig();
}
private void registerXmlConfig(){
try{
containerWrapper.register(SERVICE_METALOADER_NAME, TargetMetaDefXmlLoader.class,
new Parameter[] {
new ComponentParameter(CONFIG_NAME)
});
}catch(DuplicateComponentKeyRegistrationException de){
}
}
public void registerTatgetService() {
containerWrapper.register(TARGET_SERVICE, EJBTargetService.class);
containerWrapper.register(METHOD_INVOKER, EJBMethodInvoker.class);
}
public void registerAOPService() {
//整合拦截器
ContainerWrapper child = containerWrapper.getChild(
AopInterceptorRegistry.INTERCEPTORS_NAME);
List inerceptors = child.getAllInstances();
containerWrapper.register("inerceptors", inerceptors);
containerWrapper.register("JoinpointFactory", JoinpointFactory.class,
new Parameter[] {
new ComponentParameter("inerceptors"),
new ComponentParameter(METHOD_INVOKER)
});
containerWrapper.register(AOP_CLIENT, AopClient.class);
}
public void registerBusinessProxyService() {
//VisitableFactory
containerWrapper.register(VISITABLEFACTORY_NAME, VisitableFactory.class);
//注册VisitorFactory
containerWrapper.register(VISIORFACTORY_NAME, VisitorFactory.class);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -