[KARAF-5131] XA + JMS support Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/7a84233c Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/7a84233c Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/7a84233c
Branch: refs/heads/OPENSSH Commit: 7a84233c0eb13568ee797c1e623285af427fdcdf Parents: d1ce154 Author: Guillaume Nodet <[email protected]> Authored: Wed Aug 2 10:36:31 2017 +0200 Committer: Guillaume Nodet <[email protected]> Committed: Wed Aug 2 14:10:48 2017 +0200 ---------------------------------------------------------------------- .../src/main/feature/feature.xml | 2 +- assemblies/features/enterprise/pom.xml | 5 - .../enterprise/src/main/feature/feature.xml | 57 +- .../standard/src/main/feature/feature.xml | 2 + .../java/org/apache/karaf/itests/JmsTest.java | 2 +- .../karaf/jdbc/internal/JdbcServiceImpl.java | 2 +- jms/NOTICE | 67 +++ jms/core/NOTICE | 67 --- jms/core/pom.xml | 123 ----- .../java/org/apache/karaf/jms/JmsMBean.java | 165 ------ .../java/org/apache/karaf/jms/JmsMessage.java | 164 ------ .../java/org/apache/karaf/jms/JmsService.java | 171 ------ .../apache/karaf/jms/command/BrowseCommand.java | 104 ---- .../jms/command/ConnectionFactoriesCommand.java | 45 -- .../karaf/jms/command/ConsumeCommand.java | 40 -- .../apache/karaf/jms/command/CountCommand.java | 41 -- .../apache/karaf/jms/command/CreateCommand.java | 52 -- .../apache/karaf/jms/command/DeleteCommand.java | 40 -- .../apache/karaf/jms/command/InfoCommand.java | 46 -- .../karaf/jms/command/JmsCommandSupport.java | 36 -- .../command/JmsConnectionCommandSupport.java | 39 -- .../apache/karaf/jms/command/MoveCommand.java | 44 -- .../apache/karaf/jms/command/QueuesCommand.java | 43 -- .../apache/karaf/jms/command/SendCommand.java | 44 -- .../apache/karaf/jms/command/TopicsCommand.java | 43 -- .../ConnectionFactoriesFileNameCompleter.java | 59 -- .../ConnectionFactoriesNameCompleter.java | 59 -- .../ActiveMQDestinationSourceFactory.java | 68 --- .../ArtemisDestinationSourceFactory.java | 63 --- .../karaf/jms/internal/DestinationSource.java | 35 -- .../apache/karaf/jms/internal/JmsConnector.java | 108 ---- .../apache/karaf/jms/internal/JmsMBeanImpl.java | 164 ------ .../karaf/jms/internal/JmsServiceImpl.java | 285 ---------- .../karaf/jms/internal/osgi/Activator.java | 32 -- .../src/main/resources/OSGI-INF/bundle.info | 41 -- .../jms/internal/connectionfactory-activemq.xml | 34 -- .../jms/internal/connectionfactory-artemis.xml | 35 -- .../internal/connectionfactory-webspheremq.xml | 35 -- jms/pom.xml | 111 +++- jms/pool/pom.xml | 104 ---- .../karaf/jms/pool/internal/ConnectionKey.java | 75 --- .../karaf/jms/pool/internal/ConnectionPool.java | 315 ----------- .../jms/pool/internal/IntrospectionSupport.java | 123 ----- .../jms/pool/internal/PooledConnection.java | 285 ---------- .../pool/internal/PooledConnectionFactory.java | 538 ------------------- .../pool/internal/PooledMessageConsumer.java | 76 --- .../karaf/jms/pool/internal/PooledProducer.java | 168 ------ .../jms/pool/internal/PooledQueueSender.java | 51 -- .../karaf/jms/pool/internal/PooledSession.java | 497 ----------------- .../internal/PooledSessionEventListener.java | 48 -- .../jms/pool/internal/PooledTopicPublisher.java | 57 -- .../karaf/jms/pool/internal/SessionKey.java | 65 --- .../karaf/jms/pool/internal/osgi/Activator.java | 180 ------- .../java/org/apache/karaf/jms/JmsMBean.java | 165 ++++++ .../java/org/apache/karaf/jms/JmsMessage.java | 164 ++++++ .../java/org/apache/karaf/jms/JmsService.java | 171 ++++++ .../apache/karaf/jms/command/BrowseCommand.java | 104 ++++ .../jms/command/ConnectionFactoriesCommand.java | 45 ++ .../karaf/jms/command/ConsumeCommand.java | 40 ++ .../apache/karaf/jms/command/CountCommand.java | 41 ++ .../apache/karaf/jms/command/CreateCommand.java | 52 ++ .../apache/karaf/jms/command/DeleteCommand.java | 40 ++ .../apache/karaf/jms/command/InfoCommand.java | 46 ++ .../karaf/jms/command/JmsCommandSupport.java | 36 ++ .../command/JmsConnectionCommandSupport.java | 39 ++ .../apache/karaf/jms/command/MoveCommand.java | 44 ++ .../apache/karaf/jms/command/QueuesCommand.java | 43 ++ .../apache/karaf/jms/command/SendCommand.java | 44 ++ .../apache/karaf/jms/command/TopicsCommand.java | 43 ++ .../ConnectionFactoriesFileNameCompleter.java | 59 ++ .../ConnectionFactoriesNameCompleter.java | 59 ++ .../ActiveMQDestinationSourceFactory.java | 89 +++ .../ArtemisDestinationSourceFactory.java | 69 +++ .../karaf/jms/internal/DestinationSource.java | 36 ++ .../apache/karaf/jms/internal/JmsMBeanImpl.java | 164 ++++++ .../karaf/jms/internal/JmsServiceImpl.java | 285 ++++++++++ .../karaf/jms/internal/osgi/Activator.java | 38 ++ jms/src/main/resources/OSGI-INF/bundle.info | 41 ++ pom.xml | 6 +- 79 files changed, 2168 insertions(+), 4950 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/assemblies/features/enterprise-legacy/src/main/feature/feature.xml ---------------------------------------------------------------------- diff --git a/assemblies/features/enterprise-legacy/src/main/feature/feature.xml b/assemblies/features/enterprise-legacy/src/main/feature/feature.xml index 8d221b6..56cd7ae 100644 --- a/assemblies/features/enterprise-legacy/src/main/feature/feature.xml +++ b/assemblies/features/enterprise-legacy/src/main/feature/feature.xml @@ -29,7 +29,7 @@ <feature name="transaction" description="OSGi Transaction Manager" version="${aries.transaction.manager.version}"> <details>JTA implementation provided by Apache Aries Transaction</details> - <feature version="${aries.transaction.manager.version}">transaction-manager-geronimo</feature> + <feature version="${geronimo.transaction.manager.version}">transaction-manager-geronimo</feature> </feature> <feature name="jpa" description="OSGi Persistence Container" version="${aries.jpa.container.context.version}"> http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/assemblies/features/enterprise/pom.xml ---------------------------------------------------------------------- diff --git a/assemblies/features/enterprise/pom.xml b/assemblies/features/enterprise/pom.xml index 8557860..8f6c0b6 100644 --- a/assemblies/features/enterprise/pom.xml +++ b/assemblies/features/enterprise/pom.xml @@ -53,11 +53,6 @@ <artifactId>org.apache.aries.transaction.blueprint</artifactId> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.apache.aries.transaction</groupId> - <artifactId>org.apache.aries.transaction.manager</artifactId> - <scope>provided</scope> - </dependency> <!-- jpa deps --> <dependency> http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/assemblies/features/enterprise/src/main/feature/feature.xml ---------------------------------------------------------------------- diff --git a/assemblies/features/enterprise/src/main/feature/feature.xml b/assemblies/features/enterprise/src/main/feature/feature.xml index 6b6fa04..f9b6ab7 100644 --- a/assemblies/features/enterprise/src/main/feature/feature.xml +++ b/assemblies/features/enterprise/src/main/feature/feature.xml @@ -24,6 +24,8 @@ <repository>mvn:org.hibernate/hibernate-osgi/${hibernate.version}/xml/karaf</repository> <repository>mvn:org.ops4j.pax.cdi/pax-cdi-features/${pax.cdi.version}/xml/features</repository> <repository>mvn:org.ops4j.pax.jdbc/pax-jdbc-features/${pax.jdbc.version}/xml/features</repository> + <repository>mvn:org.ops4j.pax.jms/pax-jms-features/${pax.jms.version}/xml/features</repository> + <repository>mvn:org.ops4j.pax.transx/pax-transx-features/${pax.transx.version}/xml/features</repository> <repository>mvn:org.apache.karaf.features/standard/${project.version}/xml/features</repository> <repository>mvn:org.apache.aries.jpa/jpa-features/${aries.jpa.version}/xml/features</repository> @@ -33,21 +35,21 @@ <bundle dependency="true">mvn:javax.el/javax.el-api/3.0.0</bundle> <bundle dependency="true">mvn:javax.enterprise/cdi-api/1.2</bundle> <bundle>mvn:javax.transaction/javax.transaction-api/1.2</bundle> + <feature>pax-transx-tm-api</feature> </feature> - <feature name="transaction-manager-geronimo" description="Geronimo Transaction Manager" version="${aries.transaction.manager.version}"> + <feature name="transaction-manager-geronimo" description="Geronimo Transaction Manager" version="${geronimo.transaction.manager.version}"> <details>JTA implementation provided by Apache Aries Transaction</details> - <config name="org.apache.aries.transaction"> - aries.transaction.recoverable = true - aries.transaction.timeout = 600 - aries.transaction.howl.logFileDir = ${karaf.data}/txlog - aries.transaction.howl.maxLogFiles = 2 - aries.transaction.howl.maxBlocksPerFile = 512 - aries.transaction.howl.bufferSize = 4 + <config name="org.ops4j.pax.transx.tm.geronimo"> + org.apache.geronimo.tm.recoverable = true + org.apache.geronimo.tm.timeout = 600 + org.apache.geronimo.tm.howl.logFileDir = ${karaf.data}/txlog + org.apache.geronimo.tm.howl.maxLogFiles = 2 + org.apache.geronimo.tm.howl.maxBlocksPerFile = 512 + org.apache.geronimo.tm.howl.bufferSize = 4 </config> <feature version="[1.1,2)">transaction-api</feature> - <bundle dependency="true">mvn:org.apache.aries/org.apache.aries.util/${aries.util.version}</bundle> - <bundle>mvn:org.apache.aries.transaction/org.apache.aries.transaction.manager/${aries.transaction.manager.version}</bundle> + <feature>pax-transx-tm-geronimo</feature> <capability> transaction-manager;provider:=geronimo </capability> @@ -55,17 +57,30 @@ <feature name="transaction-manager-narayana" description="Narayana Transaction Manager" version="${narayana.version}"> <details>JTA implementation provided by Narayana</details> - <config name="org.jboss.narayana"> - ObjectStoreEnvironmentBean.objectStoreDir=${karaf.data}/narayana - ObjectStoreEnvironmentBean.communicationStore.objectStoreDir=${karaf.data}/narayana - HornetqJournalEnvironmentBean.storeDir=${karaf.data}/narayana/hornetq + <config name="org.ops4j.pax.transx.tm.narayana"> + com.arjuna.ats.arjuna.objectstore.objectStoreDir=${karaf.data}/narayana + com.arjuna.ats.arjuna.objectstore.communicationStore.objectStoreDir=${karaf.data}/narayana + com.arjuna.ats.arjuna.hornetqjournal.storeDir=${karaf.data}/narayana/hornetq </config> - <bundle>mvn:org.jboss.narayana.osgi/narayana-osgi-jta/${narayana.version}</bundle> + <feature version="[1.1,2)">transaction-api</feature> + <feature>pax-transx-tm-narayana</feature> <capability> transaction-manager;provider:=narayana </capability> </feature> + <feature name="transaction-manager-atomikos" description="Atomikos Transaction Manager" version="${atomikos.version}"> + <details>JTA implementation provided by Atomikos</details> + <config name="org.ops4j.pax.transx.tm.atomikos"> + com.atomikos.icatch.log_base_dir=${karaf.data}/atomikos + </config> + <feature version="[1.1,2)">transaction-api</feature> + <feature>pax-transx-tm-atomikos</feature> + <capability> + transaction-manager;provider:=atomikos + </capability> + </feature> + <feature name="transaction" description="OSGi Transaction Manager" version="2.0"> <details>JTA Support</details> <feature dependency="true">transaction-manager-geronimo</feature> @@ -158,21 +173,13 @@ <feature name="jms" description="JMS service and commands" version="${project.version}"> <details>JMS support provinding service, commands, and MBean.</details> - <feature dependency="true">aries-blueprint</feature> + <feature>pax-jms-pool</feature> + <feature>transaction</feature> <bundle dependency="true">mvn:javax.jms/javax.jms-api/2.0</bundle> <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/${geronimo.jta-spec.version}</bundle> <bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/${geronimo.jms-spec.version}</bundle> <bundle dependency="true">mvn:org.apache.commons/commons-pool2/2.4.2</bundle> <bundle>mvn:org.apache.karaf.jms/org.apache.karaf.jms.core/${project.version}</bundle> - <bundle>mvn:org.apache.karaf.jms/org.apache.karaf.jms.pool/${project.version}</bundle> - <!-- - Requirement on Blueprint. - We don't use a feature dependency to allow the choice between aries-blueprint and gemini-blueprint. - This means that you need to install one of the above to be able to install the jdbc feature. - --> - <requirement> - osgi.extender;filter:="(&(osgi.extender=osgi.blueprint)(version>=1.0))" - </requirement> </feature> <feature name="application-without-isolation" description="Provide EBA archive support" version="${aries.application.version}"> http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/assemblies/features/standard/src/main/feature/feature.xml ---------------------------------------------------------------------- diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml index 32aaa9d..61f13bf 100644 --- a/assemblies/features/standard/src/main/feature/feature.xml +++ b/assemblies/features/standard/src/main/feature/feature.xml @@ -79,7 +79,9 @@ hawtio=mvn:io.hawt/hawtio-karaf/RELEASE/xml/features pax-cdi=mvn:org.ops4j.pax.cdi/pax-cdi-features/RELEASE/xml/features pax-jdbc=mvn:org.ops4j.pax.jdbc/pax-jdbc-features/RELEASE/xml/features + pax-jms=mvn:org.ops4j.pax.jms/pax-jms-features/RELEASE/xml/features pax-jpa=mvn:org.ops4j.pax.jpa/pax-jpa-features/RELEASE/xml/features + pax-transx=mvn:org.ops4j.pax.transx/pax-transx-features/RELEASE/xml/features pax-web=mvn:org.ops4j.pax.web/pax-web-features/RELEASE/xml/features pax-wicket=mvn:org.ops4j.pax.wicket/pax-wicket-features/RELEASE/xml/features ecf=http://download.eclipse.org/rt/ecf/RELEASE/site.p2/karaf-features.xml http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/itests/src/test/java/org/apache/karaf/itests/JmsTest.java ---------------------------------------------------------------------- diff --git a/itests/src/test/java/org/apache/karaf/itests/JmsTest.java b/itests/src/test/java/org/apache/karaf/itests/JmsTest.java index 21487de..417b9e5 100644 --- a/itests/src/test/java/org/apache/karaf/itests/JmsTest.java +++ b/itests/src/test/java/org/apache/karaf/itests/JmsTest.java @@ -72,7 +72,7 @@ public class JmsTest extends KarafTestSupport { @Test(timeout = 60000) public void testCommands() throws Exception { - execute("jms:create -t ActiveMQ -u karaf -p karaf --url tcp://localhost:61616 test"); + execute("jms:create -t activemq -u karaf -p karaf --url tcp://localhost:61616 test"); waitForConnectionFactory("name=test"); assertThat(execute("jms:connectionfactories"), containsString("jms/test")); http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java index bcaa016..aa367c9 100644 --- a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java +++ b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java @@ -82,7 +82,7 @@ public class JdbcServiceImpl implements JdbcService { @Override public void delete(String name) throws Exception { - String filter = String.format("(%s=%s)", DataSourceFactory.JDBC_DATASOURCE_NAME, name); + String filter = String.format("(&(service.factoryPid=org.ops4j.datasource)(%s=%s))", DataSourceFactory.JDBC_DATASOURCE_NAME, name); Configuration[] configs = configAdmin.listConfigurations(filter); for (Configuration config : configs) { config.delete(); http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/NOTICE ---------------------------------------------------------------------- diff --git a/jms/NOTICE b/jms/NOTICE new file mode 100644 index 0000000..ec9092f --- /dev/null +++ b/jms/NOTICE @@ -0,0 +1,67 @@ +Apache Karaf +Copyright 2010-2014 The Apache Software Foundation + + +I. Included Software + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). +Licensed under the Apache License 2.0. + +This product uses software developed at +The OSGi Alliance (http://www.osgi.org/). +Copyright (c) OSGi Alliance (2000, 2010). +Licensed under the Apache License 2.0. + +This product includes software developed at +OW2 (http://www.ow2.org/). +Licensed under the BSD License. + +This product includes software developed at +OPS4J (http://www.ops4j.org/). +Licensed under the Apache License 2.0. + +This product includes software developed at +Eclipse Foundation (http://www.eclipse.org/). +Licensed under the EPL. + +This product includes software written by +Antony Lesuisse. +Licensed under Public Domain. + + +II. Used Software + +This product uses software developed at +FUSE Source (http://www.fusesource.org/). +Licensed under the Apache License 2.0. + +This product uses software developed at +AOP Alliance (http://aopalliance.sourceforge.net/). +Licensed under the Public Domain. + +This product uses software developed at +Tanuki Software (http://www.tanukisoftware.com/). +Licensed under the Apache License 2.0. + +This product uses software developed at +Jasypt (http://jasypt.sourceforge.net/). +Licensed under the Apache License 2.0. + +This product uses software developed at +JLine (https://github.com/jline/). +Licensed under the BSD License. + +This product uses software developed at +SLF4J (http://www.slf4j.org/). +Licensed under the MIT License. + +This product uses software developed at +SpringSource (http://www.springsource.org/). +Licensed under the Apache License 2.0. + +III. License Summary +- Apache License 2.0 +- BSD License +- EPL License +- MIT License http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/NOTICE ---------------------------------------------------------------------- diff --git a/jms/core/NOTICE b/jms/core/NOTICE deleted file mode 100644 index f1f81e0..0000000 --- a/jms/core/NOTICE +++ /dev/null @@ -1,67 +0,0 @@ -Apache Karaf -Copyright 2010-2014 The Apache Software Foundation - - -I. Included Software - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). -Licensed under the Apache License 2.0. - -This product uses software developed at -The OSGi Alliance (http://www.osgi.org/). -Copyright (c) OSGi Alliance (2000, 2010). -Licensed under the Apache License 2.0. - -This product includes software developed at -OW2 (http://www.ow2.org/). -Licensed under the BSD License. - -This product includes software developed at -OPS4J (http://www.ops4j.org/). -Licensed under the Apache License 2.0. - -This product includes software developed at -Eclipse Foundation (http://www.eclipse.org/). -Licensed under the EPL. - -This product includes software written by -Antony Lesuisse. -Licensed under Public Domain. - - -II. Used Software - -This product uses software developed at -FUSE Source (http://www.fusesource.org/). -Licensed under the Apache License 2.0. - -This product uses software developed at -AOP Alliance (http://aopalliance.sourceforge.net/). -Licensed under the Public Domain. - -This product uses software developed at -Tanuki Software (http://www.tanukisoftware.com/). -Licensed under the Apache License 2.0. - -This product uses software developed at -Jasypt (http://jasypt.sourceforge.net/). -Licensed under the Apache License 2.0. - -This product uses software developed at -JLine (https://github.com/jline/). -Licensed under the BSD License. - -This product uses software developed at -SLF4J (http://www.slf4j.org/). -Licensed under the MIT License. - -This product uses software developed at -SpringSource (http://www.springsource.org/). -Licensed under the Apache License 2.0. - -III. License Summary -- Apache License 2.0 -- BSD License -- EPL License -- MIT License http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/pom.xml ---------------------------------------------------------------------- diff --git a/jms/core/pom.xml b/jms/core/pom.xml deleted file mode 100644 index 8d2d485..0000000 --- a/jms/core/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <!-- - - 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. - --> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.karaf</groupId> - <artifactId>karaf</artifactId> - <version>4.2.0-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <groupId>org.apache.karaf.jms</groupId> - <artifactId>org.apache.karaf.jms.core</artifactId> - <packaging>bundle</packaging> - <name>Apache Karaf :: JMS :: Core</name> - <description>This bundle provides core implementation of the JMS service.</description> - - <properties> - <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory> - </properties> - - <dependencies> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_1.1_spec</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-pool</artifactId> - <version>5.9.0</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jta_1.0.1B_spec</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.karaf</groupId> - <artifactId>org.apache.karaf.util</artifactId> - </dependency> - <dependency> - <groupId>org.apache.karaf.shell</groupId> - <artifactId>org.apache.karaf.shell.core</artifactId> - <optional>true</optional> - </dependency> - </dependencies> - - <build> - <resources> - <resource> - <directory>${project.basedir}/src/main/resources</directory> - <includes> - <include>**/*</include> - </includes> - </resource> - <resource> - <directory>${project.basedir}/src/main/resources</directory> - <filtering>true</filtering> - <includes> - <include>**/*.info</include> - </includes> - </resource> - </resources> - <plugins> - <plugin> - <groupId>org.apache.karaf.tooling</groupId> - <artifactId>karaf-services-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <configuration> - <instructions> - <Export-Package> - org.apache.karaf.jms;-noimport:=true - </Export-Package> - <Import-Package> - javax.jms;version="[1.1,3)", - org.apache.activemq*;resolution:=optional, - * - </Import-Package> - <Private-Package> - org.apache.karaf.jms.command, - org.apache.karaf.jms.command.completers, - org.apache.karaf.jms.internal, - org.apache.karaf.jms.internal.osgi, - org.apache.karaf.util, - org.apache.karaf.util.json - </Private-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/JmsMBean.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/JmsMBean.java b/jms/core/src/main/java/org/apache/karaf/jms/JmsMBean.java deleted file mode 100644 index d62a9ba..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/JmsMBean.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.karaf.jms; - -import javax.management.MBeanException; -import javax.management.openmbean.TabularData; -import java.util.List; -import java.util.Map; - -/** - * JMS MBean. - */ -public interface JmsMBean { - - /** - * List the JMS connection factories. - * - * @return The {@link List} of the JMS connection factories name. - * @throws MBeanException If the MBean fails. - */ - List<String> getConnectionfactories() throws MBeanException; - - /** - * Create a JMS connection factory. - * - * @param name The JMS connection factory name. - * @param type The JMS connection factory type (ActiveMQ or WebsphereMQ). - * @param url The JMS connection factory URL. NB: when type is WebsphereMQ, the URL has the format host/port/queuemanager/channel. - * @throws MBeanException If the MBean fails. - */ - void create(String name, String type, String url) throws MBeanException; - - /** - * Create a JMS connection factory. - * - * @param name The JMS connection factory name. - * @param type The JMS connection factory type (ActiveMQ or WebsphereMQ). - * @param url The JMS connection factory URL. NB: when type is WebsphereMQ, the URL has the format host/port/queuemanager/channel. - * @param username The JMS connection factory authentication username. - * @param password The JMS connection factory authentication password. - * @throws MBeanException If the MBean fails. - */ - void create(String name, String type, String url, String username, String password) throws MBeanException; - - /** - * Delete a JMS connection factory. - * - * @param name The JMS connection factory name. - * @throws MBeanException If the MBean fails. - */ - void delete(String name) throws MBeanException; - - /** - * Get details about a JMS connection factory. - * - * @param connectionFactory The JMS connection factory name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return A {@link Map} (property/value) containing details. - * @throws MBeanException If the MBean fails. - */ - Map<String, String> info(String connectionFactory, String username, String password) throws MBeanException; - - /** - * Count the messages on a given JMS queue. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The JMS queue name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The number of messages in the queue. - * @throws MBeanException If the MBean fails. - */ - int count(String connectionFactory, String queue, String username, String password) throws MBeanException; - - /** - * List the JMS queues. - * - * @param connectionFactory The JMS connection factory name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The {@link List} of JMS queues. - * @throws MBeanException If the MBean fails. - */ - List<String> queues(String connectionFactory, String username, String password) throws MBeanException; - - /** - * List the JMS topics. - * - * @param connectionFactory The JMS connection factory name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The @link List} of JMS topics. - * @throws MBeanException If the MBean fails. - */ - List<String> topics(String connectionFactory, String username, String password) throws MBeanException; - - /** - * Browse the messages in a JMS queue. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The JMS queue name. - * @param selector A selector to use to browse only certain messages. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return A {@link TabularData} containing messages details. - * @throws MBeanException If the MBean fails. - */ - TabularData browse(String connectionFactory, String queue, String selector, String username, String password) throws MBeanException; - - /** - * Send a JMS message to given queue. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The JMS queue name. - * @param content The message content. - * @param replyTo The message ReplyTo. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @throws MBeanException If the MBean fails. - */ - void send(String connectionFactory, String queue, String content, String replyTo, String username, String password) throws MBeanException; - - /** - * Consume JMS messages from a given queue. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The JMS queue name. - * @param selector A selector to use to consume only certain messages. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The number of messages consumed. - * @throws MBeanException If the MBean fails. - */ - int consume(String connectionFactory, String queue, String selector, String username, String password) throws MBeanException; - - /** - * Move JMS messages from one queue to another. - * - * @param connectionFactory The JMS connection factory name. - * @param source The source JMS queue name. - * @param destination The destination JMS queue name. - * @param selector A selector to move only certain messages. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The number of messages moved. - * @throws MBeanException If the MBean fails. - */ - int move(String connectionFactory, String source, String destination, String selector, String username, String password) throws MBeanException; - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/JmsMessage.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/JmsMessage.java b/jms/core/src/main/java/org/apache/karaf/jms/JmsMessage.java deleted file mode 100644 index acf13bf..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/JmsMessage.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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.karaf.jms; - -import javax.jms.*; -import java.io.UnsupportedEncodingException; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; - -/** - * Describe a JMS message is more human readable way. - */ -public class JmsMessage { - - private Map<String, Object> properties = new HashMap<>(); - - private String content; - private String charset = "UTF-8"; - private String correlationID; - private String deliveryMode; - private String destination; - private String expiration; - private String messageId; - private int priority; - private boolean redelivered; - private String replyTo; - private String timestamp; - private String type; - - public JmsMessage(Message message) { - try { - initFromMessage(message); - } catch (JMSException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - - public void initFromMessage(Message message) throws JMSException { - @SuppressWarnings("unchecked") - Enumeration<String> names = message.getPropertyNames(); - while (names.hasMoreElements()) { - String key = names.nextElement(); - Object value = message.getObjectProperty(key); - properties.put(key, value); - } - - correlationID = message.getJMSCorrelationID(); - if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) { - deliveryMode = "Non Persistent"; - } else { - deliveryMode = "Persistent"; - } - Destination destinationDest = message.getJMSDestination(); - if (destinationDest != null) { - destination = destinationDest.toString(); - } - if (message.getJMSExpiration() > 0) { - expiration = new Date(message.getJMSExpiration()).toString(); - } else { - expiration = "Never"; - } - messageId = message.getJMSMessageID(); - priority = message.getJMSPriority(); - redelivered = message.getJMSRedelivered(); - Destination replyToDest = message.getJMSReplyTo(); - if (replyToDest != null) { - replyTo = replyToDest.toString(); - } - if (message.getJMSTimestamp() > 0) { - timestamp = new Date(message.getJMSTimestamp()).toString(); - } else { - timestamp = ""; - } - type = message.getJMSType(); - content = getMessageContent(message); - } - - - private String getMessageContent(Message message) throws JMSException { - if (message instanceof TextMessage) { - return ((TextMessage) message).getText(); - } else if (message instanceof BytesMessage) { - BytesMessage bMessage = (BytesMessage) message; - long length = bMessage.getBodyLength(); - byte[] content = new byte[(int) length]; - bMessage.readBytes(content); - try { - return new String(content, charset); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - return ""; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public String getContent() { - return content; - } - - public String getCharset() { - return charset; - } - - public String getCorrelationID() { - return correlationID; - } - - public String getDeliveryMode() { - return deliveryMode; - } - - public String getDestination() { - return destination; - } - - public String getExpiration() { - return expiration; - } - - public String getMessageId() { - return messageId; - } - - public int getPriority() { - return priority; - } - - public boolean isRedelivered() { - return redelivered; - } - - public String getReplyTo() { - return replyTo; - } - - public String getTimestamp() { - return timestamp; - } - - public String getType() { - return type; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/JmsService.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/JmsService.java b/jms/core/src/main/java/org/apache/karaf/jms/JmsService.java deleted file mode 100644 index 0902e33..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/JmsService.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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.karaf.jms; - -import java.util.List; -import java.util.Map; - -/** - * JMS Service. - */ -public interface JmsService { - - /** - * List the JMS connection factories. - * - * @return The {@link List} of JMS connection factory names. - * @throws Exception If the service fails. - */ - List<String> connectionFactories() throws Exception; - - /** - * List the JMS connection factories file names. - * - * @return The {@link List} of JMS connection factory file names. - * @throws Exception If the service fails. - */ - List<String> connectionFactoryFileNames() throws Exception; - - /** - * Create a new JMS connection factory. - * - * @param name The JMS connection factory name. - * @param type The JMS connection factory type (ActiveMQ, WebsphereMQ, ...). - * @param url The JMS URL to use. - * @throws Exception If the service fails. - */ - void create(String name, String type, String url) throws Exception; - - /** - * Create a new JMS connection factory. - * - * @param name The JMS connection factory name. - * @param type The JMS connection factory type (ActiveMQ, WebsphereMQ, ...). - * @param url The JMS URL to use. - * @param username The username to use. - * @param password The password to use. - * @throws Exception If the service fails. - */ - void create(String name, String type, String url, String username, String password) throws Exception; - - /** - * Delete a JMS connection factory. - * - * @param name The JMS connection factory name. - * @throws Exception If the service fails. - */ - void delete(String name) throws Exception; - - /** - * Get details about a given JMS connection factory. - * - * @param connectionFactory The JMS connection factory name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return A {@link Map} (property/value) containing details. - * @throws Exception If the service fails. - */ - Map<String, String> info(String connectionFactory, String username, String password) throws Exception; - - /** - * Count the number of messages in a JMS queue. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The queue name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The number of messages in a JMS queue. - * @throws Exception If the service fails. - */ - int count(String connectionFactory, String queue, String username, String password) throws Exception; - - /** - * List the queues. - * - * @param connectionFactory The JMS connection factory name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The {@link List} of queues. - * @throws Exception If the service fails. - */ - List<String> queues(String connectionFactory, String username, String password) throws Exception; - - /** - * List the topics. - * - * @param connectionFactory The JMS connection factory name. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The {@link List} of topics. - * @throws Exception If the service fails. - */ - List<String> topics(String connectionFactory, String username, String password) throws Exception; - - /** - * Browse a destination. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The queue name. - * @param selector The selector. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The {@link List} of messages. - * @throws Exception If the service fails. - */ - List<JmsMessage> browse(String connectionFactory, String queue, String selector, String username, String password) throws Exception; - - /** - * Send a message on the given queue. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The queue name. - * @param body The message body. - * @param replyTo The message replyTo header. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @throws Exception If the service fails. - */ - void send(String connectionFactory, String queue, String body, String replyTo, String username, String password) throws Exception; - - /** - * Consume messages from a given destination. - * - * @param connectionFactory The JMS connection factory name. - * @param queue The queue name. - * @param selector The messages selector. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The number of messages consumed. - * @throws Exception If the service fails. - */ - int consume(String connectionFactory, String queue, String selector, String username, String password) throws Exception; - - /** - * Move messages from a destination to another. - * - * @param connectionFactory The JMS connection factory name. - * @param sourceQueue The source queue. - * @param targetQueue The target queue. - * @param selector The messages selector on the source queue. - * @param username The (optional) username to connect to the JMS broker. - * @param password The (optional) password to connect to the JMS broker. - * @return The number of messages moved. - * @throws Exception If the service fails. - */ - int move(String connectionFactory, String sourceQueue, String targetQueue, String selector, String username, String password) throws Exception; - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/BrowseCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/BrowseCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/BrowseCommand.java deleted file mode 100644 index cb86aa6..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/BrowseCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.karaf.jms.command; - -import java.util.List; - -import org.apache.karaf.jms.JmsMessage; -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.Option; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.table.ShellTable; - -@Command(scope = "jms", name = "browse", description = "Browse a JMS queue") -@Service -public class BrowseCommand extends JmsConnectionCommandSupport { - - @Argument(index = 1, name = "queue", description = "The JMS queue to browse", required = true, multiValued = false) - String queue; - - @Option(name = "-s", aliases = { "--selector" }, description = "The selector to select the messages to browse", required = false, multiValued = false) - String selector; - - @Option(name = "-v", aliases = { "--verbose" }, description = "Display JMS properties", required = false, multiValued = false) - boolean verbose = false; - - @Override - public Object execute() throws Exception { - - ShellTable table = new ShellTable(); - table.column("Message ID"); - table.column("Content").maxSize(80); - table.column("Charset"); - table.column("Type"); - table.column("Correlation ID"); - table.column("Delivery Mode"); - table.column("Destination"); - table.column("Expiration"); - table.column("Priority"); - table.column("Redelivered"); - table.column("ReplyTo"); - table.column("Timestamp"); - if (verbose) { - table.column("Properties"); - } - - List<JmsMessage> messages = getJmsService().browse(connectionFactory, queue, selector, username, password); - for (JmsMessage message : messages) { - if (verbose) { - StringBuilder properties = new StringBuilder(); - for (String property : message.getProperties().keySet()) { - properties.append(property).append("=").append(message.getProperties().get(property)).append("\n"); - } - table.addRow().addContent( - message.getMessageId(), - message.getContent(), - message.getCharset(), - message.getType(), - message.getCorrelationID(), - message.getDeliveryMode(), - message.getDestination(), - message.getExpiration(), - message.getPriority(), - message.isRedelivered(), - message.getReplyTo(), - message.getTimestamp(), - properties.toString()); - } else { - table.addRow().addContent( - message.getMessageId(), - message.getContent(), - message.getCharset(), - message.getType(), - message.getCorrelationID(), - message.getDeliveryMode(), - message.getDestination(), - message.getExpiration(), - message.getPriority(), - message.isRedelivered(), - message.getReplyTo(), - message.getTimestamp()); - } - } - - table.print(System.out); - - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/ConnectionFactoriesCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/ConnectionFactoriesCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/ConnectionFactoriesCommand.java deleted file mode 100644 index b698336..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/ConnectionFactoriesCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.karaf.jms.command; - -import java.util.List; - -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.table.ShellTable; - -@Command(scope = "jms", name = "connectionfactories", description = "List the JMS connection factories") -@Service -public class ConnectionFactoriesCommand extends JmsCommandSupport { - - @Override - public Object execute() throws Exception { - - ShellTable table = new ShellTable(); - table.column("JMS Connection Factory"); - - List<String> connectionFactories = getJmsService().connectionFactories(); - for (String connectionFactory : connectionFactories) { - table.addRow().addContent(connectionFactory); - } - - table.print(System.out); - - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/ConsumeCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/ConsumeCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/ConsumeCommand.java deleted file mode 100644 index cd8caaf..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/ConsumeCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.karaf.jms.command; - -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.Option; -import org.apache.karaf.shell.api.action.lifecycle.Service; - -@Command(scope = "jms", name = "consume", description = "Consume messages from a JMS queue.") -@Service -public class ConsumeCommand extends JmsConnectionCommandSupport { - - @Argument(index = 1, name = "queue", description = "The JMS queue where to consume messages", required = true, multiValued = false) - String queue; - - @Option(name = "-s", aliases = { "--selector" }, description = "The selector to use to select the messages to consume", required = false, multiValued = false) - String selector; - - @Override - public Object execute() throws Exception { - System.out.println(getJmsService().consume(connectionFactory, queue, selector, username, password) + " message(s) consumed"); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/CountCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/CountCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/CountCommand.java deleted file mode 100644 index 576e8dd..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/CountCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.table.ShellTable; - -@Command(scope = "jms", name = "count", description = "Count the number of messages on a JMS queue.") -@Service -public class CountCommand extends JmsConnectionCommandSupport { - - @Argument(index = 1, name = "queue", description = "The JMS queue name", required = true, multiValued = false) - String queue; - - @Override - public Object execute() throws Exception { - ShellTable table = new ShellTable(); - table.column("Messages Count"); - table.addRow().addContent(getJmsService().count(connectionFactory, queue, username, password)); - table.print(System.out); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/CreateCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/CreateCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/CreateCommand.java deleted file mode 100644 index 64ccf02..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/CreateCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.karaf.jms.command; - -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.Completion; -import org.apache.karaf.shell.api.action.Option; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.completers.StringsCompleter; - -@Command(scope = "jms", name = "create", description = "Create a JMS connection factory.") -@Service -public class CreateCommand extends JmsCommandSupport { - - @Argument(index = 0, name = "name", description = "The JMS connection factory name", required = true, multiValued = false) - String name; - - @Option(name = "-t", aliases = { "--type" }, description = "The JMS connection factory type (ActiveMQ, Artemis or WebsphereMQ)", required = false, multiValued = false) - @Completion(value = StringsCompleter.class, values = { "activemq", "artemis", "webspheremq" }) - String type = "ActiveMQ"; - - @Option(name = "--url", description = "URL of the JMS broker. For WebsphereMQ type, the URL is hostname/port/queuemanager/channel", required = false, multiValued = false) - String url = "tcp://localhost:61616"; - - @Option(name = "-u", aliases = { "--username" }, description = "Username to connect to the JMS broker", required = false, multiValued = false) - String username = "karaf"; - - @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false) - String password = "karaf"; - - @Override - public Object execute() throws Exception { - getJmsService().create(name, type, url, username, password); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/DeleteCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/DeleteCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/DeleteCommand.java deleted file mode 100644 index cab3123..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/DeleteCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import org.apache.karaf.jms.command.completers.ConnectionFactoriesFileNameCompleter; -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.Completion; -import org.apache.karaf.shell.api.action.lifecycle.Service; - -@Command(scope = "jms", name = "delete", description = "Delete a JMS connection factory") -@Service -public class DeleteCommand extends JmsCommandSupport { - - @Argument(index = 0, name = "name", description = "The JMS connection factory name", required = true, multiValued = false) - @Completion(ConnectionFactoriesFileNameCompleter.class) - String name; - - @Override - public Object execute() throws Exception { - getJmsService().delete(name); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/InfoCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/InfoCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/InfoCommand.java deleted file mode 100644 index 354db39..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/InfoCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import java.util.Map; - -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.table.ShellTable; - -@Command(scope = "jms", name = "info", description = "Provides details about a JMS connection factory.") -@Service -public class InfoCommand extends JmsConnectionCommandSupport { - - @Override - public Object execute() throws Exception { - ShellTable table = new ShellTable(); - table.column("Property"); - table.column("Value"); - - Map<String, String> info = getJmsService().info(connectionFactory, username, password); - for (String key : info.keySet()) { - table.addRow().addContent(key, info.get(key)); - } - - table.print(System.out); - - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/JmsCommandSupport.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/JmsCommandSupport.java b/jms/core/src/main/java/org/apache/karaf/jms/command/JmsCommandSupport.java deleted file mode 100644 index 2f5df8f..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/JmsCommandSupport.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.karaf.jms.command; - -import org.apache.karaf.jms.JmsService; -import org.apache.karaf.shell.api.action.Action; -import org.apache.karaf.shell.api.action.lifecycle.Reference; - -public abstract class JmsCommandSupport implements Action { - - @Reference - private JmsService jmsService; - - public JmsService getJmsService() { - return jmsService; - } - - public void setJmsService(JmsService jmsService) { - this.jmsService = jmsService; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/JmsConnectionCommandSupport.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/JmsConnectionCommandSupport.java b/jms/core/src/main/java/org/apache/karaf/jms/command/JmsConnectionCommandSupport.java deleted file mode 100644 index 64adfe4..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/JmsConnectionCommandSupport.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.karaf.jms.command; - -import org.apache.karaf.jms.command.completers.ConnectionFactoriesNameCompleter; -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Completion; -import org.apache.karaf.shell.api.action.Option; - -/** - * For commands that need a connection factory and authentication information - */ -public abstract class JmsConnectionCommandSupport extends JmsCommandSupport { - - @Argument(index = 0, name = "connectionFactory", description = "The JMS connection factory name", required = true, multiValued = false) - @Completion(ConnectionFactoriesNameCompleter.class) - String connectionFactory; - - @Option(name = "-u", aliases = { "--username" }, description = "Username to connect to the JMS broker", required = false, multiValued = false) - String username = "karaf"; - - @Option(name = "-p", aliases = { "--password" }, description = "Password to connect to the JMS broker", required = false, multiValued = false) - String password = "karaf"; - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/MoveCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/MoveCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/MoveCommand.java deleted file mode 100644 index a4c8d12..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/MoveCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.Option; -import org.apache.karaf.shell.api.action.lifecycle.Service; - -@Command(scope = "jms", name = "move", description = "Move messages from one JMS queue to another one.") -@Service -public class MoveCommand extends JmsConnectionCommandSupport { - - @Argument(index = 1, name = "source", description = "The source JMS queue", required = true, multiValued = false) - String source; - - @Argument(index = 2, name = "destination", description = "The destination JMS queue", required = true, multiValued = false) - String destination; - - @Option(name = "-s", aliases = { "--selector" }, description = "Selector to move only some messages", required = false, multiValued = false) - String selector; - - @Override - public Object execute() throws Exception { - System.out.println(getJmsService().move(connectionFactory, source, destination, selector, username, password) + " message(s) moved"); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/QueuesCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/QueuesCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/QueuesCommand.java deleted file mode 100644 index 7cf1dac..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/QueuesCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.table.ShellTable; - -@Command(scope = "jms", name = "queues", description = "List the JMS queues.") -@Service -public class QueuesCommand extends JmsConnectionCommandSupport { - - @Override - public Object execute() throws Exception { - ShellTable table = new ShellTable(); - - table.column("JMS Queues"); - - for (String queue : getJmsService().queues(connectionFactory, username, password)) { - table.addRow().addContent(queue); - } - - table.print(System.out); - - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/SendCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/SendCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/SendCommand.java deleted file mode 100644 index 63d3f4a..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/SendCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import org.apache.karaf.shell.api.action.Argument; -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.Option; -import org.apache.karaf.shell.api.action.lifecycle.Service; - -@Command(scope = "jms", name = "send", description = "Send a message to ") -@Service -public class SendCommand extends JmsConnectionCommandSupport { - - @Argument(index = 1, name = "queue", description = "The JMS queue name", required = true, multiValued = false) - String queue; - - @Argument(index = 2, name = "message", description = "The JMS message content", required = true, multiValued = false) - String message; - - @Option(name = "-r", aliases = { "--replyTo" }, description = "Set the message ReplyTo", required = false, multiValued = false) - String replyTo; - - @Override - public Object execute() throws Exception { - getJmsService().send(connectionFactory, queue, message, replyTo, username, password); - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/TopicsCommand.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/TopicsCommand.java b/jms/core/src/main/java/org/apache/karaf/jms/command/TopicsCommand.java deleted file mode 100644 index b583bc4..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/TopicsCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.karaf.jms.command; - - -import org.apache.karaf.shell.api.action.Command; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.support.table.ShellTable; - -@Command(scope = "jms", name = "topics", description = "List the JMS topics.") -@Service -public class TopicsCommand extends JmsConnectionCommandSupport { - - @Override - public Object execute() throws Exception { - ShellTable table = new ShellTable(); - - table.column("JMS Topics"); - - for (String topic : getJmsService().topics(connectionFactory, username, password)) { - table.addRow().addContent(topic); - } - - table.print(System.out); - - return null; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesFileNameCompleter.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesFileNameCompleter.java b/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesFileNameCompleter.java deleted file mode 100644 index c33ff62..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesFileNameCompleter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.karaf.jms.command.completers; - -import java.util.List; - -import org.apache.karaf.jms.JmsService; -import org.apache.karaf.shell.api.action.lifecycle.Reference; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.api.console.CommandLine; -import org.apache.karaf.shell.api.console.Completer; -import org.apache.karaf.shell.api.console.Session; -import org.apache.karaf.shell.support.completers.StringsCompleter; - -/** - * Completer on the JMS connection factory file names. - */ -@Service -public class ConnectionFactoriesFileNameCompleter implements Completer { - - @Reference - private JmsService jmsService; - - @Override - public int complete(Session session, CommandLine commandLine, List<String> candidates) { - StringsCompleter delegate = new StringsCompleter(); - try { - for (String connectionFactory : jmsService.connectionFactoryFileNames()) { - delegate.getStrings().add(connectionFactory.replace("connectionfactory-", "").replace(".xml", "")); - } - } catch (Exception e) { - // nothing to do - } - return delegate.complete(session, commandLine, candidates); - } - - public JmsService getJmsService() { - return jmsService; - } - - public void setJmsService(JmsService jmsService) { - this.jmsService = jmsService; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesNameCompleter.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesNameCompleter.java b/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesNameCompleter.java deleted file mode 100644 index 98f97b3..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/command/completers/ConnectionFactoriesNameCompleter.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.karaf.jms.command.completers; - -import java.util.List; - -import org.apache.karaf.jms.JmsService; -import org.apache.karaf.shell.api.action.lifecycle.Reference; -import org.apache.karaf.shell.api.action.lifecycle.Service; -import org.apache.karaf.shell.api.console.CommandLine; -import org.apache.karaf.shell.api.console.Completer; -import org.apache.karaf.shell.api.console.Session; -import org.apache.karaf.shell.support.completers.StringsCompleter; - -/** - * Completer on the JMS connection factories name. - */ -@Service -public class ConnectionFactoriesNameCompleter implements Completer { - - @Reference - private JmsService jmsService; - - @Override - public int complete(Session session, CommandLine commandLine, List<String> candidates) { - StringsCompleter delegate = new StringsCompleter(); - try { - for (String connectionFactory : jmsService.connectionFactories()) { - delegate.getStrings().add(connectionFactory); - } - } catch (Exception e) { - // nothing to do - } - return delegate.complete(session, commandLine, candidates); - } - - public JmsService getJmsService() { - return jmsService; - } - - public void setJmsService(JmsService jmsService) { - this.jmsService = jmsService; - } - -} http://git-wip-us.apache.org/repos/asf/karaf/blob/7a84233c/jms/core/src/main/java/org/apache/karaf/jms/internal/ActiveMQDestinationSourceFactory.java ---------------------------------------------------------------------- diff --git a/jms/core/src/main/java/org/apache/karaf/jms/internal/ActiveMQDestinationSourceFactory.java b/jms/core/src/main/java/org/apache/karaf/jms/internal/ActiveMQDestinationSourceFactory.java deleted file mode 100644 index a6e5cb7..0000000 --- a/jms/core/src/main/java/org/apache/karaf/jms/internal/ActiveMQDestinationSourceFactory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.karaf.jms.internal; - -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.Queue; -import javax.jms.Topic; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -class ActiveMQDestinationSourceFactory implements DestinationSource.Factory { - - @Override - public DestinationSource create(Connection connection) throws JMSException { - if (connection.getClass().getName().matches("org\\.apache\\.activemq\\.ActiveMQ(XA)?Connection")) { - try { - final Object destSource = connection.getClass().getMethod("getDestinationSource").invoke(connection); - return type -> getNames(destSource, type); - } catch (Exception e) { - // Ignore - } - } - return null; - } - - private List<String> getNames(Object destSource, DestinationSource.DestinationType type) { - try { - if (type == DestinationSource.DestinationType.Queue) { - @SuppressWarnings("unchecked") - Set<Queue> queues = (Set) destSource.getClass().getMethod("getQueues").invoke(destSource); - List<String> names = new ArrayList<>(); - for (Queue queue : queues) { - names.add(queue.getQueueName()); - } - return names; - } - if (type == DestinationSource.DestinationType.Topic) { - @SuppressWarnings("unchecked") - Set<Topic> topics = (Set) destSource.getClass().getMethod("getTopics").invoke(destSource); - List<String> names = new ArrayList<>(); - for (Topic topic : topics) { - names.add(topic.getTopicName()); - } - return names; - } - } catch (Exception e) { - // Ignore - } - return Collections.emptyList(); - } -}
