KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > deployment > plugin > DisconnectedDeploymentManager


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.deployment.plugin;
19
20 import java.io.File JavaDoc;
21 import java.io.InputStream JavaDoc;
22 import java.util.Locale JavaDoc;
23
24 import javax.enterprise.deploy.model.DeployableObject JavaDoc;
25 import javax.enterprise.deploy.shared.DConfigBeanVersionType JavaDoc;
26 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
27 import javax.enterprise.deploy.spi.DeploymentConfiguration JavaDoc;
28 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
29 import javax.enterprise.deploy.spi.Target JavaDoc;
30 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
31 import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException JavaDoc;
32 import javax.enterprise.deploy.spi.exceptions.InvalidModuleException JavaDoc;
33 import javax.enterprise.deploy.spi.exceptions.TargetException JavaDoc;
34 import javax.enterprise.deploy.spi.status.ProgressObject JavaDoc;
35
36 import org.apache.commons.logging.Log;
37 import org.apache.commons.logging.LogFactory;
38
39 /**
40  * Implementation of a disconnected JSR88 DeploymentManager.
41  *
42  *
43  * @version $Rev: 482870 $ $Date: 2006-12-05 21:50:50 -0500 (Tue, 05 Dec 2006) $
44  */

45 public class DisconnectedDeploymentManager implements DeploymentManager JavaDoc {
46     private static final Log log = LogFactory.getLog(DisconnectedDeploymentManager.class);
47
48     public DeploymentConfiguration JavaDoc createConfiguration(DeployableObject JavaDoc dObj) throws InvalidModuleException JavaDoc {
49         if(dObj.getType().equals(ModuleType.CAR)) {
50             //todo: need a client configurer
51
} else if(dObj.getType().equals(ModuleType.EAR)) {
52             //todo: need an EAR configurer
53
} else if(dObj.getType().equals(ModuleType.EJB)) {
54             try {
55                 Class JavaDoc cls = Class.forName("org.apache.openejb.deployment.EJBConfigurer");
56                 return (DeploymentConfiguration JavaDoc)cls.getMethod("createConfiguration", new Class JavaDoc[]{DeployableObject JavaDoc.class}).invoke(cls.newInstance(), new Object JavaDoc[]{dObj});
57             } catch (Exception JavaDoc e) {
58                 log.error("Unable to invoke EJB deployer", e);
59             }
60         } else if(dObj.getType().equals(ModuleType.RAR)) {
61 // return new RARConfigurer().createConfiguration(dObj);
62
} else if(dObj.getType().equals(ModuleType.WAR)) {
63 // return new WARConfigurer().createConfiguration(dObj); // this is jetty
64
// todo: Tomcat WARConfigurer
65
}
66         throw new InvalidModuleException JavaDoc("Not supported");
67     }
68
69     public Locale JavaDoc[] getSupportedLocales() {
70         return new Locale JavaDoc[]{getDefaultLocale()};
71     }
72
73     public Locale JavaDoc getCurrentLocale() {
74         return getDefaultLocale();
75     }
76
77     public Locale JavaDoc getDefaultLocale() {
78         return Locale.getDefault();
79     }
80
81     public boolean isLocaleSupported(Locale JavaDoc locale) {
82         return getDefaultLocale().equals(locale);
83     }
84
85     public void setLocale(Locale JavaDoc locale) {
86         if (isLocaleSupported(locale)) {
87             throw new UnsupportedOperationException JavaDoc("Unsupported Locale");
88         }
89     }
90
91     public DConfigBeanVersionType JavaDoc getDConfigBeanVersion() {
92         return DConfigBeanVersionType.V1_4;
93     }
94
95     public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType JavaDoc version) {
96         return DConfigBeanVersionType.V1_4.equals(version);
97     }
98
99     public void setDConfigBeanVersion(DConfigBeanVersionType JavaDoc version) throws DConfigBeanVersionUnsupportedException JavaDoc {
100         if (!isDConfigBeanVersionSupported(version)) {
101             throw new DConfigBeanVersionUnsupportedException JavaDoc("Version not supported " + version);
102         }
103     }
104
105     public Target JavaDoc[] getTargets() throws IllegalStateException JavaDoc {
106         throw new IllegalStateException JavaDoc("Disconnected");
107     }
108
109     public TargetModuleID JavaDoc[] getRunningModules(ModuleType JavaDoc moduleType, Target JavaDoc[] targets) throws TargetException JavaDoc, IllegalStateException JavaDoc {
110         throw new IllegalStateException JavaDoc("Disconnected");
111     }
112
113     public TargetModuleID JavaDoc[] getNonRunningModules(ModuleType JavaDoc moduleType, Target JavaDoc[] targets) throws TargetException JavaDoc, IllegalStateException JavaDoc {
114         throw new IllegalStateException JavaDoc("Disconnected");
115     }
116
117     public TargetModuleID JavaDoc[] getAvailableModules(ModuleType JavaDoc moduleType, Target JavaDoc[] targets) throws TargetException JavaDoc, IllegalStateException JavaDoc {
118         throw new IllegalStateException JavaDoc("Disconnected");
119     }
120
121     public ProgressObject JavaDoc distribute(Target JavaDoc[] targets, File JavaDoc file, File JavaDoc file1) throws IllegalStateException JavaDoc {
122         throw new IllegalStateException JavaDoc("Disconnected");
123     }
124
125     public ProgressObject JavaDoc distribute(Target JavaDoc[] targets, InputStream JavaDoc inputStream, InputStream JavaDoc inputStream1) throws IllegalStateException JavaDoc {
126         throw new IllegalStateException JavaDoc("Disconnected");
127     }
128
129     public ProgressObject JavaDoc start(TargetModuleID JavaDoc[] targetModuleIDs) throws IllegalStateException JavaDoc {
130         throw new IllegalStateException JavaDoc("Disconnected");
131     }
132
133     public ProgressObject JavaDoc stop(TargetModuleID JavaDoc[] targetModuleIDs) throws IllegalStateException JavaDoc {
134         throw new IllegalStateException JavaDoc("Disconnected");
135     }
136
137     public ProgressObject JavaDoc undeploy(TargetModuleID JavaDoc[] targetModuleIDs) throws IllegalStateException JavaDoc {
138         throw new IllegalStateException JavaDoc("Disconnected");
139     }
140
141     public boolean isRedeploySupported() {
142         return false;
143     }
144
145     public ProgressObject JavaDoc redeploy(TargetModuleID JavaDoc[] targetModuleIDs, File JavaDoc file, File JavaDoc file1) throws UnsupportedOperationException JavaDoc, IllegalStateException JavaDoc {
146         throw new IllegalStateException JavaDoc("Disconnected");
147     }
148
149     public ProgressObject JavaDoc redeploy(TargetModuleID JavaDoc[] targetModuleIDs, InputStream JavaDoc inputStream, InputStream JavaDoc inputStream1) throws UnsupportedOperationException JavaDoc, IllegalStateException JavaDoc {
150         throw new IllegalStateException JavaDoc("Disconnected");
151     }
152
153     public void release() {
154         throw new IllegalStateException JavaDoc("Disconnected");
155     }
156 }
157
Popular Tags