📄 defaultcontainerwrapper.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 org.picocontainer.MutablePicoContainer;
import com.jdon.util.Debug;
import org.picocontainer.Parameter;
import java.util.List;
import org.picocontainer.defaults.DefaultPicoContainer;
import com.jdon.controller.ContainerWrapper;
/**
* 以Picocontainer为容器基础组件
*
* <p>Copyright: Jdon.com Copyright (c) 2005</p>
* <p></p>
* @author banq
* @version JdonFramework 2005 v1.0
*/
public class DefaultContainerWrapper implements ContainerWrapper {
public final static String module = DefaultContainerWrapper.class.getName();
private MutablePicoContainer container;
public DefaultContainerWrapper(MutablePicoContainer container) {
this.container = container;
}
public void registerChild(String name) {
try {
MutablePicoContainer child = new DefaultPicoContainer(container);
register(name, child);
} catch (Exception ex) {
Debug.logWarning(" registe error: " + name, module);
}
}
public void register(String name, Class className) {
try {
container.registerComponentImplementation(name, className);
} catch (Exception ex) {
Debug.logWarning(" registe error: " + name, module);
}
}
public void register(String name, Class className, Parameter[] parameters) {
try {
container.registerComponentImplementation(name, className, parameters);
} catch (Exception ex) {
Debug.logWarning(" registe error: " + name, module);
}
}
public void register(String name, Object instance) {
try {
container.registerComponentInstance(name, instance);
} catch (Exception ex) {
Debug.logWarning(" registe error: " + name, module);
}
}
public void start() {
container.start();
}
public void stop() {
container.stop();
container.dispose();
}
public List getAllInstances() {
return container.getComponentInstances();
}
public Object lookup(String name) {
Object object = container.getComponentInstance(name);
if (object == null)
Debug.logWarning("Not find the component in container :" + name, module);
return object;
}
public ContainerWrapper getChild(String name) {
MutablePicoContainer child = (MutablePicoContainer)lookup(name);
return new DefaultContainerWrapper(child);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -