diff --git a/activemq-karaf/pom.xml b/activemq-karaf/pom.xml
index d217fca885..d2ad9987ef 100644
--- a/activemq-karaf/pom.xml
+++ b/activemq-karaf/pom.xml
@@ -26,10 +26,44 @@
activemq-karaf
- jar
+ bundle
ActiveMQ :: Apache Karaf
Provides resources for running ActiveMQ in Apache Karaf
+
+
+ org.apache.karaf.shell
+ org.apache.karaf.shell.console
+ ${karaf-version}
+
+
+ org.osgi
+ org.osgi.core
+ provided
+
+
+
+ org.apache.activemq
+ activemq-core
+
+
+
+ org.apache.activemq
+ activemq-optional
+
+
+
+ org.apache.activemq
+ activemq-console
+
+
+
+ org.apache.activemq
+ activemq-pool
+
+
+
+
@@ -73,6 +107,22 @@
+
+ org.apache.felix
+ maven-bundle-plugin
+
+
+ ${project.artifactId}
+ org.apache.activemq.karaf.commands;version=${project.version};-split-package:=merge-first
+
+ org.apache.felix.gogo.commands,
+ *
+
+ !*
+ <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))
+
+
+
diff --git a/activemq-karaf/src/main/java/org/apache/activemq/karaf/commands/ActiveMQCommand.java b/activemq-karaf/src/main/java/org/apache/activemq/karaf/commands/ActiveMQCommand.java
new file mode 100644
index 0000000000..3dd9bc6914
--- /dev/null
+++ b/activemq-karaf/src/main/java/org/apache/activemq/karaf/commands/ActiveMQCommand.java
@@ -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 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 getCompleters() {
+ return completers;
+ }
+
+ public void setCompleters(List 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