AMQ-2968 - Add Apache commons daemon (jsvc/procrun) start/stop support.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1079638 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bruce Snyder 2011-03-09 01:42:36 +00:00
parent 6c09e846b1
commit da66c46847
4 changed files with 127 additions and 6 deletions

5
NOTICE
View File

@ -42,3 +42,8 @@ Some portions of the code are Copyright:
1999 Jason Gilbert. 1999 Jason Gilbert.
The jboss integration module contains some LGPL code. The jboss integration module contains some LGPL code.
This product includes software developed by
Yahoo! Inc. (www.yahoo.com)
Copyright (c) 2010 Yahoo! Inc. All rights reserved.

View File

@ -125,7 +125,13 @@
<dependency> <dependency>
<groupId>com.ibm.icu</groupId> <groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId> <artifactId>icu4j</artifactId>
</dependency> </dependency>
<dependency>
<groupId>commons-daemon</groupId>
<artifactId>commons-daemon</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,103 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.activemq.console;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.activemq.console.command.Command;
import org.apache.activemq.console.command.ShutdownCommand;
import org.apache.activemq.console.command.StartCommand;
import org.apache.activemq.console.CommandContext;
import org.apache.activemq.console.Main;
import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
/**
* This class launches activemq under Apache JSVC {@link http://commons.apache.org/daemon/jsvc.html}
*
* @author areese
*
*/
public class ActiveMQLauncher implements Daemon {
private List<String> args;
/**
*
*/
public ActiveMQLauncher() {
}
/*
* (non-Javadoc)
*
* @see org.apache.commons.daemon.Daemon#destroy()
*/
public void destroy() {
}
/*
* (non-Javadoc)
*
* @see
* org.apache.commons.daemon.Daemon#init(org.apache.commons.daemon.DaemonContext
* )
*/
public void init(DaemonContext arg0) throws Exception {
// we need to save the args we started with.
args = Arrays.asList(arg0.getArguments());
}
/*
* (non-Javadoc)
*
* @see org.apache.commons.daemon.Daemon#start()
*/
public void start() throws Exception {
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
Command command = new StartCommand();
command.setCommandContext(context);
command.execute(args);
}
/*
* (non-Javadoc)
*
* @see org.apache.commons.daemon.Daemon#stop()
*/
public void stop() throws Exception {
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
Command command = new ShutdownCommand();
command.setCommandContext(context);
List<String> tokens = new ArrayList<String>(Arrays.asList(new String[] {
"--jmxlocal", "--all", }));
command.execute(tokens);
}
}

17
pom.xml
View File

@ -449,6 +449,13 @@
<version>3.0.0</version> <version>3.0.0</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- For jsvc support -->
<dependency>
<groupId>commons-daemon</groupId>
<artifactId>commons-daemon</artifactId>
<version>1.0.3</version>
</dependency>
<!-- for the XML parsing --> <!-- for the XML parsing -->
<dependency> <dependency>
@ -941,11 +948,11 @@
</dependency> </dependency>
<!-- FTP support for BlobMessages --> <!-- FTP support for BlobMessages -->
<dependency> <dependency>
<groupId>commons-net</groupId> <groupId>commons-net</groupId>
<artifactId>commons-net</artifactId> <artifactId>commons-net</artifactId>
<version>${commons-net-version}</version> <version>${commons-net-version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>