From: markt Date: Fri, 14 Jan 2011 14:01:20 +0000 (+0000) Subject: i18n X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b97ee5c1a0a5ac3a1ef3edad81621c04bd9f1567;p=tomcat7.0 i18n git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1059011 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/ha/deploy/Constants.java b/java/org/apache/catalina/ha/deploy/Constants.java new file mode 100644 index 000000000..084c207fd --- /dev/null +++ b/java/org/apache/catalina/ha/deploy/Constants.java @@ -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 org.apache.catalina.ha.deploy + * package. + */ +public class Constants { + + public static final String Package = "org.apache.catalina.ha.deploy"; + +} diff --git a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java index 755c346d1..3bdf38fe4 100644 --- a/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java +++ b/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java @@ -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.Registry; * @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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, // 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, } 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, * 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, /* * 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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 ClusterListener implements ClusterDeployer, 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; diff --git a/java/org/apache/catalina/ha/deploy/LocalStrings.properties b/java/org/apache/catalina/ha/deploy/LocalStrings.properties new file mode 100644 index 000000000..216a025b3 --- /dev/null +++ b/java/org/apache/catalina/ha/deploy/LocalStrings.properties @@ -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. diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 3cdbb2821..e7c80b80f 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -78,6 +78,13 @@ + + + + Internationalise the log messages for the WarFarmDeployer. (markt) + + +