Code clean up in o.a.c.h.deploy
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 26 Sep 2008 12:20:03 +0000 (12:20 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 26 Sep 2008 12:20:03 +0000 (12:20 +0000)
No functional change

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@699296 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
java/org/apache/catalina/ha/deploy/WarWatcher.java

index 4b65259..aa6ceb6 100644 (file)
@@ -70,7 +70,8 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
 
     protected boolean started = false; //default 5 seconds
 
-    protected HashMap fileFactories = new HashMap();
+    protected HashMap<String, FileMessageFactory> fileFactories =
+        new HashMap<String, FileMessageFactory>();
 
     protected String deployDir;
 
@@ -212,7 +213,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
      */
     public void messageReceived(ClusterMessage msg) {
         try {
-            if (msg instanceof FileMessage && msg != null) {
+            if (msg instanceof FileMessage) {
                 FileMessage fmsg = (FileMessage) msg;
                 if (log.isDebugEnabled())
                     log.debug("receive cluster deployment [ path: "
@@ -250,7 +251,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
                         removeFactory(fmsg);
                     }
                 }
-            } else if (msg instanceof UndeployMessage && msg != null) {
+            } else if (msg instanceof UndeployMessage) {
                 try {
                     UndeployMessage umsg = (UndeployMessage) msg;
                     String path = umsg.getContextPath();
@@ -291,8 +292,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
             throws java.io.FileNotFoundException, java.io.IOException {
         File tmpFile = new File(msg.getFileName());
         File writeToFile = new File(getTempDir(), tmpFile.getName());
-        FileMessageFactory factory = (FileMessageFactory) fileFactories.get(msg
-                .getFileName());
+        FileMessageFactory factory = fileFactories.get(msg.getFileName());
         if (factory == null) {
             factory = FileMessageFactory.getInstance(writeToFile, true);
             fileFactories.put(msg.getFileName(), factory);
@@ -450,7 +450,7 @@ public class FarmWarDeployer extends ClusterListener implements ClusterDeployer,
             } catch (Exception x) {
                 log.error("No removal", x);
             }
-            install(contextName, deployWar.toURL());
+            install(contextName, deployWar.toURI().toURL());
         } catch (Exception x) {
             log.error("Unable to install WAR file", x);
         }
index beb7636..479c4af 100644 (file)
@@ -54,7 +54,8 @@ public class WarWatcher {
     /**
      * Currently deployed files
      */
-    protected Map currentStatus = new HashMap();
+    protected Map<String, WarInfo> currentStatus =
+        new HashMap<String, WarInfo>();
 
     /*--Constructor---------------------------------------------*/
 
@@ -83,9 +84,10 @@ public class WarWatcher {
         }
 
         //check all the status codes and update the FarmDeployer
-        for (Iterator i = currentStatus.entrySet().iterator(); i.hasNext();) {
-            Map.Entry entry = (Map.Entry) i.next();
-            WarInfo info = (WarInfo) entry.getValue();
+        for (Iterator<Map.Entry<String,WarInfo>> i =
+                currentStatus.entrySet().iterator(); i.hasNext();) {
+            Map.Entry<String,WarInfo> entry = i.next();
+            WarInfo info = entry.getValue();
             int check = info.check();
             if (check == 1) {
                 listener.fileModified(info.getWar());
@@ -103,7 +105,7 @@ public class WarWatcher {
      * @param warfile
      */
     protected void addWarInfo(File warfile) {
-        WarInfo info = (WarInfo) currentStatus.get(warfile.getAbsolutePath());
+        WarInfo info = currentStatus.get(warfile.getAbsolutePath());
         if (info == null) {
             info = new WarInfo(warfile);
             info.setLastState(-1); //assume file is non existent