mirror of https://github.com/apache/activemq.git
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:
parent
6c09e846b1
commit
da66c46847
5
NOTICE
5
NOTICE
|
@ -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.
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,12 @@
|
||||||
<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>
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
7
pom.xml
7
pom.xml
|
@ -450,6 +450,13 @@
|
||||||
<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>
|
||||||
<groupId>javax.xml.bind</groupId>
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
|
Loading…
Reference in New Issue