View Javadoc

1   /**
2    *
3    *  Licensed to the Apache Software Foundation (ASF) under one or more
4    *  contributor license agreements.  See the NOTICE file distributed with
5    *  this work for additional information regarding copyright ownership.
6    *  The ASF licenses this file to You under the Apache License, Version 2.0
7    *  (the "License"); you may not use this file except in compliance with
8    *  the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  
19  package org.apache.geronimo.deployment.plugin;
20  
21  import javax.enterprise.deploy.spi.DeploymentManager;
22  import javax.enterprise.deploy.spi.DeploymentConfiguration;
23  import javax.enterprise.deploy.spi.Target;
24  import javax.enterprise.deploy.spi.TargetModuleID;
25  import javax.enterprise.deploy.spi.status.ProgressObject;
26  import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
27  import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException;
28  import javax.enterprise.deploy.spi.exceptions.TargetException;
29  import javax.enterprise.deploy.model.DeployableObject;
30  import javax.enterprise.deploy.shared.DConfigBeanVersionType;
31  import javax.enterprise.deploy.shared.ModuleType;
32  import java.util.Locale;
33  import java.io.File;
34  import java.io.InputStream;
35  import org.apache.geronimo.connector.deployment.RARConfigurer;
36  import org.apache.geronimo.web.deployment.WARConfigurer;
37  import org.apache.commons.logging.Log;
38  import org.apache.commons.logging.LogFactory;
39  
40  /**
41   * Implementation of a disconnected JSR88 DeploymentManager.
42   *
43   *
44   * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
45   */
46  public class DisconnectedDeploymentManager implements DeploymentManager {
47      private static final Log log = LogFactory.getLog(DisconnectedDeploymentManager.class);
48  
49      public DeploymentConfiguration createConfiguration(DeployableObject dObj) throws InvalidModuleException {
50          if(dObj.getType().equals(ModuleType.CAR)) {
51              //todo: need a client configurer
52          } else if(dObj.getType().equals(ModuleType.EAR)) {
53              //todo: need an EAR configurer
54          } else if(dObj.getType().equals(ModuleType.EJB)) {
55              try {
56                  Class cls = Class.forName("org.apache.openejb.deployment.EJBConfigurer");
57                  return (DeploymentConfiguration)cls.getMethod("createConfiguration", new Class[]{DeployableObject.class}).invoke(cls.newInstance(), new Object[]{dObj});
58              } catch (Exception e) {
59                  log.error("Unable to invoke EJB deployer", e);
60              }
61          } else if(dObj.getType().equals(ModuleType.RAR)) {
62              return new RARConfigurer().createConfiguration(dObj);
63          } else if(dObj.getType().equals(ModuleType.WAR)) {
64              return new WARConfigurer().createConfiguration(dObj); // this is jetty
65              // todo: Tomcat WARConfigurer
66          }
67          throw new InvalidModuleException("Not supported");
68      }
69  
70      public Locale[] getSupportedLocales() {
71          return new Locale[]{getDefaultLocale()};
72      }
73  
74      public Locale getCurrentLocale() {
75          return getDefaultLocale();
76      }
77  
78      public Locale getDefaultLocale() {
79          return Locale.getDefault();
80      }
81  
82      public boolean isLocaleSupported(Locale locale) {
83          return getDefaultLocale().equals(locale);
84      }
85  
86      public void setLocale(Locale locale) {
87          if (isLocaleSupported(locale)) {
88              throw new UnsupportedOperationException("Unsupported Locale");
89          }
90      }
91  
92      public DConfigBeanVersionType getDConfigBeanVersion() {
93          return DConfigBeanVersionType.V1_4;
94      }
95  
96      public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType version) {
97          return DConfigBeanVersionType.V1_4.equals(version);
98      }
99  
100     public void setDConfigBeanVersion(DConfigBeanVersionType version) throws DConfigBeanVersionUnsupportedException {
101         if (!isDConfigBeanVersionSupported(version)) {
102             throw new DConfigBeanVersionUnsupportedException("Version not supported " + version);
103         }
104     }
105 
106     public Target[] getTargets() throws IllegalStateException {
107         throw new IllegalStateException("Disconnected");
108     }
109 
110     public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] targets) throws TargetException, IllegalStateException {
111         throw new IllegalStateException("Disconnected");
112     }
113 
114     public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] targets) throws TargetException, IllegalStateException {
115         throw new IllegalStateException("Disconnected");
116     }
117 
118     public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] targets) throws TargetException, IllegalStateException {
119         throw new IllegalStateException("Disconnected");
120     }
121 
122     public ProgressObject distribute(Target[] targets, File file, File file1) throws IllegalStateException {
123         throw new IllegalStateException("Disconnected");
124     }
125 
126     public ProgressObject distribute(Target[] targets, InputStream inputStream, InputStream inputStream1) throws IllegalStateException {
127         throw new IllegalStateException("Disconnected");
128     }
129 
130     public ProgressObject start(TargetModuleID[] targetModuleIDs) throws IllegalStateException {
131         throw new IllegalStateException("Disconnected");
132     }
133 
134     public ProgressObject stop(TargetModuleID[] targetModuleIDs) throws IllegalStateException {
135         throw new IllegalStateException("Disconnected");
136     }
137 
138     public ProgressObject undeploy(TargetModuleID[] targetModuleIDs) throws IllegalStateException {
139         throw new IllegalStateException("Disconnected");
140     }
141 
142     public boolean isRedeploySupported() {
143         return false;
144     }
145 
146     public ProgressObject redeploy(TargetModuleID[] targetModuleIDs, File file, File file1) throws UnsupportedOperationException, IllegalStateException {
147         throw new IllegalStateException("Disconnected");
148     }
149 
150     public ProgressObject redeploy(TargetModuleID[] targetModuleIDs, InputStream inputStream, InputStream inputStream1) throws UnsupportedOperationException, IllegalStateException {
151         throw new IllegalStateException("Disconnected");
152     }
153 
154     public void release() {
155         throw new IllegalStateException("Disconnected");
156     }
157 }