001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package org.apache.geronimo.deployment.plugin; 020 021 import javax.enterprise.deploy.spi.DeploymentManager; 022 import javax.enterprise.deploy.spi.DeploymentConfiguration; 023 import javax.enterprise.deploy.spi.Target; 024 import javax.enterprise.deploy.spi.TargetModuleID; 025 import javax.enterprise.deploy.spi.status.ProgressObject; 026 import javax.enterprise.deploy.spi.exceptions.InvalidModuleException; 027 import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException; 028 import javax.enterprise.deploy.spi.exceptions.TargetException; 029 import javax.enterprise.deploy.model.DeployableObject; 030 import javax.enterprise.deploy.shared.DConfigBeanVersionType; 031 import javax.enterprise.deploy.shared.ModuleType; 032 import java.util.Locale; 033 import java.io.File; 034 import java.io.InputStream; 035 import org.apache.geronimo.connector.deployment.RARConfigurer; 036 import org.apache.geronimo.web.deployment.WARConfigurer; 037 import org.apache.commons.logging.Log; 038 import org.apache.commons.logging.LogFactory; 039 040 /** 041 * Implementation of a disconnected JSR88 DeploymentManager. 042 * 043 * 044 * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $ 045 */ 046 public class DisconnectedDeploymentManager implements DeploymentManager { 047 private static final Log log = LogFactory.getLog(DisconnectedDeploymentManager.class); 048 049 public DeploymentConfiguration createConfiguration(DeployableObject dObj) throws InvalidModuleException { 050 if(dObj.getType().equals(ModuleType.CAR)) { 051 //todo: need a client configurer 052 } else if(dObj.getType().equals(ModuleType.EAR)) { 053 //todo: need an EAR configurer 054 } else if(dObj.getType().equals(ModuleType.EJB)) { 055 try { 056 Class cls = Class.forName("org.apache.openejb.deployment.EJBConfigurer"); 057 return (DeploymentConfiguration)cls.getMethod("createConfiguration", new Class[]{DeployableObject.class}).invoke(cls.newInstance(), new Object[]{dObj}); 058 } catch (Exception e) { 059 log.error("Unable to invoke EJB deployer", e); 060 } 061 } else if(dObj.getType().equals(ModuleType.RAR)) { 062 return new RARConfigurer().createConfiguration(dObj); 063 } else if(dObj.getType().equals(ModuleType.WAR)) { 064 return new WARConfigurer().createConfiguration(dObj); // this is jetty 065 // todo: Tomcat WARConfigurer 066 } 067 throw new InvalidModuleException("Not supported"); 068 } 069 070 public Locale[] getSupportedLocales() { 071 return new Locale[]{getDefaultLocale()}; 072 } 073 074 public Locale getCurrentLocale() { 075 return getDefaultLocale(); 076 } 077 078 public Locale getDefaultLocale() { 079 return Locale.getDefault(); 080 } 081 082 public boolean isLocaleSupported(Locale locale) { 083 return getDefaultLocale().equals(locale); 084 } 085 086 public void setLocale(Locale locale) { 087 if (isLocaleSupported(locale)) { 088 throw new UnsupportedOperationException("Unsupported Locale"); 089 } 090 } 091 092 public DConfigBeanVersionType getDConfigBeanVersion() { 093 return DConfigBeanVersionType.V1_4; 094 } 095 096 public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType version) { 097 return DConfigBeanVersionType.V1_4.equals(version); 098 } 099 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 }