modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 17 ++ modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentNativePromptInfo.java | 2 modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/JlinePromptInfo.java | 71 ---------- 3 files changed, 16 insertions(+), 74 deletions(-)
New commits: commit ef718853fc7e1978f01081928a8b69ce67dc5ca2 Author: Jason Dobies jason.dobies@redhat.com Date: Tue Feb 2 10:00:51 2010 -0500
Revert "Fix the native cleanup so that it will not echo password and will use jline"
This reverts commit d19bacd67e857e52428144ab28af5a0c44956df3.
Conflicts:
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/JlinePromptInfo.java
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java index e2c6440..0d900d4 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java @@ -816,7 +816,22 @@ public class AgentMain { * @return object that can be used to read input with the typed data being echoed or not */ public PromptInput getNativeIn() { - return new JlinePromptInfo(this) ; + SystemInfo sysinfo = null; + + // if we are not in daemon mode, we are running in a console and thus we can try to use + // the native library to get its input. + // If we are in daemon mode, we aren't running in a console so we need to pass null + // in for sysinfo thus causing the prompt info implementation to use our fallback buffered + // reader (which is either empty or is contents of an input file that was piped in via --input. + if (!m_daemonMode) { + // just in case the native stuff has a bug in the console stuff (JBNATIVE-42 as an example), + // be able to configure the agent to ignore the native console + if (Boolean.getBoolean("rhq.agent.do-not-use-native-console") == false) { + sysinfo = SystemInfoFactory.createSystemInfo(); + } + } + + return new AgentNativePromptInfo(sysinfo, this); }
/** diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentNativePromptInfo.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentNativePromptInfo.java index b1cc009..287421d 100644 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentNativePromptInfo.java +++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentNativePromptInfo.java @@ -30,9 +30,7 @@ import org.rhq.enterprise.communications.util.prefs.PromptInput; * will do the same as {@link #readLine()}). * * @author John Mazzitelli - * @deprecated */ -@Deprecated public class AgentNativePromptInfo implements PromptInput { private final SystemInfo systemInfo; private final AgentMain agent; diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/JlinePromptInfo.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/JlinePromptInfo.java deleted file mode 100644 index cb09997..0000000 --- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/JlinePromptInfo.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.agent; - -import java.io.IOException; -import org.rhq.core.system.SystemInfo; -import org.rhq.enterprise.agent.i18n.AgentI18NResourceKeys; -import org.rhq.enterprise.communications.util.prefs.PromptInput; - -/** - * Provides a {@link PromptInput} implementation that the agent can use to obtain input from the jline - * command prompt in the agent. - */ -public class JlinePromptInfo implements PromptInput { - private final AgentMain agent; - - /** - * Constructor for {@link AgentNativePromptInfo} that is given the agent main to retrieve - * the jline command prompt from. - */ - public JlinePromptInfo(AgentMain agent) { - this.agent = agent; - } - - public String readLine() throws IOException { - - return agent.getIn().readLine(); - } - - public String readLineNoEcho() throws IOException { - String input = null; - - while (true) { - // get the answer the first time - // A (char)0 will blank it out. I like stars - input = agent.getIn().readLine('*'); - - // get the answer a second time - agent.getOut().write(agent.getI18NMsg().getMsg(AgentI18NResourceKeys.PROMPT_CONFIRM)) ; - agent.getOut().println() ; - String confirmation = agent.getIn().readLine('*'); - agent.getOut().println() ; - - // make sure the first and second answers match; otherwise, ask again - if (input.equals(confirmation)) { - break; - } - - agent.getOut().write(agent.getI18NMsg().getMsg(AgentI18NResourceKeys.PROMPT_CONFIRM_FAILED)); - agent.getOut().println() ; - } - - return input; - } -} \ No newline at end of file
rhq-commits@lists.fedorahosted.org