Author: markt Date: Fri Jan 14 14:01:20 2011 New Revision: 1059011 URL: http://svn.apache.org/viewvc?rev=1059011&view=rev Log: i18n
Added: tomcat/trunk/java/org/apache/catalina/ha/deploy/Constants.java (with props) tomcat/trunk/java/org/apache/catalina/ha/deploy/LocalStrings.properties (with props) Modified: tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java tomcat/trunk/webapps/docs/changelog.xml Added: tomcat/trunk/java/org/apache/catalina/ha/deploy/Constants.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/deploy/Constants.java?rev=1059011&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ha/deploy/Constants.java (added) +++ tomcat/trunk/java/org/apache/catalina/ha/deploy/Constants.java Fri Jan 14 14:01:20 2011 @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.ha.deploy; + +/** + * Manifest constants for the <code>org.apache.catalina.ha.deploy</code> + * package. + */ +public class Constants { + + public static final String Package = "org.apache.catalina.ha.deploy"; + +} Propchange: tomcat/trunk/java/org/apache/catalina/ha/deploy/Constants.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=1059011&r1=1059010&r2=1059011&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java (original) +++ tomcat/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java Fri Jan 14 14:01:20 2011 @@ -38,6 +38,7 @@ import org.apache.catalina.tribes.Member import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.modeler.Registry; +import org.apache.tomcat.util.res.StringManager; /** @@ -59,9 +60,13 @@ import org.apache.tomcat.util.modeler.Re * @author Peter Rossbach * @version $Revision$ */ -public class FarmWarDeployer extends ClusterListener implements ClusterDeployer, FileChangeListener { +public class FarmWarDeployer extends ClusterListener + implements ClusterDeployer, FileChangeListener { /*--Static Variables----------------------------------------*/ private static final Log log = LogFactory.getLog(FarmWarDeployer.class); + private static final StringManager sm = + StringManager.getManager(Constants.Package); + /** * The descriptive information about this implementation. */ @@ -142,7 +147,7 @@ public class FarmWarDeployer extends Clu return; Container hcontainer = getCluster().getContainer(); if(!(hcontainer instanceof Host)) { - log.error("FarmWarDeployer can only work as host cluster subelement!"); + log.error(sm.getString("farmWarDeployer.hostOnly")); return ; } host = (Host) hcontainer; @@ -150,7 +155,8 @@ public class FarmWarDeployer extends Clu // Check to correct engine and host setup Container econtainer = host.getParent(); if(!(econtainer instanceof Engine)) { - log.error("FarmWarDeployer can only work if parent of " + host.getName()+ " is an engine!"); + log.error(sm.getString("farmWarDeployer.hostParentEngine", + host.getName())); return ; } Engine engine = (Engine) econtainer; @@ -160,18 +166,20 @@ public class FarmWarDeployer extends Clu oname = new ObjectName(engine.getName() + ":type=Deployer,host=" + hostname); } catch (Exception e) { - log.error("Can't construct MBean object name" + e); + log.error(sm.getString("farmWarDeployer.mbeanNameFail", + engine.getName(), hostname),e); return; } if (watchEnabled) { watcher = new WarWatcher(this, new File(getWatchDir())); if (log.isInfoEnabled()) { - log.info("Cluster deployment is watching " + getWatchDir() - + " for changes."); + log.info(sm.getString( + "farmWarDeployer.watchDir", getWatchDir())); } } - configBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf"); + configBase = new File( + System.getProperty(Globals.CATALINA_BASE_PROP), "conf"); configBase = new File(configBase, engine.getName()); configBase = new File(configBase, hostname); @@ -184,7 +192,7 @@ public class FarmWarDeployer extends Clu getCluster().addClusterListener(this); if (log.isInfoEnabled()) - log.info("Cluster FarmWarDeployer started."); + log.info(sm.getString("farmWarDeployer.started")); } /* @@ -203,12 +211,12 @@ public class FarmWarDeployer extends Clu } if (log.isInfoEnabled()) - log.info("Cluster FarmWarDeployer stopped."); + log.info(sm.getString("farmWarDeployer.stopped")); } public void cleanDeployDir() { - throw new java.lang.UnsupportedOperationException( - "Method cleanDeployDir() not yet implemented."); + throw new java.lang.UnsupportedOperationException(sm.getString( + "farmWarDeployer.notImplemented", "cleanDeployDir()")); } /** @@ -224,9 +232,8 @@ public class FarmWarDeployer extends Clu if (msg instanceof FileMessage) { FileMessage fmsg = (FileMessage) msg; if (log.isDebugEnabled()) - log.debug("receive cluster deployment [ path: " - + fmsg.getContextPath() + " war: " - + fmsg.getFileName() + " ]"); + log.debug(sm.getString("farmWarDeployer.msgRxDeploy", + fmsg.getContextPath(), fmsg.getFileName())); FileMessageFactory factory = getFactory(fmsg); // TODO correct second try after app is in service! if (factory.writeMessage(fmsg)) { @@ -242,21 +249,21 @@ public class FarmWarDeployer extends Clu try { remove(path); if (!factory.getFile().renameTo(deployable)) { - log.error("Failed to rename [" + - factory.getFile() + "] to [" + - deployable + "]"); + log.error(sm.getString( + "farmWarDeployer.renameFail", + factory.getFile(), deployable)); } check(path); } finally { removeServiced(path); } if (log.isDebugEnabled()) - log.debug("deployment from " + path - + " finished."); + log.debug(sm.getString( + "farmWarDeployer.deployEnd", path)); } else - log.error("Application " + path - + " in used. touch war file " + name - + " again!"); + log.error(sm.getString( + "farmWarDeployer.servicingDeploy", path, + name)); } catch (Exception ex) { log.error(ex); } finally { @@ -268,7 +275,8 @@ public class FarmWarDeployer extends Clu UndeployMessage umsg = (UndeployMessage) msg; String path = umsg.getContextPath(); if (log.isDebugEnabled()) - log.debug("receive cluster undeployment from " + path); + log.debug(sm.getString("farmWarDeployer.msgRxUndeploy", + path)); if (!isServiced(path)) { addServiced(path); try { @@ -277,18 +285,17 @@ public class FarmWarDeployer extends Clu removeServiced(path); } if (log.isDebugEnabled()) - log.debug("undeployment from " + path - + " finished."); + log.debug(sm.getString( + "farmWarDeployer.undeployEnd", path)); } else - log.error("Application " - + path - + " in used. Sorry not remove from backup cluster nodes!"); + log.error(sm.getString( + "farmWarDeployer.servicingUneploy", path)); } catch (Exception ex) { log.error(ex); } } } catch (java.io.IOException x) { - log.error("Unable to read farm deploy file message.", x); + log.error(sm.getString("farmWarDeployer.msgIoe"), x); } } @@ -375,21 +382,21 @@ public class FarmWarDeployer extends Clu FileMessage msg = new FileMessage(localMember, war.getFile(), contextPath); if(log.isDebugEnabled()) - log.debug("Send cluster war deployment [ path:" - + contextPath + " war: " + war + " ] started."); + log.debug(sm.getString("farmWarDeployer.sendStart", contextPath, + war)); msg = factory.readMessage(msg); while (msg != null) { for (int i = 0; i < members.length; i++) { if (log.isDebugEnabled()) - log.debug("Send cluster war fragment [ path: " - + contextPath + " war: " + war + " to: " + members[i] + " ]"); + log.debug(sm.getString("farmWarDeployer.sendFragment", + contextPath, war, members[i])); getCluster().send(msg, members[i]); } msg = factory.readMessage(msg); } if(log.isDebugEnabled()) - log.debug("Send cluster war deployment [ path: " - + contextPath + " war: " + war + " ] finished."); + log.debug(sm.getString( + "farmWarDeployer.sendEnd", contextPath, war)); } /** @@ -415,16 +422,16 @@ public class FarmWarDeployer extends Clu * if an input/output error occurs during removal */ @Override - public void remove(String contextPath, boolean undeploy) throws IOException { + public void remove(String contextPath, boolean undeploy) + throws IOException { if (log.isInfoEnabled()) - log.info("Cluster wide remove of web app " + contextPath); + log.info(sm.getString("farmWarDeployer.removeStart", contextPath)); Member localMember = getCluster().getLocalMember(); UndeployMessage msg = new UndeployMessage(localMember, System .currentTimeMillis(), "Undeploy:" + contextPath + ":" + System.currentTimeMillis(), contextPath, undeploy); if (log.isDebugEnabled()) - log.debug("Send cluster wide undeployment from " - + contextPath ); + log.debug(sm.getString("farmWarDeployer.removeTxMsg", contextPath)); cluster.send(msg); // remove locally if (undeploy) { @@ -437,11 +444,12 @@ public class FarmWarDeployer extends Clu removeServiced(contextPath); } } else - log.error("Local remove from " + contextPath - + "failed, other manager has app in service!"); + log.error(sm.getString("farmWarDeployer.removeFailRemote", + contextPath)); } catch (Exception ex) { - log.error("local remove from " + contextPath + " failed", ex); + log.error(sm.getString("farmWarDeployer.removeFailLocal", + contextPath), ex); } } @@ -450,7 +458,7 @@ public class FarmWarDeployer extends Clu /* * Modification from watchDir war detected! * - * @see org.apache.catalina.ha.deploy.FileChangeListener#fileModified(java.io.File) + * @see org.apache.catalina.ha.deploy.FileChangeListener#fileModified(File) */ @Override public void fileModified(File newWar) { @@ -459,40 +467,42 @@ public class FarmWarDeployer extends Clu copy(newWar, deployWar); String contextName = getContextName(deployWar); if (log.isInfoEnabled()) - log.info("Installing webapp[" + contextName + "] from " - + deployWar.getAbsolutePath()); + log.info(sm.getString("farmWarDeployer.modInstall", contextName, + deployWar.getAbsolutePath())); try { remove(contextName, false); } catch (Exception x) { - log.error("No removal", x); + log.error(sm.getString("farmWarDeployer.modRemoveFail"), x); } install(contextName, deployWar.toURI().toURL()); } catch (Exception x) { - log.error("Unable to install WAR file", x); + log.error(sm.getString("farmWarDeployer.modInstallFail"), x); } } /* * War remove from watchDir * - * @see org.apache.catalina.ha.deploy.FileChangeListener#fileRemoved(java.io.File) + * @see org.apache.catalina.ha.deploy.FileChangeListener#fileRemoved(File) */ @Override public void fileRemoved(File removeWar) { try { String contextName = getContextName(removeWar); if (log.isInfoEnabled()) - log.info("Removing webapp[" + contextName + "]"); + log.info(sm.getString("farmWarDeployer.removeLocal", + contextName)); remove(contextName, true); } catch (Exception x) { - log.error("Unable to remove WAR file", x); + log.error(sm.getString("farmWarDeployer.removeLocalFail"), x); } } /** * Create a context path from war * @param war War filename - * @return '/filename' or if war name is ROOT.war context name is empty string '' + * @return '/filename' or if war name is ROOT.war context name is empty + * string '' */ protected String getContextName(File war) { String contextName = "/" @@ -535,7 +545,7 @@ public class FarmWarDeployer extends Clu Context context = (Context) host.findChild(path); if (context != null) { if(log.isDebugEnabled()) - log.debug("Undeploy local context " +path ); + log.debug(sm.getString("farmWarDeployer.undeployLocal", path)); context.stop(); String baseName = context.getBaseName(); File war = new File(getAppBase(), baseName + ".war"); @@ -543,13 +553,13 @@ public class FarmWarDeployer extends Clu File xml = new File(configBase, baseName + ".xml"); if (war.exists()) { if (!war.delete()) { - log.error("Failed to delete [" + war + "]"); + log.error(sm.getString("farmWarDeployer.deleteFail", war)); } } else if (dir.exists()) { undeployDir(dir); } else { if (!xml.delete()) { - log.error("Failed to delete [" + xml + "]"); + log.error(sm.getString("farmWarDeployer.deleteFail", xml)); } } // Perform new deployment and remove internal HostConfig state @@ -577,12 +587,12 @@ public class FarmWarDeployer extends Clu undeployDir(file); } else { if (!file.delete()) { - log.error("Failed to delete [" + file + "]"); + log.error(sm.getString("farmWarDeployer.deleteFail", file)); } } } if (!dir.delete()) { - log.error("Failed to delete [" + dir + "]"); + log.error(sm.getString("farmWarDeployer.deleteFail", dir)); } } @@ -722,7 +732,7 @@ public class FarmWarDeployer extends Clu try { if (!to.exists()) { if (!to.createNewFile()) { - log.error("Unable to create [" + to + "]"); + log.error(sm.getString("farmWarDeployer.fileNewFail", to)); return false; } } @@ -739,7 +749,8 @@ public class FarmWarDeployer extends Clu is.close(); os.close(); } catch (IOException e) { - log.error("Unable to copy file from:" + from + " to:" + to, e); + log.error(sm.getString("farmWarDeployer.fileCopyFail", + from, to), e); return false; } return true; Added: tomcat/trunk/java/org/apache/catalina/ha/deploy/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/deploy/LocalStrings.properties?rev=1059011&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ha/deploy/LocalStrings.properties (added) +++ tomcat/trunk/java/org/apache/catalina/ha/deploy/LocalStrings.properties Fri Jan 14 14:01:20 2011 @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +farmWarDeployer.deleteFail=Failed to delete [{0}] +farmWarDeployer.deployEnd=Deployment from [{0}] finished. +farmWarDeployer.fileCopyFail=Unable to copy from [{0}] to [{1}] +farmWarDeployer.fileNewFail=Unable to create [{0}] +farmWarDeployer.hostOnly=FarmWarDeployer can only work as host cluster subelement! +farmWarDeployer.hostParentEngine=FarmWarDeployer can only work if parent of [{0}] is an engine! +farmWarDeployer.mbeanNameFail=Can't construct MBean object name for engine [{0}] and host [{1}] +farmWarDeployer.modInstall=Installing webapp [{0}] from [{1}] +farmWarDeployer.modRemoveFail=No removal +farmWarDeployer.modInstallFail=Unable to install WAR file +farmWarDeployer.msgIoe=Unable to read farm deploy file message. +farmWarDeployer.msgRxDeploy=Receive cluster deployment path [{0}], war [{1}] +farmWarDeployer.msgRxUndeploy=Receive cluster undeployment from path [{0}] +farmWarDeployer.notImplemented=Method [{0}] not yet implemented. +farmWarDeployer.removeStart=Cluster wide remove of web app [{0}] +farmWarDeployer.removeTxMsg=Send cluster wide undeployment from [{1}] +farmWarDeployer.removeFailRemote=Local remove from [{0}] failed, other manager has app in service! +farmWarDeployer.removeFailLocal=Local remove from [{0}] failed +farmWarDeployer.removeLocal=Removing webapp [{0}] +farmWarDeployer.removeLocalFail=Unable to remove WAR file +farmWarDeployer.renameFail=Failed to rename [{0}] to [{1}] +farmWarDeployer.sendEnd=Send cluster war deployment path [{0}], war [{1}] finished. +farmWarDeployer.sendFragment=Send cluster war fragment path [{0}], war [{1}] to [{2}] +farmWarDeployer.sendStart=Send cluster war deployment path [{0}], war [{1}] started. +farmWarDeployer.servicingDeploy=Application [{0}] is being serviced. Touch war file [{1}] again! +farmWarDeployer.servicingUneploy=Application [{0}] is being serviced and can't be removed from backup cluster node +farmWarDeployer.started=Cluster FarmWarDeployer started. +farmWarDeployer.stopped=Cluster FarmWarDeployer stopped. +farmWarDeployer.undeployEnd=Undeployment from [{0}] finished. +farmWarDeployer.undeployLocal=Undeploy local context [{0}] +farmWarDeployer.watchDir=Cluster deployment is watching [{0}] for changes. Propchange: tomcat/trunk/java/org/apache/catalina/ha/deploy/LocalStrings.properties ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1059011&r1=1059010&r2=1059011&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Jan 14 14:01:20 2011 @@ -78,6 +78,13 @@ </update> </changelog> </subsection> + <subsection name="Cluster"> + <changelog> + <add> + Internationalise the log messages for the WarFarmDeployer. (markt) + </add> + </changelog> + </subsection> <subsection name="Web applications"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org