分类: Java
2008-11-26 15:21:06
1.DI配置文件:helloworld2.dicon内容如下:
"">
2.自动注册的情况下,S2Container#init()和S2Container#destroy()的调用是必要的
package org.tie.seasar1.client;
import org.apache.log4j.Logger;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.container.factory.S2ContainerFactory;
import org.tie.seasar1.service.impl.HelloWorld;
public class HelloWorldClient2 {
private static final Logger log = Logger.getLogger(HelloWorldClient2.class);
private static final String PATH = "dicon/helloworld2.dicon";
// 自动注册的情况下,S2Container#init()和S2Container#destroy()的调用是必要的
public static void main(String[] args) {
S2Container container = S2ContainerFactory.create(PATH);
container.init();
try {
HelloWorld helloWorld = (HelloWorld) container
.getComponent("helloWorld");
helloWorld.sayHello();
log.info("组件自动注册");
} finally {
log.info("自动注册的情况下,S2Container#init()和S2Container#destroy()的调用是必要的");
container.destroy();
}
}
}