You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2010/04/08 08:30:17 UTC
svn commit: r931793 - in /geronimo/server/trunk/framework/modules:
geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/
geronimo-deploy-tool/
geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/
Author: xuhaihong
Date: Thu Apr 8 06:30:16 2010
New Revision: 931793
URL: http://svn.apache.org/viewvc?rev=931793&view=rev
Log:
Use jline from karaf-shell in gerronimo-deploy-tool, also some codes clean up
Removed:
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/InputPrompt.java
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/pom.xml
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.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/CommandRestart.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ConsoleReader.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ServerConnection.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StreamConsoleReader.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=931793&r1=931792&r2=931793&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 Thu Apr 8 06:30:16 2010
@@ -170,8 +170,8 @@ public class ConfigIDExtractor {
*
* @throws DeploymentException If no TargetModuleIDs have that module.
*/
- public static Collection identifyTargetModuleIDs(TargetModuleID[] allModules, String name, boolean fromPlan) throws DeploymentException {
- List list = new LinkedList();
+ public static Collection<TargetModuleID> identifyTargetModuleIDs(TargetModuleID[] allModules, String name, boolean fromPlan) throws DeploymentException {
+ List<TargetModuleID> list = new LinkedList<TargetModuleID>();
int pos;
if((pos = name.indexOf('|')) > -1) {
String target = name.substring(0, pos);
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/pom.xml?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/pom.xml (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/pom.xml Thu Apr 8 06:30:16 2010
@@ -56,10 +56,10 @@
<artifactId>geronimo-deploy-jsr88</artifactId>
<version>${version}</version>
</dependency>
-
+
<dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jline</artifactId>
+ <groupId>org.apache.felix.karaf.shell</groupId>
+ <artifactId>org.apache.felix.karaf.shell.console</artifactId>
</dependency>
</dependencies>
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/AbstractCommand.java Thu Apr 8 06:30:16 2010
@@ -18,7 +18,6 @@
package org.apache.geronimo.deployment.cli;
import java.io.IOException;
-import java.io.OutputStreamWriter;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -92,7 +91,7 @@ public abstract class AbstractCommand im
}
protected static boolean isMultipleTargets(TargetModuleID[] ids) {
- Set set = new HashSet();
+ Set<String> set = new HashSet<String>();
for (int i = 0; i < ids.length; i++) {
TargetModuleID id = ids[i];
set.add(id.getTarget().getName());
@@ -100,11 +99,11 @@ public abstract class AbstractCommand im
return set.size() > 1;
}
- protected static Target[] identifyTargets(List targetNames, final DeploymentManager mgr) throws DeploymentException {
+ protected static Target[] identifyTargets(List<String> targetNames, final DeploymentManager mgr) throws DeploymentException {
//TODO consider if nicknames that match multiple servers should be allowed. Also if regexps should be used in matching
Target[] tlist = new Target[targetNames.size()];
Target[] all = mgr.getTargets();
- Set found = new HashSet();
+ Set<String> found = new HashSet<String>();
for (int i = 0; i < tlist.length; i++) {
for (int j = 0; j < all.length; j++) {
Target server = all[j];
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallCAR.java Thu Apr 8 06:30:16 2010
@@ -21,7 +21,6 @@ import java.io.IOException;
import javax.enterprise.deploy.spi.DeploymentManager;
-import org.apache.geronimo.cli.deployer.BaseCommandArgs;
import org.apache.geronimo.cli.deployer.CommandArgs;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.deployment.plugin.GeronimoDeploymentManager;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandInstallLibrary.java Thu Apr 8 06:30:16 2010
@@ -18,7 +18,6 @@
package org.apache.geronimo.deployment.cli;
import java.io.File;
-import java.io.PrintWriter;
import javax.enterprise.deploy.spi.DeploymentManager;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListConfigurations.java Thu Apr 8 06:30:16 2010
@@ -28,8 +28,8 @@ import java.util.TreeSet;
import javax.enterprise.deploy.shared.ModuleType;
import javax.enterprise.deploy.spi.DeploymentManager;
-import javax.enterprise.deploy.spi.exceptions.TargetException;
import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.TargetException;
import javax.security.auth.login.FailedLoginException;
import org.apache.geronimo.cli.deployer.CommandArgs;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandListModules.java Thu Apr 8 06:30:16 2010
@@ -17,7 +17,6 @@
package org.apache.geronimo.deployment.cli;
-import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
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=931793&r1=931792&r2=931793&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 Thu Apr 8 06:30:16 2010
@@ -142,7 +142,7 @@ public class CommandRedeploy extends Abs
}
if (args.length >= 3 && args[0].equalsIgnoreCase("--targets")) // case of cluster redeployment
{
- List modules = new ArrayList();
+ List<TargetModuleID> modules = new ArrayList<TargetModuleID>();
boolean multipleTargets;
File test = null;
File test1 = null;
@@ -201,18 +201,19 @@ public class CommandRedeploy extends Abs
List<String> targets = Arrays.asList(distributeCommandArgs.getTargets());
if (targets.size() > 0) {
- Target[] tlist = identifyTargets(targets, mgr); // before starting undeployment and deployment verify the correctness of target argument
+ //Target[] tlist = identifyTargets(targets, mgr);
+ // before starting undeployment and deployment verify the correctness of target argument
}
if (modules.size() == 0) {
String moduleId = guessModuleId(modules, connection, consoleReader, plan, module, allModules);
modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId, false));
}
- TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
- boolean multiple = isMultipleTargets(ids);
+ TargetModuleID[] ids = modules.toArray(new TargetModuleID[modules.size()]);
+ //boolean multiple = isMultipleTargets(ids);
po = mgr.undeploy(ids);
waitForProgress(consoleReader, po);
- TargetModuleID[] done = po.getResultTargetModuleIDs();
+ //TargetModuleID[] done = po.getResultTargetModuleIDs();
if (targets.size() > 0) {
Target[] tlist = identifyTargets(targets, mgr);
@@ -280,7 +281,7 @@ public class CommandRedeploy extends Abs
throw new DeploymentException("Operation failed: " + po.getDeploymentStatus().getMessage());
}
} else { // case of local redeployment
- List modules = new ArrayList();
+ List<TargetModuleID> modules = new ArrayList<TargetModuleID>();
File module = null;
File plan = null;
File test = new File(args[0]); // Guess whether the first argument is a module or a plan
@@ -365,7 +366,7 @@ public class CommandRedeploy extends Abs
plan = plan.getAbsoluteFile();
}
// Now that we've sorted out all the arguments, do the work
- TargetModuleID[] ids = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
+ TargetModuleID[] ids = modules.toArray(new TargetModuleID[modules.size()]);
boolean multiple = isMultipleTargets(ids);
po = mgr.redeploy(ids, module, plan);
waitForProgress(consoleReader, po);
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandRestart.java Thu Apr 8 06:30:16 2010
@@ -16,8 +16,6 @@
*/
package org.apache.geronimo.deployment.cli;
-import java.io.PrintWriter;
-
import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.status.ProgressObject;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java Thu Apr 8 06:30:16 2010
@@ -17,7 +17,6 @@
package org.apache.geronimo.deployment.cli;
-import java.io.PrintWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStop.java Thu Apr 8 06:30:16 2010
@@ -17,8 +17,6 @@
package org.apache.geronimo.deployment.cli;
-import java.io.PrintWriter;
-
import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.status.ProgressObject;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandUndeploy.java Thu Apr 8 06:30:16 2010
@@ -17,8 +17,6 @@
package org.apache.geronimo.deployment.cli;
-import java.io.PrintWriter;
-
import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.TargetModuleID;
import javax.enterprise.deploy.spi.status.ProgressObject;
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ConsoleReader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ConsoleReader.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ConsoleReader.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/ConsoleReader.java Thu Apr 8 06:30:16 2010
@@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.geronimo.deployment.cli;
+
import java.io.IOException;
/**
@@ -22,6 +24,7 @@ import java.io.IOException;
* and a console.
*/
public interface ConsoleReader {
+
/**
* Print an end-of-line marker.
*
@@ -47,7 +50,6 @@ public interface ConsoleReader {
*/
void println(String s) throws IOException;
-
/**
* Read a line from the console.
*
@@ -56,7 +58,6 @@ public interface ConsoleReader {
*/
String readLine() throws IOException;
-
/**
* Read a line from the console with a prompt.
*
@@ -67,12 +68,23 @@ public interface ConsoleReader {
*/
String readLine(String prompt) throws IOException;
-
/**
* Flush any pending writes to the console.
*
* @exception IOException
*/
void flushConsole() throws IOException;
-}
+ /**
+ * Read a line from the console without echo
+ * @return
+ */
+ String readPassword() throws IOException;
+
+ /**
+ * Read a line from the console without echo
+ * @param prompt The prompt string used for the reading.
+ * @return
+ */
+ String readPassword(String prompt) throws IOException;
+}
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployCommand.java Thu Apr 8 06:30:16 2010
@@ -20,10 +20,6 @@ package org.apache.geronimo.deployment.c
import org.apache.geronimo.cli.deployer.CommandArgs;
import org.apache.geronimo.common.DeploymentException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.BufferedReader;
-
/**
* An abstraction of various CLI deployer commands.
*
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/DeployTool.java Thu Apr 8 06:30:16 2010
@@ -21,9 +21,6 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.util.Arrays;
import java.util.IdentityHashMap;
import java.util.Iterator;
@@ -32,7 +29,6 @@ import java.util.List;
import javax.enterprise.deploy.spi.factories.DeploymentFactory;
-
import org.apache.geronimo.cli.deployer.CommandArgs;
import org.apache.geronimo.cli.deployer.CommandFileCommandMetaData;
import org.apache.geronimo.cli.deployer.CommandMetaData;
@@ -112,15 +108,14 @@ public class DeployTool implements Main
this.kernel = kernel;
this.deploymentFactory = deploymentFactory;
}
-
+
public int execute(Object opaque) {
if (! (opaque instanceof DeployerCLParser)) {
throw new IllegalArgumentException("Argument type is [" + opaque.getClass() + "]; expected [" + DeployerCLParser.class + "]");
}
DeployerCLParser parser = (DeployerCLParser) opaque;
-
- PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out), true);
- InputStream in = System.in;
+
+ ConsoleReader consoleReader = new StreamConsoleReader(System.in, System.out);
CommandMetaData commandMetaData = parser.getCommandMetaData();
CommandArgs commandArgs = parser.getCommandArgs();
@@ -129,7 +124,7 @@ public class DeployTool implements Main
String arg = commandArgs.getArgs()[0];
File source = new File(arg);
if(!source.exists() || !source.canRead() || source.isDirectory()) {
- processException(out, new DeploymentSyntaxException("Cannot read command file "+source.getAbsolutePath()));
+ processException(new DeploymentSyntaxException("Cannot read command file "+source.getAbsolutePath()));
} else {
try {
BufferedReader commands = new BufferedReader(new FileReader(source));
@@ -148,53 +143,58 @@ public class DeployTool implements Main
}
failed = oneFailed;
} catch (IOException e) {
- processException(out, new DeploymentException("Unable to read command file", e));
+ processException(new DeploymentException("Unable to read command file", e));
} finally {
try {
con.close();
} catch (DeploymentException e) {
- processException(out, e);
+ processException(e);
}
}
}
} else {
DeployCommand dc = commands.get(commandMetaData);
if(dc == null) {
- out.println();
- processException(out, new DeploymentSyntaxException("No such command: '"+commandMetaData+"'"));
+ try {
+ consoleReader.printNewline();
+ } catch (IOException e) {
+ }
+ processException(new DeploymentSyntaxException("No such command: '"+commandMetaData+"'"));
} else {
try {
- if(con == null) {
- con = new ServerConnection(parser, out, in, kernel, deploymentFactory);
+ if (con == null) {
+ con = new ServerConnection(parser, consoleReader, kernel, deploymentFactory);
}
try {
- dc.execute(new StreamConsoleReader(in, out), con, commandArgs);
+ dc.execute(consoleReader, con, commandArgs);
} catch (DeploymentSyntaxException e) {
- processException(out, e);
+ processException( e);
} catch (DeploymentException e) {
- processException(out, e);
+ processException(e);
} finally {
if(!multipleCommands) {
try {
con.close();
} catch(DeploymentException e) {
- processException(out, e);
+ processException(e);
}
}
}
} catch(DeploymentException e) {
- processException(out, e);
+ processException(e);
}
}
}
- out.flush();
- System.out.flush();
+ try {
+ consoleReader.flushConsole();
+ } catch (IOException e) {
+ }
return failed ? 1 : 0;
}
public static String[] splitCommand(String line) {
String[] chunks = line.split("\"");
- List list = new LinkedList();
+ List<String> list = new LinkedList<String>();
for (int i = 0; i < chunks.length; i++) {
String chunk = chunks[i];
if(i % 2 == 1) { // it's in quotes
@@ -203,16 +203,16 @@ public class DeployTool implements Main
list.addAll(Arrays.asList(chunk.split("\\s")));
}
}
- for (Iterator it = list.iterator(); it.hasNext();) {
- String test = (String) it.next();
+ for (Iterator<String> it = list.iterator(); it.hasNext();) {
+ String test = it.next();
if(test.trim().equals("")) {
it.remove();
}
}
- return (String[]) list.toArray(new String[list.size()]);
+ return list.toArray(new String[list.size()]);
}
- private void processException(PrintWriter out, Exception e) {
+ private void processException(Exception e) {
failed = true;
log.error("Error: ", e);
}
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=931793&r1=931792&r2=931793&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 Thu Apr 8 06:30:16 2010
@@ -20,8 +20,6 @@ package org.apache.geronimo.deployment.c
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
import java.io.Serializable;
import java.util.Properties;
import java.util.jar.JarFile;
@@ -45,7 +43,7 @@ import org.apache.geronimo.kernel.util.J
/**
* Supports online connections to the server, via JSR-88, valid only when the
* server is online.
- *
+ *
* @version $Rev$ $Date$
*/
public class ServerConnection {
@@ -53,29 +51,33 @@ public class ServerConnection {
private final DeploymentFactory geronimoDeploymentFactory;
private DeploymentManager manager;
+
private UsernamePasswordHandler handler;
+
private SavedAuthentication auth;
+
private boolean logToSysErr;
+
private boolean verboseMessages;
+
String KEYSTORE_TRUSTSTORE_PASSWORD_FILE = "org.apache.geronimo.keyStoreTrustStorePasswordFile";
+
String DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION = "/var/security/keystores/geronimo-default";
+
String GERONIMO_HOME = "org.apache.geronimo.home.dir";
- String DEFAULT_KEYSTORE_TRUSTSTORE_PASSWORD_FILE = System.getProperty(GERONIMO_HOME)
- + "/var/config/config-substitutions.properties";
- public ServerConnection(ConnectionParams params, PrintWriter out, InputStream in, Kernel kernel,
- DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
- this(params, new DefaultUserPasswordHandler(in, out), kernel, geronimoDeploymentFactory);
+ String DEFAULT_KEYSTORE_TRUSTSTORE_PASSWORD_FILE = System.getProperty(GERONIMO_HOME) + "/var/config/config-substitutions.properties";
+
+ public ServerConnection(ConnectionParams params, ConsoleReader consoleReader, Kernel kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
+ this(params, new DefaultUserPasswordHandler(consoleReader), kernel, geronimoDeploymentFactory);
}
- public ServerConnection(ConnectionParams params, UsernamePasswordHandler handler, Kernel kernel,
- DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
+ public ServerConnection(ConnectionParams params, UsernamePasswordHandler handler, Kernel kernel, DeploymentFactory geronimoDeploymentFactory) throws DeploymentException {
if (null == kernel) {
throw new IllegalArgumentException("kernel is required");
}
this.geronimoDeploymentFactory = geronimoDeploymentFactory;
this.handler = handler;
-
String uri = params.getURI();
String driver = params.getDriver();
String user = params.getUser();
@@ -86,7 +88,6 @@ public class ServerConnection {
logToSysErr = params.isSyserr();
boolean offline = params.isOffline();
boolean secure = params.isSecure();
-
if ((driver != null) && uri == null) {
throw new DeploymentSyntaxException("A custom driver requires a custom URI");
}
@@ -101,14 +102,10 @@ public class ServerConnection {
throw new DeploymentException(e);
}
} else {
-
ClassLoader OldCL = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(DeployUtils.class.getClassLoader());
-
tryToConnect(uri, driver, user, password, secure);
-
Thread.currentThread().setContextClassLoader(OldCL);
-
}
if (manager == null) {
throw new DeploymentException("Unexpected error; connection failed.");
@@ -138,8 +135,7 @@ public class ServerConnection {
return (auth == null) ? null : auth.getURI();
}
- private void tryToConnect(String argURI, String driver, String user, String password, boolean secure)
- throws DeploymentException {
+ private void tryToConnect(String argURI, String driver, String user, String password, boolean secure) throws DeploymentException {
DeploymentFactoryManager mgr = DeploymentFactoryManager.getInstance();
if (driver != null) {
loadDriver(driver, mgr);
@@ -147,7 +143,6 @@ public class ServerConnection {
mgr.registerDeploymentFactory(geronimoDeploymentFactory);
}
String useURI = argURI == null ? DeployUtils.getConnectionURI(null, null, secure) : argURI;
-
if (user == null && password == null) {
try {
SavedAuthentication savedAuthentication = DeployUtils.readSavedCredentials(useURI);
@@ -159,27 +154,18 @@ public class ServerConnection {
System.out.println("Warning: " + e.getMessage());
}
}
-
if (secure) {
try {
Properties props = new Properties();
-
String keyStorePassword = null;
String trustStorePassword = null;
-
- FileInputStream fstream = new FileInputStream(System.getProperty(KEYSTORE_TRUSTSTORE_PASSWORD_FILE,
- DEFAULT_KEYSTORE_TRUSTSTORE_PASSWORD_FILE));
+ FileInputStream fstream = new FileInputStream(System.getProperty(KEYSTORE_TRUSTSTORE_PASSWORD_FILE, DEFAULT_KEYSTORE_TRUSTSTORE_PASSWORD_FILE));
props.load(fstream);
-
keyStorePassword = (String) EncryptionManager.decrypt(props.getProperty("keyStorePassword"));
trustStorePassword = (String) EncryptionManager.decrypt(props.getProperty("trustStorePassword"));
-
fstream.close();
-
- String value = System.getProperty("javax.net.ssl.keyStore", System.getProperty(GERONIMO_HOME)
- + DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
- String value1 = System.getProperty("javax.net.ssl.trustStore", System.getProperty(GERONIMO_HOME)
- + DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
+ String value = System.getProperty("javax.net.ssl.keyStore", System.getProperty(GERONIMO_HOME) + DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
+ String value1 = System.getProperty("javax.net.ssl.trustStore", System.getProperty(GERONIMO_HOME) + DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION);
System.setProperty("javax.net.ssl.keyStore", value);
System.setProperty("javax.net.ssl.trustStore", value1);
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
@@ -209,7 +195,6 @@ public class ServerConnection {
} catch (DeploymentManagerCreationException e) {
throw new DeploymentException("Unable to connect to server at " + useURI + " -- " + e.getMessage(), e);
}
-
if (manager instanceof JMXDeploymentManager) {
JMXDeploymentManager deploymentManager = (JMXDeploymentManager) manager;
deploymentManager.setLogConfiguration(logToSysErr, verboseMessages);
@@ -230,8 +215,7 @@ public class ServerConnection {
JarFile jar = new JarFile(file);
className = jar.getManifest().getMainAttributes().getValue("J2EE-DeploymentFactory-Implementation-Class");
if (className == null) {
- throw new DeploymentException("The driver JAR " + file.getAbsolutePath()
- + " does not specify a J2EE-DeploymentFactory-Implementation-Class; cannot load driver.");
+ throw new DeploymentException("The driver JAR " + file.getAbsolutePath() + " does not specify a J2EE-DeploymentFactory-Implementation-Class; cannot load driver.");
}
jar.close();
DeploymentFactory factory = (DeploymentFactory) Class.forName(className).newInstance();
@@ -239,8 +223,7 @@ public class ServerConnection {
} catch (DeploymentException e) {
throw e;
} catch (Exception e) {
- throw new DeploymentSyntaxException("Unable to load driver class " + className + " from JAR "
- + file.getAbsolutePath(), e);
+ throw new DeploymentSyntaxException("Unable to load driver class " + className + " from JAR " + file.getAbsolutePath(), e);
}
}
@@ -253,6 +236,7 @@ public class ServerConnection {
}
public static interface UsernamePasswordHandler {
+
String getUsername() throws IOException;
String getPassword() throws IOException;
@@ -260,28 +244,18 @@ public class ServerConnection {
private static class DefaultUserPasswordHandler implements UsernamePasswordHandler {
- private PrintWriter out;
- private InputStream in;
- private InputPrompt prompt;
+ private ConsoleReader consoleReader;
- public DefaultUserPasswordHandler(InputStream in, PrintWriter out) {
- this.out = out;
- this.in = in;
- }
-
- private void initPrompt() throws IOException {
- this.prompt = new InputPrompt(this.in, this.out);
+ public DefaultUserPasswordHandler(ConsoleReader consoleReader) {
+ this.consoleReader = consoleReader;
}
public String getPassword() throws IOException {
- initPrompt();
- return this.prompt.getPassword("Password: ");
+ return new String(consoleReader.readPassword("Password: "));
}
public String getUsername() throws IOException {
- initPrompt();
- return this.prompt.getInput("Username: ");
+ return consoleReader.readLine("Username: ");
}
-
}
}
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StopServer.java Thu Apr 8 06:30:16 2010
@@ -33,8 +33,8 @@ import javax.management.remote.JMXServic
import javax.management.remote.rmi.RMIConnectorServer;
import javax.rmi.ssl.SslRMIClientSocketFactory;
-import org.apache.geronimo.crypto.EncryptionManager;
import org.apache.geronimo.cli.shutdown.ShutdownCLParser;
+import org.apache.geronimo.crypto.EncryptionManager;
import org.apache.geronimo.deployment.cli.DeployUtils.SavedAuthentication;
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -49,14 +49,14 @@ public class StopServer implements Main,
public static final String DEFAULT_PORT = "1099"; // 1099 is used by java.rmi.registry.Registry
- private String host;
+ private String host;
private Integer port;
private String user;
- private String password;
+ private String password;
private boolean secure;
private final Bundle bundle;
- private String[] args;
+
String KEYSTORE_TRUSTSTORE_PASSWORD_FILE = "org.apache.geronimo.keyStoreTrustStorePasswordFile";
String DEFAULT_TRUSTSTORE_KEYSTORE_LOCATION = "/var/security/keystores/geronimo-default";
String GERONIMO_HOME = "org.apache.geronimo.home.dir";
@@ -77,16 +77,16 @@ public class StopServer implements Main,
if (port == null) {
port = new Integer(DEFAULT_PORT);
}
-
+
host = parser.getHost();
if (host == null) {
host = "localhost";
}
secure = parser.isSecure();
-
+
if(secure){
-
+
try {
Properties props = new Properties();
@@ -116,13 +116,13 @@ public class StopServer implements Main,
System.out.println("Unable to set KeyStorePassword and TrustStorePassword");
e.printStackTrace();
}
-
+
}
-
+
user = parser.getUser();
-
+
password = parser.getPassword();
-
+
if (user == null && password == null) {
String uri = DeployUtils.getConnectionURI(host, port, secure);
try {
@@ -138,19 +138,19 @@ public class StopServer implements Main,
if (user == null || password == null) {
try {
- InputPrompt prompt = new InputPrompt(System.in, System.out);
+ ConsoleReader consoleReader = new StreamConsoleReader(System.in, System.out);
if (user == null) {
- user = prompt.getInput("Username: ");
+ user = consoleReader.readLine("Username: ");
}
if (password == null) {
- password = prompt.getPassword("Password: ");
+ password = new String(consoleReader.readPassword("Password: "));
}
- } catch (IOException e) {
+ } catch (Exception e) {
System.out.println("Unable to prompt for login.");
return 1;
}
}
-
+
System.out.print("Locating server on " + host + ":" + port + "... ");
MBeanServerConnection conn = null;
try {
@@ -160,20 +160,20 @@ public class StopServer implements Main,
return 1;
}
if (conn != null) {
- System.out.println("Server found.");
+ System.out.println("Server found.");
try {
shutdown(conn);
} catch (Exception e) {
System.err.println("Error shutting down the server");
e.printStackTrace();
return 2;
- }
+ }
}
return 0;
}
public MBeanServerConnection getMBeanServerConnection() throws Exception {
- Map map = new HashMap();
+ Map<String, Object> map = new HashMap<String, Object>();
map.put(JMXConnector.CREDENTIALS, new String[] { user, password });
String connectorName = "/JMXConnector";
if (secure) {
@@ -184,17 +184,17 @@ public class StopServer implements Main,
JMXServiceURL address = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://" + host + ":" + port + connectorName);
JMXConnector jmxConnector = JMXConnectorFactory.connect(address, map);
- return jmxConnector.getMBeanServerConnection();
+ return jmxConnector.getMBeanServerConnection();
}
-
- public void shutdown(MBeanServerConnection mbServerConnection) throws Exception {
- Set<ObjectName> objectNameSet =
+
+ public void shutdown(MBeanServerConnection mbServerConnection) throws Exception {
+ Set<ObjectName> objectNameSet =
mbServerConnection.queryNames(new ObjectName("osgi.core:type=framework,*"), null);
if (objectNameSet.isEmpty()) {
throw new Exception("Framework mbean not found");
} else if (objectNameSet.size() == 1) {
System.out.println("Server shutdown started");
- mbServerConnection.invoke(objectNameSet.iterator().next(), "stopBundle",
+ mbServerConnection.invoke(objectNameSet.iterator().next(), "stopBundle",
new Object[] { 0 }, new String[] { long.class.getName() });
System.out.println("Server shutdown completed");
} else {
@@ -227,5 +227,5 @@ public class StopServer implements Main,
public void doStop() throws Exception {
// TODO: unregister Main service?
}
-
+
}
Modified: geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StreamConsoleReader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StreamConsoleReader.java?rev=931793&r1=931792&r2=931793&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StreamConsoleReader.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/StreamConsoleReader.java Thu Apr 8 06:30:16 2010
@@ -14,36 +14,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.geronimo.deployment.cli;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
+import java.io.PrintStream;
import java.io.PrintWriter;
-import java.io.Writer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Abstract interface for an interface between command components
* and a console.
*/
public class StreamConsoleReader implements ConsoleReader {
- // the standard streams to write to
+
+ private static final Logger logger = LoggerFactory.getLogger(StreamConsoleReader.class);
+
protected BufferedReader keyboard;
+
protected PrintWriter console;
- public StreamConsoleReader(InputStream in, PrintWriter out) {
- keyboard = new BufferedReader(new InputStreamReader(in));
- console = out;
- }
+ private jline.ConsoleReader jlineConsoleReader;
- public StreamConsoleReader(InputStream in, OutputStream out) {
- this(in, new PrintWriter(new OutputStreamWriter(out)));
- }
+ private boolean jlineConsoleEnabled = true;
- public StreamConsoleReader(InputStream in, Writer out) {
- this(in, new PrintWriter(out, true));
+ public StreamConsoleReader(InputStream in, PrintStream out) {
+ try {
+ jlineConsoleReader = new jline.ConsoleReader(in, new PrintWriter(out, true));
+ } catch (IOException e) {
+ logger.warn("Fail to create jline console, some features like password mask will be disabled", e);
+ jlineConsoleEnabled = false;
+ keyboard = new BufferedReader(new InputStreamReader(in));
+ console = new PrintWriter(out, true);
+ }
}
/**
@@ -51,8 +59,13 @@ public class StreamConsoleReader impleme
*
* @exception IOException
*/
+ @Override
public void printNewline() throws IOException {
- console.println();
+ if (jlineConsoleEnabled) {
+ jlineConsoleReader.printNewline();
+ } else {
+ console.println();
+ }
}
/**
@@ -62,8 +75,13 @@ public class StreamConsoleReader impleme
*
* @exception IOException
*/
+ @Override
public void printString(String s) throws IOException {
- console.print(s);
+ if (jlineConsoleEnabled) {
+ jlineConsoleReader.printString(s);
+ } else {
+ console.print(s);
+ }
}
/**
@@ -73,22 +91,31 @@ public class StreamConsoleReader impleme
*
* @exception IOException
*/
+ @Override
public void println(String s) throws IOException {
- console.println(s);
+ if (jlineConsoleEnabled) {
+ jlineConsoleReader.printNewline();
+ jlineConsoleReader.printString(s);
+ } else {
+ console.println(s);
+ }
}
-
/**
* Read a line from the console.
*
* @return The next line from the console.
* @exception IOException
*/
+ @Override
public String readLine() throws IOException {
- return keyboard.readLine();
+ if (jlineConsoleEnabled) {
+ return jlineConsoleReader.readLine();
+ } else {
+ return keyboard.readLine();
+ }
}
-
/**
* Read a line from the console with a prompt.
*
@@ -97,20 +124,48 @@ public class StreamConsoleReader impleme
* @return The next line from the console.
* @exception IOException
*/
+ @Override
public String readLine(String prompt) throws IOException {
- printString(prompt);
- flushConsole();
- return readLine();
+ if (jlineConsoleEnabled) {
+ return jlineConsoleReader.readLine(prompt);
+ } else {
+ printString(prompt);
+ flushConsole();
+ return keyboard.readLine();
+ }
}
-
/**
* Flush any pending writes to the console.
*
* @exception IOException
*/
+ @Override
public void flushConsole() throws IOException {
- console.flush();
+ if (jlineConsoleEnabled) {
+ jlineConsoleReader.flushConsole();
+ } else {
+ console.flush();
+ }
+ }
+
+ @Override
+ public String readPassword() throws IOException {
+ if (jlineConsoleEnabled) {
+ return jlineConsoleReader.readLine('*');
+ } else {
+ return keyboard.readLine();
+ }
+ }
+
+ @Override
+ public String readPassword(String prompt) throws IOException {
+ if (jlineConsoleEnabled) {
+ return jlineConsoleReader.readLine(prompt, '*');
+ } else {
+ printString(prompt);
+ flushConsole();
+ return keyboard.readLine();
+ }
}
}
-