KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > Startup


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.ioc;
8
9 import org.jfox.ioc.depend.ComponentRefDependency;
10 import org.jfox.ioc.depend.Dependency;
11 import org.jfox.ioc.depend.ObjectDependency;
12 import org.jfox.ioc.deploy.ComponentDeployer;
13 import org.jfox.ioc.deploy.DeployMonitor;
14
15 /**
16  * 该类发布 HttpManagement 服务和 DeployMonitor 服务,
17  * 默认 DeployMonitor 服务使用 ./modules 目录作为组件模块部署目录。
18  * 然后启动 Registry,DeployMonitor 将会发布 ./modules 目录下的各模块
19  *
20  *
21  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
22  */

23
24 public class Startup {
25
26     /**
27      *
28      * @param args 第一个参数为模块部署目录
29      * @throws Exception
30      */

31     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
32         String JavaDoc moduleDir = "./modules";
33         if(args !=null && args.length !=0){
34             if(!args[0].trim().equals("")) {
35                 moduleDir = args[0].trim();
36             }
37         }
38
39         Registry registry = Registry.getInstance();
40         registry.registerComponent(ComponentDeployer.class);
41         ComponentMeta meta = registry.registerComponent(DeployMonitor.class,
42                 new Dependency[]{
43                     new ComponentRefDependency(ComponentName.newInstance(ComponentDeployer.class)),
44                     new ObjectDependency(moduleDir)});
45         registry.getComponentInstance(meta.getComponentName());
46         //启动 registry,registry将启动注册的服务,DeployMonitor 将发布modules下的组件
47
registry.start();
48     }
49 }
50
Popular Tags