geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r779811 - in /geronimo/server/trunk: framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ plugins/hotdeploy/ger...
Date Fri, 29 May 2009 01:22:33 GMT
Author: djencks
Date: Fri May 29 01:22:32 2009
New Revision: 779811

URL: http://svn.apache.org/viewvc?rev=779811&view=rev
Log:
GERONIMO-3402 Apply patch from Lasantha Ranaweera, Replace deprecated DeployUtils with FileUtils

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
    geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
    geronimo/server/trunk/plugins/hotdeploy/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java?rev=779811&r1=779810&r2=779811&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/ConfigIDExtractor.java
Fri May 29 01:22:32 2009
@@ -232,19 +232,6 @@
         }
     }
 
-    /**
-     * Try to determine whether a file is a JAR File (or, at least, a ZIP file).
-     *
-     * @deprecated See org.apache.geronimo.common.FileUtils.isJarFile
-     */
-    public static boolean isJarFile(File file) throws DeploymentException {
-        try {
-            return FileUtils.isZipFile(file);
-        } catch (IOException e) {
-            throw new DeploymentException("Unable to read file "+file.getAbsolutePath(),
e);
-        }
-    }
-
     private static class ConfigIdHandler extends DefaultHandler {
         private String configId;
         private boolean inConfigId;

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java?rev=779811&r1=779810&r2=779811&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandDistribute.java
Fri May 29 01:22:32 2009
@@ -18,7 +18,6 @@
 package org.apache.geronimo.deployment.cli;
 
 import java.io.File;
-import java.io.PrintWriter;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
@@ -29,11 +28,12 @@
 import javax.enterprise.deploy.spi.TargetModuleID;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 
+import jline.ConsoleReader;
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.cli.deployer.DistributeCommandArgs;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.FileUtils;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
-import jline.ConsoleReader;
 
 /**
  * The CLI deployer logic to distribute.
@@ -70,47 +70,55 @@
             throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass()
+ "]; expected [" + DistributeCommandArgs.class + "]");
         }
         DistributeCommandArgs distributeCommandArgs = (DistributeCommandArgs) commandArgs;
-        
+
         BooleanHolder inPlaceHolder = new BooleanHolder();
         inPlaceHolder.inPlace = distributeCommandArgs.isInPlace();
-        
+
         List<String> targets = Arrays.asList(distributeCommandArgs.getTargets());
 
         String[] args = distributeCommandArgs.getArgs();
         File module = null;
         File plan = null;
-        if(args.length > 0) {
+        if (args.length > 0) {
             File test = new File(args[0]);
-            if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-                if(module != null) {
-                    throw new DeploymentSyntaxException("Module and plan cannot both be JAR
files or directories!");
-                }
-                module = test;
-            } else {
-                if(plan != null) {
-                    throw new DeploymentSyntaxException("Module or plan must be a JAR file
or directory!");
+            try {
+                if (FileUtils.isJarFile(test) || test.isDirectory()) {
+                    if (module != null) {
+                        throw new DeploymentSyntaxException("Module and plan cannot both
be JAR files or directories!");
+                    }
+                    module = test;
+                } else {
+                    if (plan != null) {
+                        throw new DeploymentSyntaxException("Module or plan must be a JAR
file or directory!");
+                    }
+                    plan = test;
                 }
-                plan = test;
+            } catch (IOException e) {
+                throw new DeploymentException("Invalid JAR file " + args[0]);
             }
         }
-        if(args.length > 1) {
+        if (args.length > 1) {
             File test = new File(args[1]);
-            if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-                if(module != null) {
-                    throw new DeploymentSyntaxException("Module and plan cannot both be JAR
files or directories!");
-                }
-                module = test;
-            } else {
-                if(plan != null) {
-                    throw new DeploymentSyntaxException("Module or plan must be a JAR file
or directory!");
+            try {
+                if (FileUtils.isJarFile(test) || test.isDirectory()) {
+                    if (module != null) {
+                        throw new DeploymentSyntaxException("Module and plan cannot both
be JAR files or directories!");
+                    }
+                    module = test;
+                } else {
+                    if (plan != null) {
+                        throw new DeploymentSyntaxException("Module or plan must be a JAR
file or directory!");
+                    }
+                    plan = test;
                 }
-                plan = test;
+            } catch (IOException e) {
+                throw new DeploymentException("Invalid JAR file " + args[1]);
             }
         }
-        if(module != null) {
+        if (module != null) {
             module = module.getAbsoluteFile();
         }
-        if(plan != null) {
+        if (plan != null) {
             plan = plan.getAbsoluteFile();
         }
         try {
@@ -144,13 +152,13 @@
 
         // print the results that succeeded
         results = po.getResultTargetModuleIDs();
-        for (int i = 0; i < results.length; i++) {
-            TargetModuleID result = results[i];
-            out.printString(DeployUtils.reformat(getAction()+" "+result.getModuleID()+(multipleTargets
? " to "+result.getTarget().getName() : "")+(result.getWebURL() == null || !getAction().equals("Deployed")
? "" : " @ "+result.getWebURL()), 4, 72));
-            if(result.getChildTargetModuleID() != null) {
+        for (TargetModuleID result : results) {
+            out.printString(DeployUtils.reformat(
+                    getAction() + " " + result.getModuleID() + (multipleTargets ? " to "
+ result.getTarget().getName() : "") + (result.getWebURL() == null || !getAction().equals("Deployed")
? "" : " @ " + result.getWebURL()), 4, 72));
+            if (result.getChildTargetModuleID() != null) {
                 for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                     TargetModuleID child = result.getChildTargetModuleID()[j];
-                    out.printString(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || !getAction().equals("Deployed") ? "" : " @ "+child.getWebURL()),4, 72));
+                    out.printString(DeployUtils.reformat("  `-> " + child.getModuleID()
+ (child.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ " + child.getWebURL()),
4, 72));
                 }
             }
         }

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java?rev=779811&r1=779810&r2=779811&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRedeploy.java
Fri May 29 01:22:32 2009
@@ -30,6 +30,7 @@
 
 import org.apache.geronimo.cli.deployer.CommandArgs;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.FileUtils;
 import org.apache.geronimo.kernel.repository.Artifact;
 import jline.ConsoleReader;
 
@@ -41,20 +42,20 @@
 public class CommandRedeploy extends AbstractCommand {
 
     public void execute(ConsoleReader consoleReader, ServerConnection connection, CommandArgs
commandArgs) throws DeploymentException {
-        ProgressObject po = null;
+        ProgressObject po;
         try {
             String[] args = commandArgs.getArgs();
 
             if (args.length == 0) {
                 throw new DeploymentSyntaxException("Must specify a module or plan (or both)
and optionally module IDs to replace");
             }
-            
+
             DeploymentManager mgr = connection.getDeploymentManager();
             Target[] allTargets = mgr.getTargets();
             TargetModuleID[] allModules;
             try {
                 allModules = mgr.getAvailableModules(null, allTargets);
-            } catch(TargetException e) {
+            } catch (TargetException e) {
                 throw new DeploymentException("Unable to load modules from server", e);
             }
 
@@ -62,78 +63,86 @@
             File module = null;
             File plan = null;
             File test = new File(args[0]); // Guess whether the first argument is a module
or a plan
-            if(!test.exists()) {
+            if (!test.exists()) {
                 throw new DeploymentSyntaxException("Module or plan file does not exist:
" + test.getAbsolutePath());
             }
-            if(!test.canRead()) {
-                throw new DeploymentException("Cannot read file "+test.getAbsolutePath());
+            if (!test.canRead()) {
+                throw new DeploymentException("Cannot read file " + test.getAbsolutePath());
             }
-            if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-                module = test;
-            } else {
-                plan = test;
+            try {
+                if (FileUtils.isJarFile(test) || test.isDirectory()) {
+                    module = test;
+                } else {
+                    plan = test;
+                }
+            } catch (IOException e) {
+                throw new DeploymentException("Invalid JAR File " + args[0]);
             }
-            if(args.length > 1) { // Guess whether the second argument is a module, plan,
ModuleID, or TargetModuleID
+            if (args.length > 1) { // Guess whether the second argument is a module, plan,
ModuleID, or TargetModuleID
                 test = new File(args[1]);
-                if(test.exists() && test.canRead() && !args[1].equals(args[0]))
{
-                    if(DeployUtils.isJarFile(test) || test.isDirectory()) {
-                        if(module != null) {
-                            throw new DeploymentSyntaxException("Module and plan cannot both
be JAR files or directories!");
-                        }
-                        module = test;
-                    } else {
-                        if(plan != null) {
-                            throw new DeploymentSyntaxException("Module or plan must be a
JAR file or directory!");
+                if (test.exists() && test.canRead() && !args[1].equals(args[0]))
{
+                    try {
+                        if (FileUtils.isJarFile(test) || test.isDirectory()) {
+                            if (module != null) {
+                                throw new DeploymentSyntaxException("Module and plan cannot
both be JAR files or directories!");
+                            }
+                            module = test;
+                        } else {
+                            if (plan != null) {
+                                throw new DeploymentSyntaxException("Module or plan must
be a JAR file or directory!");
+                            }
+                            plan = test;
                         }
-                        plan = test;
+                    } catch (IOException e) {
+                        throw new DeploymentException("Invalid JAR File " + args[1]);
                     }
                 } else {
                     modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[1],
false));
                 }
             }
-            for(int i=2; i<args.length; i++) { // Any arguments beyond 2 must be a ModuleID
or TargetModuleID
+            for (int i = 2; i < args.length; i++) { // Any arguments beyond 2 must be
a ModuleID or TargetModuleID
                 modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
             }
             // If we don't have any moduleIDs, try to guess one.
-            if(modules.size() == 0 && connection.isGeronimo()) {
-                emit(consoleReader, "No ModuleID or TargetModuleID provided.  Attempting
to guess based on the content of the "+(plan == null ? "archive" : "plan")+".");
+            if (modules.size() == 0 && connection.isGeronimo()) {
+                emit(consoleReader, "No ModuleID or TargetModuleID provided.  Attempting
to guess based on the content of the " + (plan == null ? "archive" : "plan") + ".");
                 String moduleId = null;
                 try {
-                    if(plan != null) {
+                    if (plan != null) {
                         moduleId = DeployUtils.extractModuleIdFromPlan(plan);
-                        if(moduleId == null) { // plan just doesn't have a config ID
+                        if (moduleId == null) { // plan just doesn't have a config ID
                             String fileName = module == null ? plan.getName() : module.getName();
                             int pos = fileName.lastIndexOf('.');
                             String artifactId = pos > -1 ? module.getName().substring(0,
pos) : module.getName();
-                            moduleId = Artifact.DEFAULT_GROUP_ID+"/"+artifactId+"//";
+                            moduleId = Artifact.DEFAULT_GROUP_ID + "/" + artifactId + "//";
                             emit(consoleReader, "Unable to locate Geronimo deployment plan
in archive.  Calculating default ModuleID from archive name.");
                         }
-                    } else if(module != null) {
+                    } else if (module != null) {
                         moduleId = DeployUtils.extractModuleIdFromArchive(module);
-                        if(moduleId == null) {
+                        if (moduleId == null) {
                             int pos = module.getName().lastIndexOf('.');
                             String artifactId = pos > -1 ? module.getName().substring(0,
pos) : module.getName();
-                            moduleId = Artifact.DEFAULT_GROUP_ID+"/"+artifactId+"//";
+                            moduleId = Artifact.DEFAULT_GROUP_ID + "/" + artifactId + "//";
                             emit(consoleReader, "Unable to locate Geronimo deployment plan
in archive.  Calculating default ModuleID from archive name.");
                         }
                     }
                 } catch (IOException e) {
-                    throw new DeploymentException("Unable to read input files: "+e.getMessage(),
e);
+                    throw new DeploymentException("Unable to read input files: " + e.getMessage(),
e);
                 }
-                if(moduleId != null) {
-                    emit(consoleReader, "Attempting to use ModuleID '"+moduleId+"'");
+                if (moduleId != null) {
+                    emit(consoleReader, "Attempting to use ModuleID '" + moduleId + "'");
                     modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId,
true));
                 } else {
                     emit(consoleReader, "Unable to calculate a ModuleID from supplied module
and/or plan.");
                 }
             }
-            if(modules.size() == 0) { // Either not deploying to Geronimo or unable to identify
modules
+            if (modules.size() == 0) { // Either not deploying to Geronimo or unable to identify
modules
                 throw new DeploymentSyntaxException("No ModuleID or TargetModuleID available.
 Nothing to do.  Maybe you should add a ModuleID or TargetModuleID to the command line?");
             }
-            if(module != null) {
+            if (module != null) {
                 module = module.getAbsoluteFile();
             }
-            if(plan != null) {
+            if (plan != null) {
                 plan = plan.getAbsoluteFile();
             }
             // Now that we've sorted out all the arguments, do the work
@@ -142,21 +151,20 @@
             po = mgr.redeploy(ids, module, plan);
             waitForProgress(consoleReader, po);
             TargetModuleID[] done = po.getResultTargetModuleIDs();
-            for(int i = 0; i < done.length; i++) {
-                TargetModuleID id = done[i];
-                emit(consoleReader, "Redeployed "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName()
: "")+(id.getWebURL() == null ? "" : " @ "+id.getWebURL()));
-                if(id.getChildTargetModuleID() != null) {
+            for (TargetModuleID id : done) {
+                emit(consoleReader, "Redeployed " + id.getModuleID() + (multiple ? " on "
+ id.getTarget().getName() : "") + (id.getWebURL() == null ? "" : " @ " + id.getWebURL()));
+                if (id.getChildTargetModuleID() != null) {
                     for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
                         TargetModuleID child = id.getChildTargetModuleID()[j];
-                        emit(consoleReader, "  `-> "+child.getModuleID()+(child.getWebURL()
== null ? "" : " @ "+child.getWebURL()));
+                        emit(consoleReader, "  `-> " + child.getModuleID() + (child.getWebURL()
== null ? "" : " @ " + child.getWebURL()));
                     }
                 }
             }
         } catch (IOException e) {
             throw new DeploymentException("Could not write to console", e);
         }
-        if(po.getDeploymentStatus().isFailed()) {
-            throw new DeploymentException("Operation failed: "+po.getDeploymentStatus().getMessage());
+        if (po.getDeploymentStatus().isFailed()) {
+            throw new DeploymentException("Operation failed: " + po.getDeploymentStatus().getMessage());
         }
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java?rev=779811&r1=779810&r2=779811&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
Fri May 29 01:22:32 2009
@@ -31,6 +31,7 @@
 
 import org.apache.geronimo.cli.deployer.ConnectionParams;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.FileUtils;
 import org.apache.geronimo.deployment.cli.DeployUtils.SavedAuthentication;
 import org.apache.geronimo.deployment.plugin.factories.AuthenticationFailedException;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
@@ -162,8 +163,12 @@
 
     private void loadDriver(String driver, DeploymentFactoryManager mgr) throws DeploymentException
{
         File file = new File(driver);
-        if (!file.exists() || !file.canRead() || !DeployUtils.isJarFile(file)) {
-            throw new DeploymentSyntaxException("Driver '" + file.getAbsolutePath() + "'
is not a readable JAR file");
+        try {
+            if (!file.exists() || !file.canRead() || !FileUtils.isJarFile(file)) {
+                throw new DeploymentSyntaxException("Driver '" + file.getAbsolutePath() +
"' is not a readable JAR file");
+            }
+        } catch (IOException e) {
+            throw new DeploymentException("Driver '" + file.getAbsolutePath() + "' is not
a readable JAR file");
         }
         String className = null;
         try {

Modified: geronimo/server/trunk/plugins/hotdeploy/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/hotdeploy/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java?rev=779811&r1=779810&r2=779811&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/hotdeploy/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
(original)
+++ geronimo/server/trunk/plugins/hotdeploy/geronimo-hot-deploy/src/main/java/org/apache/geronimo/deployment/hot/DirectoryHotDeployer.java
Fri May 29 01:22:32 2009
@@ -17,6 +17,7 @@
 package org.apache.geronimo.deployment.hot;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -30,6 +31,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.common.FileUtils;
 import org.apache.geronimo.deployment.cli.DeployUtils;
 import org.apache.geronimo.deployment.plugin.factories.DeploymentFactoryWithKernel;
 import org.apache.geronimo.deployment.plugin.jmx.JMXDeploymentManager;
@@ -269,7 +271,8 @@
             targets = new Target[] {targets[0]};
 
             ProgressObject po;
-            if (DeployUtils.isJarFile(file) || file.isDirectory()) {
+
+            if (FileUtils.isJarFile(file) || file.isDirectory()) {
                 po = mgr.distribute(targets, file, null);
             } else {
                 po = mgr.distribute(targets, null, file);
@@ -318,8 +321,7 @@
             }
         } catch (DeploymentManagerCreationException e) {
             log.error("Unable to open deployer", e);
-            return null;
-        } catch (DeploymentException e) {
+        } catch (IOException e) {
             log.error("Unable to determine if file is a jar", e);
         } finally {
             if (mgr != null) mgr.release();
@@ -409,7 +411,7 @@
             TargetModuleID[] ids = mgr.getAvailableModules(null, targets);
             ids = (TargetModuleID[]) DeployUtils.identifyTargetModuleIDs(ids, configId, true).toArray(new
TargetModuleID[0]);
             ProgressObject po;
-            if (DeployUtils.isJarFile(file) || file.isDirectory()) {
+            if (FileUtils.isJarFile(file) || file.isDirectory()) {
                 po = mgr.redeploy(ids, file, null);
             } else {
                 po = mgr.redeploy(ids, null, file);



Mime
View raw message