1 /** 2 * 3 * Copyright 2003-2005 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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 package org.apache.geronimo.tomcat.cluster; 18 19 import org.apache.geronimo.system.serverinfo.ServerInfo; 20 import org.apache.geronimo.gbean.GBeanInfo; 21 import org.apache.geronimo.gbean.GBeanInfoBuilder; 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 import org.apache.catalina.cluster.deploy.FarmWarDeployer; 25 26 27 public class FarmWarDeployerGBean extends ClusterDeployerGBean{ 28 29 private static final Log log = LogFactory 30 .getLog(FarmWarDeployerGBean.class); 31 32 private final ServerInfo serverInfo; 33 34 public FarmWarDeployerGBean(){ 35 serverInfo = null; 36 } 37 38 public FarmWarDeployerGBean(String tempDir, 39 String deployDir, 40 String watchDir, 41 boolean watchEnabled, 42 int processDeployFrequency, 43 ServerInfo serverInfo) throws Exception { 44 45 super("org.apache.catalina.cluster.deploy.FarmWarDeployer", null); 46 47 if (serverInfo == null){ 48 throw new IllegalArgumentException("serverInfo cannot be null."); 49 } 50 51 this.serverInfo = serverInfo; 52 53 FarmWarDeployer farm = (FarmWarDeployer)deployer; 54 55 if (tempDir == null) 56 tempDir = "var/catalina/war-temp"; 57 farm.setTempDir(serverInfo.resolvePath(tempDir)); 58 59 if (deployDir == null) 60 deployDir = "var/catalina/war-deploy"; 61 farm.setDeployDir(serverInfo.resolvePath(deployDir)); 62 63 if (watchDir == null) 64 watchDir = "var/catalina/war-listen"; 65 farm.setWatchDir(serverInfo.resolvePath(watchDir)); 66 67 farm.setWatchEnabled(watchEnabled); 68 69 farm.setProcessDeployFrequency(processDeployFrequency); 70 71 } 72 73 public static final GBeanInfo GBEAN_INFO; 74 75 static { 76 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("ClusterDeployer", FarmWarDeployerGBean.class, ClusterDeployerGBean.GBEAN_INFO); 77 78 infoFactory.addAttribute("tempDir", String.class, true); 79 infoFactory.addAttribute("deployDir", String.class, true); 80 infoFactory.addAttribute("watchDir", String.class, true); 81 infoFactory.addAttribute("watchEnabled", boolean.class, true); 82 infoFactory.addAttribute("processDeployFrequency", int.class, true); 83 infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean"); 84 infoFactory.addOperation("getInternalObject"); 85 infoFactory.setConstructor(new String[] { 86 "tempDir", 87 "deployDir", 88 "watchDir", 89 "watchEnabled", 90 "processDeployFrequency", 91 "ServerInfo" 92 }); 93 GBEAN_INFO = infoFactory.getBeanInfo(); 94 } 95 96 public static GBeanInfo getGBeanInfo() { 97 return GBEAN_INFO; 98 } 99 }