KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > deployment > application > EARDeployer


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 package org.jfox.deployment.application;
7
8 import org.jfox.deployment.ejb.EJBDeployer;
9 import org.jfox.deployment.ejb.NestedEJBModule;
10 import org.jfox.deployment.web.WebDeployer;
11 import org.jfox.deployment.web.WebModule;
12 import org.jfox.ioc.common.AbstractComponent;
13 import org.jfox.ioc.deploy.DeployException;
14 import org.jfox.ioc.deployment.Deployable;
15 import org.jfox.ioc.deployment.Deployer;
16
17 /**
18  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
19  */

20
21 public class EARDeployer extends AbstractComponent implements Deployer {
22 // private static EARDeployer instance = new EARDeployer();
23
// private static EJBDeployer ejbDeployer = EJBDeployer.getInstance();
24
// private static WebDeployer webDeployer = WebDeployer.getInstance();
25

26     private EJBDeployer ejbDeployer = null;
27     private WebDeployer webDeployer = null;
28
29     public EARDeployer(EJBDeployer ejbDeployer, WebDeployer webDeployer) {
30         this.ejbDeployer = ejbDeployer;
31         this.webDeployer = webDeployer;
32     }
33
34 /*
35   public static EARDeployer getInstance(){
36     return instance;
37   }
38 */

39
40     public void deploy(Deployable comp) throws DeployException {
41         if(comp instanceof EARModule) {
42             try {
43                 EARModule earModule = (EARModule) comp;
44
45                 NestedEJBModule[] ejbModules = earModule.getNestedEJBModules();
46                 for(int i = 0; i < ejbModules.length; i++) {
47                     ejbModules[i].deploy(ejbDeployer);
48                 }
49
50                 WebModule[] webModules = earModule.getNestedWebModules();
51                 for(int i = 0; i < webModules.length; i++) {
52                     webModules[i].deploy(webDeployer);
53                 }
54
55             }
56             catch(Exception JavaDoc e) {
57                 throw new DeployException("deploy Module " + comp + " error", e);
58             }
59         }
60         else {
61             throw new DeployException("can not deploy " + comp);
62         }
63     }
64
65     //TODO: implements EARDeploy.undeploy
66
public void undeploy(Deployable comp) throws DeployException {
67
68     }
69
70     protected void doInit() throws Exception JavaDoc {
71     }
72
73     protected void doDestroy() throws Exception JavaDoc {
74     }
75
76     public EJBDeployer getEjbDeployer() {
77         return ejbDeployer;
78     }
79
80     public WebDeployer getWebDeployer() {
81         return webDeployer;
82     }
83
84     public static void main(String JavaDoc[] args) {
85
86     }
87 }
88
89
Popular Tags