mirror of https://github.com/apache/activemq.git
https://issues.apache.org/activemq/browse/AMQ-2815 - first stab at moving karaf commands to activemq
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@961712 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e0f1872e69
commit
d1fa2baf40
|
@ -26,10 +26,44 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>activemq-karaf</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<packaging>bundle</packaging>
|
||||
<name>ActiveMQ :: Apache Karaf</name>
|
||||
<description>Provides resources for running ActiveMQ in Apache Karaf</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.karaf.shell</groupId>
|
||||
<artifactId>org.apache.karaf.shell.console</artifactId>
|
||||
<version>${karaf-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-optional</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-console</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.activemq</groupId>
|
||||
<artifactId>activemq-pool</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -73,6 +107,22 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Export-Package>org.apache.activemq.karaf.commands;version=${project.version};-split-package:=merge-first</Export-Package>
|
||||
<Import-Package>
|
||||
org.apache.felix.gogo.commands,
|
||||
*
|
||||
</Import-Package>
|
||||
<Private-Package>!*</Private-Package>
|
||||
<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -0,0 +1,158 @@
|
|||
/**
|
||||
*
|
||||
* 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.karaf.commands;
|
||||
|
||||
import org.apache.felix.gogo.commands.Action;
|
||||
import org.apache.felix.gogo.commands.Argument;
|
||||
import org.apache.felix.gogo.commands.basic.AbstractCommand;
|
||||
import org.apache.felix.gogo.commands.basic.ActionPreparator;
|
||||
import org.apache.felix.gogo.commands.basic.DefaultActionPreparator;
|
||||
import org.apache.karaf.shell.console.BlueprintContainerAware;
|
||||
import org.apache.karaf.shell.console.BundleContextAware;
|
||||
import org.apache.karaf.shell.console.CompletableFunction;
|
||||
import org.apache.karaf.shell.console.Completer;
|
||||
import org.apache.karaf.shell.console.commands.GenericType;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.service.blueprint.container.BlueprintContainer;
|
||||
import org.osgi.service.blueprint.container.Converter;
|
||||
import org.osgi.service.command.CommandSession;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Base command to process options and wrap native ActiveMQ console commands.
|
||||
*/
|
||||
public class ActiveMQCommand extends AbstractCommand implements CompletableFunction
|
||||
{
|
||||
protected BlueprintContainer blueprintContainer;
|
||||
protected Converter blueprintConverter;
|
||||
protected String actionId;
|
||||
protected List<Completer> completers;
|
||||
|
||||
public void setBlueprintContainer(BlueprintContainer blueprintContainer) {
|
||||
this.blueprintContainer = blueprintContainer;
|
||||
}
|
||||
|
||||
public void setBlueprintConverter(Converter blueprintConverter) {
|
||||
this.blueprintConverter = blueprintConverter;
|
||||
}
|
||||
|
||||
public void setActionId(String actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
public List<Completer> getCompleters() {
|
||||
return completers;
|
||||
}
|
||||
|
||||
public void setCompleters(List<Completer> completers) {
|
||||
this.completers = completers;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActionPreparator getPreparator() throws Exception {
|
||||
return new ActiveMQActionPreparator();
|
||||
}
|
||||
|
||||
class ActiveMQActionPreparator extends DefaultActionPreparator {
|
||||
@Override
|
||||
public boolean prepare(Action action, CommandSession session, List<Object> params) throws Exception
|
||||
{
|
||||
Map<Argument, Field> arguments = new HashMap<Argument, Field>();
|
||||
List<Argument> orderedArguments = new ArrayList<Argument>();
|
||||
// Introspect
|
||||
for (Class type = action.getClass(); type != null; type = type.getSuperclass()) {
|
||||
for (Field field : type.getDeclaredFields()) {
|
||||
Argument argument = field.getAnnotation(Argument.class);
|
||||
if (argument != null) {
|
||||
arguments.put(argument, field);
|
||||
int index = argument.index();
|
||||
while (orderedArguments.size() <= index) {
|
||||
orderedArguments.add(null);
|
||||
}
|
||||
if (orderedArguments.get(index) != null) {
|
||||
throw new IllegalArgumentException("Duplicate argument index: " + index);
|
||||
}
|
||||
orderedArguments.set(index, argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check indexes are correct
|
||||
for (int i = 0; i < orderedArguments.size(); i++) {
|
||||
if (orderedArguments.get(i) == null) {
|
||||
throw new IllegalArgumentException("Missing argument for index: " + i);
|
||||
}
|
||||
}
|
||||
// Populate
|
||||
Map<Argument, Object> argumentValues = new HashMap<Argument, Object>();
|
||||
int argIndex = 0;
|
||||
for (Iterator<Object> it = params.iterator(); it.hasNext();) {
|
||||
Object param = it.next();
|
||||
if (argIndex >= orderedArguments.size()) {
|
||||
throw new IllegalArgumentException("Too many arguments specified");
|
||||
}
|
||||
Argument argument = orderedArguments.get(argIndex);
|
||||
if (!argument.multiValued()) {
|
||||
argIndex++;
|
||||
}
|
||||
if (argument.multiValued()) {
|
||||
List<Object> l = (List<Object>) argumentValues.get(argument);
|
||||
if (l == null) {
|
||||
l = new ArrayList<Object>();
|
||||
argumentValues.put(argument, l);
|
||||
}
|
||||
l.add(param);
|
||||
} else {
|
||||
argumentValues.put(argument, param);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<Argument, Object> entry : argumentValues.entrySet()) {
|
||||
Field field = arguments.get(entry.getKey());
|
||||
Object value = convert(action, session, entry.getValue(), field.getGenericType());
|
||||
field.setAccessible(true);
|
||||
field.set(action, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object convert(Action action, CommandSession commandSession, Object o, Type type) throws Exception {
|
||||
return blueprintConverter.convert(o, new GenericType(type));
|
||||
}
|
||||
}
|
||||
|
||||
protected Action createNewAction() throws Exception {
|
||||
Action action = (Action) blueprintContainer.getComponentInstance(actionId);
|
||||
if (action instanceof BlueprintContainerAware) {
|
||||
((BlueprintContainerAware) action).setBlueprintContainer(blueprintContainer);
|
||||
}
|
||||
if (action instanceof BundleContextAware) {
|
||||
BundleContext context = (BundleContext) blueprintContainer.getComponentInstance("blueprintBundleContext");
|
||||
((BundleContextAware) action).setBundleContext(context);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.karaf.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.activemq.console.command.Command;
|
||||
import org.apache.activemq.console.formatter.CommandShellOutputFormatter;
|
||||
import org.apache.activemq.console.CommandContext;
|
||||
import org.apache.karaf.shell.console.OsgiCommandSupport;
|
||||
import org.apache.felix.gogo.commands.Argument;
|
||||
|
||||
/**
|
||||
* @version $Rev: 960482 $ $Date: 2010-07-05 10:28:33 +0200 (Mon, 05 Jul 2010) $
|
||||
*/
|
||||
public class ActiveMQCommandSupport extends OsgiCommandSupport {
|
||||
|
||||
private Command command;
|
||||
|
||||
@Argument(index=0, multiValued=true, required=true)
|
||||
private Collection<String> arguments = null;
|
||||
|
||||
protected Object doExecute() throws Exception {
|
||||
final String[] args = toStringArray(arguments.toArray());
|
||||
|
||||
CommandContext context2 = new CommandContext();
|
||||
context2.setFormatter(new CommandShellOutputFormatter(System.out));
|
||||
Command currentCommand = command.getClass().newInstance();
|
||||
|
||||
try {
|
||||
currentCommand.setCommandContext(context2);
|
||||
currentCommand.execute(new ArrayList<String>(Arrays.asList(args)));
|
||||
return null;
|
||||
} catch (Throwable e) {
|
||||
Throwable cur = e;
|
||||
while (cur.getCause() != null) {
|
||||
cur = cur.getCause();
|
||||
}
|
||||
if (cur instanceof java.net.ConnectException) {
|
||||
context2
|
||||
.print("\n"
|
||||
+ "Could not connect to JMX server. This command requires that the remote JMX server be enabled.\n"
|
||||
+ "This is typically done by adding the following JVM arguments: \n"
|
||||
+ " -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false \n"
|
||||
+ " -Dcom.sun.management.jmxremote.ssl=false \n" + "\n"
|
||||
+ "The connection error was: " + cur + "\n");
|
||||
} else {
|
||||
if (e instanceof Exception) {
|
||||
throw (Exception)e;
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public Command getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(Command command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public static String[] toStringArray(Object args[]) {
|
||||
String strings[] = new String[args.length];
|
||||
for(int i = 0; i < args.length; i++) {
|
||||
strings[i] = String.valueOf(args[i]);
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* 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.karaf.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.felix.gogo.commands.Option;
|
||||
import org.apache.felix.gogo.commands.Command;
|
||||
import org.apache.karaf.shell.console.OsgiCommandSupport;
|
||||
|
||||
/**
|
||||
* @version $Rev: 960482 $ $Date: 2010-07-05 10:28:33 +0200 (Mon, 05 Jul 2010) $
|
||||
*/
|
||||
@Command(scope="activemq", name="create-broker", description="Creates a broker instance.")
|
||||
public class CreateBrokerCommand extends OsgiCommandSupport {
|
||||
|
||||
@Option(name = "-n", aliases = {"--name"}, description = "The name of the broker (defaults to localhost).")
|
||||
private String name = "localhost";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see
|
||||
* org.apache.karaf.shell.console.OsgiCommandSupport#doExecute()
|
||||
*/
|
||||
protected Object doExecute() throws Exception {
|
||||
|
||||
try {
|
||||
String name = getName();
|
||||
File base = new File(System.getProperty("karaf.base"));
|
||||
File deploy = new File(base, "deploy");
|
||||
|
||||
HashMap<String, String> props = new HashMap<String, String>();
|
||||
props.put("${name}", name);
|
||||
|
||||
mkdir(deploy);
|
||||
File configFile = new File(deploy, name + "-broker.xml");
|
||||
copyFilteredResourceTo(configFile, "broker.xml", props);
|
||||
|
||||
System.out.println("");
|
||||
System.out.println("Default ActiveMQ Broker (" + name + ") configuration file created at: "
|
||||
+ configFile.getPath());
|
||||
System.out.println("Please review the configuration and modify to suite your needs. ");
|
||||
System.out.println("");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void copyFilteredResourceTo(File outFile, String resource, HashMap<String, String> props)
|
||||
throws Exception {
|
||||
if (!outFile.exists()) {
|
||||
System.out.println("Creating file: @|green " + outFile.getPath() + "|");
|
||||
InputStream is = CreateBrokerCommand.class.getResourceAsStream(resource);
|
||||
try {
|
||||
// Read it line at a time so that we can use the platform line
|
||||
// ending when we write it out.
|
||||
PrintStream out = new PrintStream(new FileOutputStream(outFile));
|
||||
try {
|
||||
Scanner scanner = new Scanner(is);
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
line = filter(line, props);
|
||||
out.println(line);
|
||||
}
|
||||
} finally {
|
||||
safeClose(out);
|
||||
}
|
||||
} finally {
|
||||
safeClose(is);
|
||||
}
|
||||
} else {
|
||||
System.out.println("@|red File already exists|. Move it out of the way if you want it re-created: "
|
||||
+ outFile.getPath() + "");
|
||||
}
|
||||
}
|
||||
|
||||
private void safeClose(InputStream is) throws IOException {
|
||||
if (is == null)
|
||||
return;
|
||||
try {
|
||||
is.close();
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
private void safeClose(OutputStream is) throws IOException {
|
||||
if (is == null)
|
||||
return;
|
||||
try {
|
||||
is.close();
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
private String filter(String line, HashMap<String, String> props) {
|
||||
for (Map.Entry<String, String> i : props.entrySet()) {
|
||||
int p1;
|
||||
while ((p1 = line.indexOf(i.getKey())) >= 0) {
|
||||
String l1 = line.substring(0, p1);
|
||||
String l2 = line.substring(p1 + i.getKey().length());
|
||||
line = l1 + i.getValue() + l2;
|
||||
}
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
private void mkdir(File file) {
|
||||
if (!file.exists()) {
|
||||
System.out.println("Creating missing directory: @|green " + file.getPath() + "|");
|
||||
file.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
File base = new File(System.getProperty("karaf.base"));
|
||||
name = base.getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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.karaf.commands;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.felix.gogo.commands.Option;
|
||||
import org.apache.felix.gogo.commands.Command;
|
||||
import org.apache.karaf.shell.console.OsgiCommandSupport;
|
||||
|
||||
/**
|
||||
* @version $Rev: 960482 $ $Date: 2010-07-05 10:28:33 +0200 (Mon, 05 Jul 2010) $
|
||||
*/
|
||||
@Command(scope="activemq", name="destroy-broker", description="Destory a broker instance.")
|
||||
public class DestroyBrokerCommand extends OsgiCommandSupport {
|
||||
|
||||
@Option(name = "-n", aliases = {"--name"}, description = "The name of the broker (defaults to localhost).")
|
||||
private String name = "localhost";
|
||||
|
||||
protected Object doExecute() throws Exception {
|
||||
|
||||
try {
|
||||
String name = getName();
|
||||
File base = new File(System.getProperty("karaf.base"));
|
||||
File deploy = new File(base, "deploy");
|
||||
File configFile = new File(deploy, name + "-broker.xml");
|
||||
|
||||
configFile.delete();
|
||||
|
||||
System.out.println("");
|
||||
System.out.println("Default ActiveMQ Broker (" + name + ") configuration file created at: "
|
||||
+ configFile.getPath() + " removed.");
|
||||
System.out.println("");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (name == null) {
|
||||
File base = new File(System.getProperty("karaf.base"));
|
||||
name = base.getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:shell="http://felix.apache.org/karaf/xmlns/shell/v1.0.0">
|
||||
|
||||
<shell:command-bundle>
|
||||
|
||||
<shell:command name="activemq/create-broker">
|
||||
<shell:action class="org.apache.activemq.karaf.commands.CreateBrokerCommand"/>
|
||||
</shell:command>
|
||||
|
||||
<shell:command name="activemq/destroy-broker">
|
||||
<shell:action class="org.apache.activemq.karaf.commands.DestroyBrokerCommand"/>
|
||||
</shell:command>
|
||||
|
||||
</shell:command-bundle>
|
||||
|
||||
<!-- ActiveMQ List Command -->
|
||||
<bean id="listcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
|
||||
<property name="blueprintContainer" ref="blueprintContainer"/>
|
||||
<property name="blueprintConverter" ref="blueprintConverter"/>
|
||||
<property name="actionId" value="listaction"/>
|
||||
</bean>
|
||||
|
||||
<service ref="listcommand" activation="lazy" >
|
||||
<interfaces>
|
||||
<value>org.osgi.service.command.Function</value>
|
||||
<value>org.apache.karaf.shell.console.CompletableFunction</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="osgi.command.scope" value="activemq"/>
|
||||
<entry key="osgi.command.function" value="list"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
<bean id="listaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
|
||||
activation="lazy"
|
||||
scope="prototype">
|
||||
<property name="command">
|
||||
<bean class="org.apache.activemq.console.command.ListCommand"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- ActiveMQ Query Command -->
|
||||
<bean id="querycommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
|
||||
<property name="blueprintContainer" ref="blueprintContainer"/>
|
||||
<property name="blueprintConverter" ref="blueprintConverter"/>
|
||||
<property name="actionId" value="queryaction"/>
|
||||
</bean>
|
||||
|
||||
<service ref="querycommand" activation="lazy" >
|
||||
<interfaces>
|
||||
<value>org.osgi.service.command.Function</value>
|
||||
<value>org.apache.karaf.shell.console.CompletableFunction</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="osgi.command.scope" value="activemq"/>
|
||||
<entry key="osgi.command.function" value="query"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
<bean id="queryaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
|
||||
activation="lazy"
|
||||
scope="prototype">
|
||||
<property name="command">
|
||||
<bean class="org.apache.activemq.console.command.QueryCommand"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- ActiveMQ Browse Command -->
|
||||
<bean id="browsecommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
|
||||
<property name="blueprintContainer" ref="blueprintContainer"/>
|
||||
<property name="blueprintConverter" ref="blueprintConverter"/>
|
||||
<property name="actionId" value="browseaction"/>
|
||||
</bean>
|
||||
|
||||
<service ref="browsecommand" activation="lazy" >
|
||||
<interfaces>
|
||||
<value>org.osgi.service.command.Function</value>
|
||||
<value>org.apache.karaf.shell.console.CompletableFunction</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="osgi.command.scope" value="activemq"/>
|
||||
<entry key="osgi.command.function" value="browse"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
<bean id="browseaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
|
||||
activation="lazy"
|
||||
scope="prototype">
|
||||
<property name="command">
|
||||
<bean class="org.apache.activemq.console.command.AmqBrowseCommand"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- ActiveMQ Bstat Command -->
|
||||
<bean id="bstatcommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
|
||||
<property name="blueprintContainer" ref="blueprintContainer"/>
|
||||
<property name="blueprintConverter" ref="blueprintConverter"/>
|
||||
<property name="actionId" value="bstataction"/>
|
||||
</bean>
|
||||
|
||||
<service ref="bstatcommand" activation="lazy" >
|
||||
<interfaces>
|
||||
<value>org.osgi.service.command.Function</value>
|
||||
<value>org.apache.karaf.shell.console.CompletableFunction</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="osgi.command.scope" value="activemq"/>
|
||||
<entry key="osgi.command.function" value="bstat"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
<bean id="bstataction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
|
||||
activation="lazy"
|
||||
scope="prototype">
|
||||
<property name="command">
|
||||
<bean class="org.apache.activemq.console.command.BstatCommand"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- ActiveMQ Purge Command -->
|
||||
<bean id="purgecommand" class="org.apache.activemq.karaf.commands.ActiveMQCommand">
|
||||
<property name="blueprintContainer" ref="blueprintContainer"/>
|
||||
<property name="blueprintConverter" ref="blueprintConverter"/>
|
||||
<property name="actionId" value="purgeaction"/>
|
||||
</bean>
|
||||
|
||||
<service ref="purgecommand" activation="lazy" >
|
||||
<interfaces>
|
||||
<value>org.osgi.service.command.Function</value>
|
||||
<value>org.apache.karaf.shell.console.CompletableFunction</value>
|
||||
</interfaces>
|
||||
<service-properties>
|
||||
<entry key="osgi.command.scope" value="activemq"/>
|
||||
<entry key="osgi.command.function" value="purge"/>
|
||||
</service-properties>
|
||||
</service>
|
||||
|
||||
<bean id="purgeaction" class="org.apache.activemq.karaf.commands.ActiveMQCommandSupport"
|
||||
activation="lazy"
|
||||
scope="prototype">
|
||||
<property name="command">
|
||||
<bean class="org.apache.activemq.console.command.PurgeCommand"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</blueprint>
|
|
@ -1,26 +1,6 @@
|
|||
<features name="activemq-${activemq-version}">
|
||||
<repository>mvn:org.apache.felix.karaf/apache-felix-karaf/1.6.0/xml/features</repository>
|
||||
|
||||
<feature name="spring" version="${spring-version}">
|
||||
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.aopalliance/1.0_3</bundle>
|
||||
<bundle>mvn:org.springframework/spring-core/${spring-version}</bundle>
|
||||
<bundle>mvn:org.springframework/spring-beans/${spring-version}</bundle>
|
||||
<bundle>mvn:org.springframework/spring-aop/${spring-version}</bundle>
|
||||
<bundle>mvn:org.springframework/spring-context/${spring-version}</bundle>
|
||||
<bundle>mvn:org.springframework/spring-context-support/${spring-version}</bundle>
|
||||
<bundle>mvn:org.springframework/spring-asm/${spring-version}</bundle>
|
||||
<bundle>mvn:org.springframework/spring-expression/${spring-version}</bundle>
|
||||
</feature>
|
||||
|
||||
<feature name="spring-dm" version="1.2.1">
|
||||
<feature version="${spring-version}">spring</feature>
|
||||
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.cglib/2.1_3_4</bundle>
|
||||
<bundle>mvn:org.springframework.osgi/spring-osgi-io/1.2.0</bundle>
|
||||
<bundle>mvn:org.springframework.osgi/spring-osgi-core/1.2.0</bundle>
|
||||
<bundle>mvn:org.springframework.osgi/spring-osgi-extender/1.2.0</bundle>
|
||||
<bundle>mvn:org.springframework.osgi/spring-osgi-annotation/1.2.0</bundle>
|
||||
<bundle>mvn:org.apache.felix.karaf.deployer/org.apache.felix.karaf.deployer.spring/1.7.0-SNAPSHOT</bundle>
|
||||
</feature>
|
||||
<!-- TODO: uncomment when we upgrade to karaf 2.0 -->
|
||||
<!-- <repository>mvn:org.apache.felix.karaf/apache-felix-karaf/${karaf-version}/xml/features</repository> -->
|
||||
|
||||
<feature name="activemq" version="${activemq-version}">
|
||||
<bundle>mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/1.1.1</bundle>
|
||||
|
@ -36,12 +16,12 @@
|
|||
<bundle>mvn:org.apache.activemq/kahadb/${activemq-version}</bundle>
|
||||
<bundle>mvn:org.apache.activemq/activemq-console/${activemq-version}</bundle>
|
||||
<bundle>mvn:org.apache.activemq/activemq-pool/${activemq-version}</bundle>
|
||||
<bundle>mvn:org.apache.servicemix.activemq/org.apache.servicemix.activemq.commands/4.2.0</bundle>
|
||||
<bundle>mvn:org.apache.activemq/activemq-karaf/${activemq-version}</bundle>
|
||||
<bundle>mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/0.1-incubating</bundle>
|
||||
</feature>
|
||||
|
||||
<feature name="activemq-spring" version="${activemq-version}">
|
||||
<feature version="1.2.1">spring-dm</feature>
|
||||
<feature version="1.2.0">spring-dm</feature>
|
||||
<feature version="${activemq-version}">activemq</feature>
|
||||
<bundle>mvn:org.apache.xbean/xbean-spring/${xbean-version}</bundle>
|
||||
</feature>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
## 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.
|
||||
##
|
||||
|
||||
##
|
||||
## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
|
||||
##
|
||||
|
||||
command.description=Parent ActiveMQ administration command.
|
||||
|
||||
command.manual=\
|
||||
TODO: date manual
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
## 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.
|
||||
##
|
||||
|
||||
##
|
||||
## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
|
||||
##
|
||||
|
||||
command.description=Creates a broker instance.
|
||||
|
||||
command.manual=\
|
||||
TODO: date manual
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
## 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.
|
||||
##
|
||||
|
||||
##
|
||||
## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
|
||||
##
|
||||
|
||||
command.description=Remove a broker instance.
|
||||
|
||||
command.manual=\
|
||||
TODO: date manual
|
|
@ -0,0 +1,137 @@
|
|||
<!--
|
||||
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.
|
||||
-->
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:amq="http://activemq.apache.org/schema/core"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:osgi="http://www.springframework.org/schema/osgi"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
|
||||
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
|
||||
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
|
||||
|
||||
<!-- Allows us to use system properties as variables in this configuration file -->
|
||||
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
|
||||
|
||||
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="${name}" dataDirectory="${karaf.base}/data/activemq/${name}" useShutdownHook="false">
|
||||
|
||||
<!-- Destination specific policies using destination names or wildcards -->
|
||||
<destinationPolicy>
|
||||
<policyMap>
|
||||
|
||||
<policyEntries>
|
||||
<policyEntry queue=">" memoryLimit="5mb"/>
|
||||
<policyEntry topic=">" memoryLimit="5mb">
|
||||
<subscriptionRecoveryPolicy>
|
||||
<lastImageSubscriptionRecoveryPolicy/>
|
||||
</subscriptionRecoveryPolicy>
|
||||
</policyEntry>
|
||||
</policyEntries>
|
||||
</policyMap>
|
||||
|
||||
</destinationPolicy>
|
||||
|
||||
<!-- Use the following to configure how ActiveMQ is exposed in JMX -->
|
||||
<managementContext>
|
||||
<managementContext createConnector="false"/>
|
||||
</managementContext>
|
||||
|
||||
<!-- The store and forward broker networks ActiveMQ will listen to -->
|
||||
<networkConnectors>
|
||||
<!-- by default just auto discover the other brokers -->
|
||||
|
||||
<networkConnector name="default-nc" uri="multicast://default"/>
|
||||
<!-- Example of a static configuration:
|
||||
<networkConnector name="host1 and host2" uri="static://(tcp://host1:61616,tcp://host2:61616)"/>
|
||||
-->
|
||||
</networkConnectors>
|
||||
|
||||
<persistenceAdapter>
|
||||
<amqPersistenceAdapter syncOnWrite="false" directory="${karaf.base}/data/activemq/${name}" maxFileLength="20 mb"/>
|
||||
</persistenceAdapter>
|
||||
|
||||
<!-- Use the following if you wish to configure the journal with JDBC -->
|
||||
<!--
|
||||
<persistenceAdapter>
|
||||
<journaledJDBC dataDirectory="${activemq.base}/data" dataSource="#postgres-ds"/>
|
||||
</persistenceAdapter>
|
||||
-->
|
||||
|
||||
<!-- Or if you want to use pure JDBC without a journal -->
|
||||
<!--
|
||||
<persistenceAdapter>
|
||||
<jdbcPersistenceAdapter dataSource="#postgres-ds"/>
|
||||
</persistenceAdapter>
|
||||
-->
|
||||
|
||||
<!-- The maximum about of space the broker will use before slowing down producers -->
|
||||
<systemUsage>
|
||||
<systemUsage>
|
||||
<memoryUsage>
|
||||
<memoryUsage limit="20 mb"/>
|
||||
</memoryUsage>
|
||||
|
||||
<storeUsage>
|
||||
<storeUsage limit="1 gb" name="foo"/>
|
||||
</storeUsage>
|
||||
<tempUsage>
|
||||
<tempUsage limit="100 mb"/>
|
||||
</tempUsage>
|
||||
</systemUsage>
|
||||
</systemUsage>
|
||||
|
||||
<!-- The transport connectors ActiveMQ will listen to -->
|
||||
<transportConnectors>
|
||||
<transportConnector name="openwire" uri="tcp://localhost:61616" discoveryUri="multicast://default"/>
|
||||
<transportConnector name="stomp" uri="stomp://localhost:61613"/>
|
||||
</transportConnectors>
|
||||
|
||||
</broker>
|
||||
|
||||
<bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
|
||||
<property name="brokerURL" value="tcp://localhost:61616" />
|
||||
</bean>
|
||||
|
||||
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactoryBean">
|
||||
<property name="maxConnections" value="8" />
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="connectionFactory" ref="activemqConnectionFactory" />
|
||||
<property name="resourceName" value="activemq.${name}" />
|
||||
</bean>
|
||||
|
||||
<bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource">
|
||||
<property name="transactionManager" ref="transactionManager" />
|
||||
<property name="connectionFactory" ref="activemqConnectionFactory" />
|
||||
<property name="resourceName" value="activemq.${name}" />
|
||||
</bean>
|
||||
|
||||
<osgi:reference id="transactionManager" interface="javax.transaction.TransactionManager" />
|
||||
|
||||
<osgi:service ref="pooledConnectionFactory">
|
||||
|
||||
<osgi:interfaces>
|
||||
<value>javax.jms.ConnectionFactory</value>
|
||||
</osgi:interfaces>
|
||||
<osgi:service-properties>
|
||||
<entry key="name" value="${name}"/>
|
||||
</osgi:service-properties>
|
||||
</osgi:service>
|
||||
|
||||
</beans>
|
||||
|
||||
|
1
pom.xml
1
pom.xml
|
@ -67,6 +67,7 @@
|
|||
<jmock-version>2.5.1</jmock-version>
|
||||
<junit-version>4.5</junit-version>
|
||||
<jxta-version>2.0</jxta-version>
|
||||
<karaf-version>1.99.0-SNAPSHOT</karaf-version>
|
||||
<log4j-version>1.2.14</log4j-version>
|
||||
<nlog4j-version>1.5.2</nlog4j-version>
|
||||
<org-apache-derby-version>10.1.3.1</org-apache-derby-version>
|
||||
|
|
Loading…
Reference in New Issue