Permalink
Browse files

Fixed bug in shutdown/immediate shutdown goal

  • Loading branch information...
1 parent 6fbb80a commit 652810e18fbec378c6b07aa9320080b049caa0ab @frieder committed Jan 28, 2012
@@ -248,6 +248,26 @@ public File getArtefactFile() throws MojoFailureException {
}
/**
+ * Process start arguments to check whether or not a JMX port has been specified. In case a JMX port has
+ * been found it will be set.
+ */
+ protected void checkForJMXPort() {
+ logger.info("Parsing the start arguments for a JMX port");
+ boolean jmxParam = false;
+ for (String argument : getStartParams()) {
+ if (jmxParam) { // JMX port number
+ setJmxPort(argument.trim());
+ logger.debug("JMX port found: " + getJmxPort());
+ return;
+ }
+ if ("-jmxport".equalsIgnoreCase(argument.trim())) {
+ logger.debug("JMX argument found, expect next argument to be a valid port number");
+ jmxParam = true;
+ }
+ }
+ }
+
+ /**
* Transforms a stack trace into a String object.
*
* @param throwable
@@ -24,6 +24,8 @@
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
+ // check whether or not a JMX port has been specified in the start arguments
+ checkForJMXPort();
logger.info("Prepare immediate shutdown of Eclipse Virgo");
MBeanServerConnection connection = getConnection();
ObjectName name = new ObjectName(BaseMojo.MBEAN_SHUTDOWN);
@@ -21,9 +21,10 @@
*/
public class Shutdown extends BaseMojo {
- @Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
+ // check whether or not a JMX port has been specified in the start arguments
+ checkForJMXPort();
logger.info("Prepare shutdown of Eclipse Virgo");
MBeanServerConnection connection = getConnection();
ObjectName name = new ObjectName(BaseMojo.MBEAN_SHUTDOWN);
@@ -38,7 +39,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
} catch (IOException e) {
throw new MojoFailureException(stackTrace2String(e));
}
- }
+ }
}
}
@@ -66,7 +66,7 @@ private CommandLine determineStartScript() {
* Process the given start arguments
*/
private void processArguments(CommandLine cmdLine) {
- logger.info("Parsing for boot arguments to pass on");
+ logger.info("Parsing for start arguments to pass on");
boolean jmxParam = false;
for (String argument : getStartParams()) {
if (jmxParam) { // JMX port number

0 comments on commit 652810e

Please sign in to comment.