001 /** 002 * 003 * Copyright 2003-2005 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.tomcat.cluster; 018 019 import org.apache.geronimo.system.serverinfo.ServerInfo; 020 import org.apache.geronimo.gbean.GBeanInfo; 021 import org.apache.geronimo.gbean.GBeanInfoBuilder; 022 import org.apache.commons.logging.Log; 023 import org.apache.commons.logging.LogFactory; 024 import org.apache.catalina.cluster.deploy.FarmWarDeployer; 025 026 027 public class FarmWarDeployerGBean extends ClusterDeployerGBean{ 028 029 private static final Log log = LogFactory 030 .getLog(FarmWarDeployerGBean.class); 031 032 private final ServerInfo serverInfo; 033 034 public FarmWarDeployerGBean(){ 035 serverInfo = null; 036 } 037 038 public FarmWarDeployerGBean(String tempDir, 039 String deployDir, 040 String watchDir, 041 boolean watchEnabled, 042 int processDeployFrequency, 043 ServerInfo serverInfo) throws Exception { 044 045 super("org.apache.catalina.cluster.deploy.FarmWarDeployer", null); 046 047 if (serverInfo == null){ 048 throw new IllegalArgumentException("serverInfo cannot be null."); 049 } 050 051 this.serverInfo = serverInfo; 052 053 FarmWarDeployer farm = (FarmWarDeployer)deployer; 054 055 if (tempDir == null) 056 tempDir = "var/catalina/war-temp"; 057 farm.setTempDir(serverInfo.resolvePath(tempDir)); 058 059 if (deployDir == null) 060 deployDir = "var/catalina/war-deploy"; 061 farm.setDeployDir(serverInfo.resolvePath(deployDir)); 062 063 if (watchDir == null) 064 watchDir = "var/catalina/war-listen"; 065 farm.setWatchDir(serverInfo.resolvePath(watchDir)); 066 067 farm.setWatchEnabled(watchEnabled); 068 069 farm.setProcessDeployFrequency(processDeployFrequency); 070 071 } 072 073 public static final GBeanInfo GBEAN_INFO; 074 075 static { 076 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("ClusterDeployer", FarmWarDeployerGBean.class, ClusterDeployerGBean.GBEAN_INFO); 077 078 infoFactory.addAttribute("tempDir", String.class, true); 079 infoFactory.addAttribute("deployDir", String.class, true); 080 infoFactory.addAttribute("watchDir", String.class, true); 081 infoFactory.addAttribute("watchEnabled", boolean.class, true); 082 infoFactory.addAttribute("processDeployFrequency", int.class, true); 083 infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean"); 084 infoFactory.addOperation("getInternalObject"); 085 infoFactory.setConstructor(new String[] { 086 "tempDir", 087 "deployDir", 088 "watchDir", 089 "watchEnabled", 090 "processDeployFrequency", 091 "ServerInfo" 092 }); 093 GBEAN_INFO = infoFactory.getBeanInfo(); 094 } 095 096 public static GBeanInfo getGBeanInfo() { 097 return GBEAN_INFO; 098 } 099 }