1 22 package org.jboss.services.deployment; 23 24 import java.net.URL ; 25 import java.util.HashMap ; 26 import java.util.List ; 27 import java.util.Set ; 28 import java.util.StringTokenizer ; 29 30 import org.jboss.system.ListenerServiceMBeanSupport; 31 32 39 public class DeploymentService 40 extends ListenerServiceMBeanSupport 41 implements DeploymentServiceMBean 42 { 43 45 46 public static final String DEFAULT_TEMPLATE_DIR = "conf/templates"; 47 48 49 public static final String DEFAULT_UNDEPLOY_DIR = "undeploy"; 50 51 52 public static final String DEFAULT_DEPLOY_DIR = "deploy"; 53 54 56 57 private DeploymentManager manager; 58 59 60 private String templateDir; 61 62 63 private String undeployDir; 64 65 66 private String deployDir; 67 68 70 73 public DeploymentService() 74 { 75 templateDir = DEFAULT_TEMPLATE_DIR; 76 undeployDir = DEFAULT_UNDEPLOY_DIR; 77 deployDir = DEFAULT_DEPLOY_DIR; 78 } 79 80 82 87 public void setTemplateDir(String templateDir) 88 { 89 this.templateDir = templateDir; 90 } 91 92 97 public String getTemplateDir() 98 { 99 return templateDir; 100 } 101 102 105 public String getUndeployDir() 106 { 107 return undeployDir; 108 } 109 110 113 public void setUndeployDir(String undeployDir) 114 { 115 this.undeployDir = undeployDir; 116 } 117 118 121 public String getDeployDir() 122 { 123 return deployDir; 124 } 125 126 129 public void setDeployDir(String deployDir) 130 { 131 this.deployDir = deployDir; 132 } 133 134 136 139 public Set listModuleTemplates() 140 { 141 return manager.listModuleTemplates(); 142 } 143 144 147 public List getTemplatePropertyInfo(String template) 148 throws Exception 149 { 150 return manager.getTemplatePropertyInfo(template); 151 } 152 153 156 public String createModule(String module, String template, HashMap properties) 157 throws Exception 158 { 159 return manager.createModule(module, template, properties); 160 } 161 162 167 public String createModule(String module, String template, String [] properties) 168 throws Exception 169 { 170 HashMap map = new HashMap (); 172 173 for (int i = 0; i < properties.length; i++) 174 { 175 StringTokenizer st = new StringTokenizer (properties[i], "="); 176 177 String key = st.nextToken(); 178 String value = st.nextToken(); 179 180 if (value.indexOf('|') >= 0) 181 { 182 StringTokenizer st2 = new StringTokenizer (value, "|"); 184 185 int tokens = st2.countTokens(); 186 String [] array = new String [tokens]; 187 for (int j = 0; j < tokens; j++) 188 array[j] = st2.nextToken(); 189 190 map.put(key, array); 191 } 192 else 193 { 194 map.put(key, value); 195 } 196 } 197 return manager.createModule(module, template, map); 198 } 199 200 203 public boolean removeModule(String module) 204 { 205 return manager.removeModule(module); 206 } 207 208 211 public boolean updateMBean(MBeanData data) throws Exception 212 { 213 return manager.updateMBean(data); 214 } 215 216 219 public String updateDataSource(String module, String template, HashMap properties) 220 throws Exception 221 { 222 return manager.updateDataSource(module, template, properties); 223 } 224 225 228 public String removeDataSource(String module, String template, HashMap properties) 229 throws Exception 230 { 231 return manager.removeDataSource(module, template, properties); 232 } 233 234 237 public void deployModuleAsynch(String module) 238 throws Exception 239 { 240 manager.moveToDeployDir(module); 241 } 242 243 246 public URL getDeployedURL(String module) 247 throws Exception 248 { 249 return manager.getDeployedURL(module); 250 } 251 252 255 public void undeployModuleAsynch(String module) 256 throws Exception 257 { 258 manager.moveToModuleDir(module); 259 } 260 261 264 public URL getUndeployedURL(String module) 265 throws Exception 266 { 267 return manager.getUndeployedURL(module); 268 } 269 270 282 public boolean uploadLibrary(URL src, String filename) 283 { 284 return LibraryManager.getInstance().uploadLibrary(src, filename); 285 } 286 287 289 public void startService() 290 throws Exception 291 { 292 manager = new DeploymentManager(templateDir, undeployDir, deployDir, log); 293 } 294 295 public void stopService() 296 { 297 manager = null; 298 } 299 300 } 301 | Popular Tags |