You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/11/19 18:23:31 UTC
[activemq-artemis] branch main updated: ARTEMIS-3546 Jakarta javax.json incompability on jakarta all client
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new bfc10dc ARTEMIS-3546 Jakarta javax.json incompability on jakarta all client
new 8c63d9a This closes #3846
bfc10dc is described below
commit bfc10dcf8bcb1663519fb74907623a5f6b1d0710
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Wed Nov 10 16:31:19 2021 -0500
ARTEMIS-3546 Jakarta javax.json incompability on jakarta all client
Domenico Bruscino provided the JSON Wrapper used here. Thanks Domenico!
---
artemis-cli/pom.xml | 23 +-
.../artemis/cli/commands/queue/StatQueue.java | 4 +-
.../artemis/cli/commands/user/ListUser.java | 7 +-
.../org/apache/activemq/cli/test/ArtemisTest.java | 4 +-
artemis-commons/pom.xml | 63 +++++-
.../artemis/api/core/QueueConfiguration.java | 8 +-
.../apache/activemq/artemis/json/JsonArray.java | 159 ++++++++++++++
.../activemq/artemis/json/JsonArrayBuilder.java | 142 +++++++++++++
.../apache/activemq/artemis/json/JsonNumber.java | 63 ++++++
.../apache/activemq/artemis/json/JsonObject.java | 105 +++++++++
.../activemq/artemis/json/JsonObjectBuilder.java | 155 ++++++++++++++
.../apache/activemq/artemis/json/JsonString.java | 32 +++
.../apache/activemq/artemis/json/JsonValue.java | 74 +++++++
.../artemis/json/impl/JsonArrayBuilderImpl.java | 125 +++++++++++
.../activemq/artemis/json/impl/JsonArrayImpl.java | 234 +++++++++++++++++++++
.../activemq/artemis/json/impl/JsonNumberImpl.java | 87 ++++++++
.../artemis/json/impl/JsonObjectBuilderImpl.java | 155 ++++++++++++++
.../activemq/artemis/json/impl/JsonObjectImpl.java | 217 +++++++++++++++++++
.../activemq/artemis/json/impl/JsonStringImpl.java | 44 ++++
.../activemq/artemis/json/impl/JsonValueImpl.java | 116 ++++++++++
.../apache/activemq/artemis/utils/JsonLoader.java | 46 ++--
artemis-core-client-osgi/pom.xml | 2 +-
artemis-core-client/pom.xml | 25 ++-
.../apache/activemq/artemis/api/core/JsonUtil.java | 16 +-
.../artemis/api/core/TransportConfiguration.java | 2 +-
.../api/core/management/AddressSettingsInfo.java | 2 +-
.../api/core/management/DayCounterInfo.java | 8 +-
.../api/core/management/ManagementHelper.java | 2 +-
.../api/core/management/MessageCounterInfo.java | 2 +-
.../artemis/api/core/management/NodeInfo.java | 4 +-
.../artemis/api/core/management/RoleInfo.java | 4 +-
.../core/config/TransformerConfiguration.java | 6 +-
.../activemq/artemis/core/security/Role.java | 2 +-
.../activemq/artemis/api/core/JsonUtilTest.java | 8 +-
artemis-distribution/pom.xml | 8 -
artemis-distribution/src/main/assembly/dep.xml | 2 -
artemis-features/src/main/resources/features.xml | 3 -
artemis-jakarta-client-all/pom.xml | 5 -
artemis-jakarta-server/pom.xml | 6 -
artemis-jms-client-all/pom.xml | 4 -
artemis-jms-client-osgi/pom.xml | 2 +-
artemis-jms-server/pom.xml | 4 -
.../artemis/maven/ArtemisClientPlugin.java | 27 ++-
artemis-server-osgi/pom.xml | 2 +-
artemis-server/pom.xml | 19 +-
.../artemis/core/config/BridgeConfiguration.java | 21 +-
.../management/impl/ActiveMQServerControlImpl.java | 8 +-
.../core/management/impl/AddressControlImpl.java | 2 +-
.../management/impl/BrokerBalancerControlImpl.java | 2 +-
.../core/management/impl/QueueControlImpl.java | 6 +-
.../management/impl/view/ActiveMQAbstractView.java | 6 +-
.../core/management/impl/view/AddressView.java | 2 +-
.../core/management/impl/view/ConnectionView.java | 2 +-
.../core/management/impl/view/ConsumerView.java | 2 +-
.../core/management/impl/view/ProducerView.java | 2 +-
.../core/management/impl/view/QueueView.java | 2 +-
.../core/management/impl/view/SessionView.java | 2 +-
.../core/messagecounter/MessageCounter.java | 7 +-
.../artemis/core/server/ServerSession.java | 2 +-
.../artemis/core/server/impl/AddressInfo.java | 14 +-
.../core/server/impl/ServerSessionImpl.java | 9 +-
.../core/transaction/TransactionDetail.java | 6 +-
.../core/config/BridgeConfigurationTest.java | 9 +-
examples/features/standard/pom.xml | 1 +
examples/features/standard/queue-jakarta/pom.xml | 15 ++
.../activemq/artemis/jms/example/QueueExample.java | 25 +--
.../src/main/resources/jndi.properties | 20 --
pom.xml | 39 ++--
tests/compatibility-tests/pom.xml | 25 ++-
.../ActiveMQServerControlMultiThreadTest.java | 4 +-
tests/integration-tests/pom.xml | 26 ++-
.../tests/integration/amqp/JMXManagementTest.java | 4 +-
.../integration/karaf/ArtemisFeatureTest.java | 10 +-
.../management/ActiveMQServerControlTest.java | 4 +-
.../integration/management/AddressControlTest.java | 4 +-
.../management/BroadcastGroupControlTest.java | 2 +-
.../management/BrokerBalancerControlTest.java | 4 +-
.../management/ClusterConnectionControlTest.java | 2 +-
.../JGroupsChannelBroadcastGroupControlTest.java | 2 +-
.../JGroupsFileBroadcastGroupControlTest.java | 2 +-
.../management/ManagementWithPagingServerTest.java | 10 +-
.../integration/management/QueueControlTest.java | 4 +-
tests/joram-tests/pom.xml | 14 ++
tests/smoke-tests/pom.xml | 15 ++
.../tests/smoke/jmx2/JmxServerControlTest.java | 4 +-
.../ReplicatedMultipleFailbackTest.java | 35 ++-
.../activemq/artemis/tests/smoke/utils/Jmx.java | 35 ++-
87 files changed, 2113 insertions(+), 325 deletions(-)
diff --git a/artemis-cli/pom.xml b/artemis-cli/pom.xml
index 155791a..4a4369d 100644
--- a/artemis-cli/pom.xml
+++ b/artemis-cli/pom.xml
@@ -77,14 +77,6 @@
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
- <dependency>
- <groupId>jakarta.jms</groupId>
- <artifactId>jakarta.jms-api</artifactId>
- </dependency>
- <dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- </dependency>
<!-- artemis producer and consumer can use amqp as the protocol -->
<dependency>
<groupId>org.apache.qpid</groupId>
@@ -162,6 +154,21 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
+
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
index a949ead..5791d0a 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
@@ -24,8 +24,8 @@ import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.cli.commands.AbstractAction;
import org.apache.activemq.artemis.cli.commands.ActionContext;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/ListUser.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/ListUser.java
index 11a51f7..0704f29 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/ListUser.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/user/ListUser.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.cli.commands.user;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import io.airlift.airline.Command;
import org.apache.activemq.artemis.api.core.JsonUtil;
@@ -72,7 +72,8 @@ public class ListUser extends UserAction {
// process the JSON results from the broker
JsonArray array = JsonUtil.readJsonArray(result[0]);
- for (JsonObject object : array.getValuesAs(JsonObject.class)) {
+ for (int arrayIndex = 0; arrayIndex < array.size(); arrayIndex++) {
+ JsonObject object = array.getJsonObject(arrayIndex);
logMessage.append("\"").append(object.getString("username")).append("\"").append("(");
JsonArray roles = object.getJsonArray("roles");
for (int i = 0; i < roles.size(); i++) {
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index f16cb2a..f453cb6 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -24,8 +24,8 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
diff --git a/artemis-commons/pom.xml b/artemis-commons/pom.xml
index d244029..8f013d0 100644
--- a/artemis-commons/pom.xml
+++ b/artemis-commons/pom.xml
@@ -32,6 +32,25 @@
</properties>
<dependencies>
+
+ <!-- Johnzon and JSON is meant to be referenced only here on this package (commons)
+ and we should not leak any dependencies to JSON or Johnzon in any of our packages.
+ Any other references would be meant for tests. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>compile</scope>
+ <optional>true</optional>
+ <!-- License: EPL 2.0 -->
+ </dependency>
+ <!-- ^^ these dependencies are shaded on this JAR -->
+
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
@@ -53,6 +72,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly.common</groupId>
@@ -81,10 +101,6 @@
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -111,6 +127,45 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/**/*</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ <relocations>
+ <relocation>
+ <pattern>javax.json</pattern>
+ <shadedPattern>org.apache.activemq.artemis.commons.shaded.json</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.johnzon</pattern>
+ <shadedPattern>org.apache.activemq.artemis.commons.shaded.johnzon</shadedPattern>
+ </relocation>
+ </relocations>
+ <artifactSet>
+ <includes>
+ <include>org.apache.johnzon:johnzon-core</include>
+ <include>jakarta.json:jakarta.json-api</include>
+ </includes>
+ </artifactSet>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java
index b0a2ae6..ef4396d 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/QueueConfiguration.java
@@ -17,10 +17,10 @@
package org.apache.activemq.artemis.api.core;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonString;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
import java.io.Serializable;
import java.io.StringReader;
import java.util.Map;
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonArray.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonArray.java
new file mode 100644
index 0000000..88833de
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonArray.java
@@ -0,0 +1,159 @@
+/*
+ * 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.artemis.json;
+
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * A JsonArray e.g.
+ * <pre>
+ * [1,5,8]
+ * </pre>
+ * or
+ * <pre>
+ * [
+ * {"name":"karl", "age": 38},
+ * {"name":"sue", "age": 42},
+ * ]
+ * </pre>
+ *
+ *
+ */
+public interface JsonArray extends JsonValue, List<JsonValue> {
+
+ /**
+ * @return the JsonObject at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to the JsonObject
+ */
+ JsonObject getJsonObject(int index);
+
+ /**
+ * @return the JsonArray at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to the JsonArray
+ */
+ JsonArray getJsonArray(int index);
+
+ /**
+ * @return the JsonNumber at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to the JsonNumber
+ */
+ JsonNumber getJsonNumber(int index);
+
+ /**
+ * @return the JsonString at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to the JsonString
+ */
+ JsonString getJsonString(int index);
+
+ /**
+ * @return the respective JsonValue at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to the given slazz
+ */
+ <T extends JsonValue> List<T> getValuesAs(Class<T> clazz);
+
+ /**
+ * Returns a list for the array. The value and the type of the elements
+ * in the list is specified by the {@code func} argument.
+ * <p>This method can be used to obtain a list of the unwrapped types, such as
+ * <pre>{@code
+ * List<String> strings = ary1.getValuesAs(JsonString::getString);
+ * List<Integer> ints = ary2.getValuesAs(JsonNumber::intValue);
+ * } </pre>
+ * It can also be used to obtain a list of simple projections, such as
+ * <pre> {@code
+ * Lsit<Integer> stringsizes = arr.getValueAs((JsonString v) -> v.getString().length();
+ * } </pre>
+ * @param <K> The element type (must be a subtype of JsonValue) of this JsonArray.
+ * @param <T> The element type of the returned List
+ * @param func The function that maps the elements of this JsonArray to the target elements.
+ * @return A List of the specified values and type.
+ * @throws ClassCastException if the {@code JsonArray} contains a value of wrong type
+ */
+ default <T, K extends JsonValue> List<T> getValuesAs(Function<K, T> func) {
+ Stream<K> stream = (Stream<K>) stream();
+ return stream.map(func).collect(Collectors.toList());
+ }
+
+ /**
+ * @return the native String at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to a String
+ */
+ String getString(int index);
+
+ /**
+ * @return the native String at the given position or the defaultValue if null
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to a String
+ */
+ String getString(int index, String defaultValue);
+
+ /**
+ * @return the native int value at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to an int
+ * @throws NullPointerException if an object with the given name doesn't exist
+ */
+ int getInt(int index);
+
+ /**
+ * @return the native int value at the given position or the defaultValue if null
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to an int
+ */
+ int getInt(int index, int defaultValue);
+
+ /**
+ * @return the native boolean value at the given position
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to a boolean
+ * @throws NullPointerException if an object with the given name doesn't exist
+ */
+ boolean getBoolean(int index);
+
+ /**
+ * @return the native boolean value at the given position or the defaultValue if null
+ * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws ClassCastException if the value at the specified position is not
+ * assignable to a boolean
+ */
+ boolean getBoolean(int index, boolean defaultValue);
+
+ /**
+ * @return whether the value at the given position is {@link JsonValue#NULL}.
+ * @throws IndexOutOfBoundsException if the index is out of range
+ */
+ boolean isNull(int index);
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonArrayBuilder.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonArrayBuilder.java
new file mode 100644
index 0000000..17a8d98
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonArrayBuilder.java
@@ -0,0 +1,142 @@
+/*
+ * 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.artemis.json;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public interface JsonArrayBuilder {
+ JsonArrayBuilder add(JsonValue value);
+
+ JsonArrayBuilder add(String value);
+
+ JsonArrayBuilder add(BigDecimal value);
+
+ JsonArrayBuilder add(BigInteger value);
+
+ JsonArrayBuilder add(int value);
+
+ JsonArrayBuilder add(long value);
+
+ JsonArrayBuilder add(double value);
+
+ JsonArrayBuilder add(boolean value);
+
+ JsonArrayBuilder addNull();
+
+ JsonArrayBuilder add(JsonObjectBuilder builder);
+
+ JsonArrayBuilder add(JsonArrayBuilder builder);
+
+ JsonArray build();
+
+ default JsonArrayBuilder addAll(JsonArrayBuilder builder) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, JsonValue value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, BigDecimal value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, BigInteger value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, long value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, double value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, boolean value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder addNull(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, JsonObjectBuilder builder) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder add(int index, JsonArrayBuilder builder) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, JsonValue value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, BigDecimal value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, BigInteger value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, long value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, double value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, boolean value) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder setNull(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, JsonObjectBuilder builder) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder set(int index, JsonArrayBuilder builder) {
+ throw new UnsupportedOperationException();
+ }
+
+ default JsonArrayBuilder remove(int index) {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonNumber.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonNumber.java
new file mode 100644
index 0000000..5713b32
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonNumber.java
@@ -0,0 +1,63 @@
+/*
+ * 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.artemis.json;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * JsonValue which represents a number.
+ *
+ * The decimal point is defined as dot '.'.
+ *
+ * @see <a href="https://tools.ietf.org/html/rfc4627">RFC-4627 JSON Specification</a>
+ */
+public interface JsonNumber extends JsonValue {
+ boolean isIntegral();
+
+ int intValue();
+
+ int intValueExact();
+
+ long longValue();
+
+ long longValueExact();
+
+ BigInteger bigIntegerValue();
+
+ BigInteger bigIntegerValueExact();
+
+ double doubleValue();
+
+ BigDecimal bigDecimalValue();
+
+ /**
+ * @since 1.1
+ */
+ default Number numberValue() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ String toString();
+
+ @Override
+ boolean equals(Object obj);
+
+ @Override
+ int hashCode();
+}
\ No newline at end of file
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonObject.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonObject.java
new file mode 100644
index 0000000..b044edd
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonObject.java
@@ -0,0 +1,105 @@
+/*
+ * 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.artemis.json;
+
+import java.util.Map;
+
+/**
+ * A JsonObject, e.g.
+ * <pre>
+ * {
+ * "name":"karl",
+ * "age":38,
+ * "address": {
+ * "street":"dummystreet"
+ * "housenumber":12
+ * }
+ * }
+ * </pre>
+ *
+ * A JsonObject is always also a Map which uses the attribute names as key mapping
+ * to their JsonValues.
+ */
+public interface JsonObject extends JsonValue, Map<String, JsonValue> {
+
+ /**
+ * @return the JsonArray with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ JsonArray getJsonArray(String name);
+
+ /**
+ * @return the JsonObject with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ JsonObject getJsonObject(String name);
+
+ /**
+ * @return the JsonNumber with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ JsonNumber getJsonNumber(String name);
+
+ /**
+ * @return the JsonString with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ JsonString getJsonString(String name);
+
+ /**
+ * @return the native string with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ String getString(String name);
+
+ /**
+ * @return the native string with the given name or the default value if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ String getString(String name, String defaultValue);
+
+ /**
+ * @return the int with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ * @throws NullPointerException if an object with the given name doesn't exist
+ */
+ int getInt(String name);
+
+ /**
+ * @return the int with the given name or the default value if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ int getInt(String name, int defaultValue);
+
+ /**
+ * @return the boolean with the given name or {@code null} if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ * @throws NullPointerException if an object with the given name doesn't exist
+ */
+ boolean getBoolean(String name);
+
+ /**
+ * @return the boolean with the given name or the default value if there is no attribute with that name
+ * @throws ClassCastException if the JsonValue cannot be correctly cast
+ */
+ boolean getBoolean(String name, boolean defaultValue);
+
+ /**
+ * @return whether the attribute with the given name is {@link JsonValue#NULL}
+ */
+ boolean isNull(String name);
+}
\ No newline at end of file
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonObjectBuilder.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonObjectBuilder.java
new file mode 100644
index 0000000..fa08e0c
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonObjectBuilder.java
@@ -0,0 +1,155 @@
+/*
+ * 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.artemis.json;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * A JsonObjectBuilder can be used to build {@link JsonObject JsonObjects}.
+ * Instances are not thread safe.
+ *
+ * Calling any of those methods with either the {@code name} or {@code value} param as {@code null}
+ * will result in a {@code NullPointerException}
+ */
+public interface JsonObjectBuilder {
+ /**
+ * Add the given JsonValue value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value the JsonValue to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, JsonValue value);
+
+ /**
+ * Add the given String value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value the String value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, String value);
+ JsonObjectBuilder add(String name, String value, JsonValue defaultValue);
+
+ /**
+ * Add the given BigInteger value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value the BigInteger value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, BigInteger value);
+ JsonObjectBuilder add(String name, BigInteger value, JsonValue defaultValue);
+
+ /**
+ * Add the given BigDecimal value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value the BigDecimal value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, BigDecimal value);
+ JsonObjectBuilder add(String name, BigDecimal value, JsonValue defaultValue);
+
+ /**
+ * Add the given int value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, int value);
+
+ /**
+ * Add the given long value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, long value);
+
+ /**
+ * Add the given double value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, double value);
+
+ /**
+ * Add the given boolean value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param value to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, boolean value);
+
+ /**
+ * Add a {@link JsonValue#NULL} value to the JsonObject to be created.
+ * If a value with that name already exists it will be replaced by the null value.
+ * @param name the JSON attribute name
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder addNull(String name);
+
+ /**
+ * Use the given {@link JsonObjectBuilder} to create a {@link JsonObject} which will be
+ * added to the JsonObject to be created by this builder.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param builder for creating the JsonObject to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, JsonObjectBuilder builder);
+
+ /**
+ * Use the given {@link JsonArrayBuilder} to create a {@link JsonArray} which will be
+ * added to the JsonObject to be created by this builder.
+ * If a value with that name already exists it will be replaced by the new value.
+ * @param name the JSON attribute name
+ * @param builder for creating the JsonArray to add
+ * @return the current JsonObjectBuilder
+ */
+ JsonObjectBuilder add(String name, JsonArrayBuilder builder);
+
+ /**
+ * @return a {@link JsonObject} based on the added values.
+ */
+ JsonObject build();
+
+ /**
+ * Add all of the attributes of the given {@link JsonObjectBuilder} to the current one
+ *
+ * @since 1.1
+ */
+ default JsonObjectBuilder addAll(JsonObjectBuilder builder) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Remove the attribute with the given name from the builder.
+ *
+ * @since 1.1
+ */
+ default JsonObjectBuilder remove(String name) {
+ throw new UnsupportedOperationException();
+ }
+}
\ No newline at end of file
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonString.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonString.java
new file mode 100644
index 0000000..24dfd3e
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonString.java
@@ -0,0 +1,32 @@
+/*
+ * 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.artemis.json;
+
+/**
+ * JsonValue which represents a string.
+ */
+public interface JsonString extends JsonValue {
+ String getString();
+
+ CharSequence getChars();
+
+ @Override
+ boolean equals(Object obj);
+
+ @Override
+ int hashCode();
+}
\ No newline at end of file
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonValue.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonValue.java
new file mode 100644
index 0000000..a0e5448
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/JsonValue.java
@@ -0,0 +1,74 @@
+/*
+ * 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.artemis.json;
+
+import org.apache.activemq.artemis.json.impl.JsonArrayImpl;
+import org.apache.activemq.artemis.json.impl.JsonObjectImpl;
+import org.apache.activemq.artemis.json.impl.JsonValueImpl;
+
+/**
+ * A single value in a JSON expression.
+ */
+public interface JsonValue {
+
+ /**
+ * The empty JSON object.
+ */
+ JsonObject EMPTY_JSON_OBJECT = new JsonObjectImpl(javax.json.JsonValue.EMPTY_JSON_OBJECT);
+
+ /**
+ * The empty JSON array.
+ */
+ JsonArray EMPTY_JSON_ARRAY = new JsonArrayImpl(javax.json.JsonValue.EMPTY_JSON_ARRAY);
+
+
+ /**
+ * A constant JsonValue for null values
+ */
+ JsonValue NULL = new JsonValueImpl(javax.json.JsonValue.NULL);
+
+ /**
+ * A constant JsonValue for TRUE
+ */
+ JsonValue TRUE = new JsonValueImpl(javax.json.JsonValue.TRUE);
+
+ /**
+ * A constant JsonValue for FALSE
+ */
+ JsonValue FALSE = new JsonValueImpl(javax.json.JsonValue.FALSE);
+
+ ValueType getValueType();
+
+ @Override
+ String toString();
+
+ enum ValueType {
+ ARRAY,
+ OBJECT, STRING, NUMBER,
+ TRUE, FALSE,
+ NULL
+ }
+
+ default JsonObject asJsonObject() {
+ return JsonObject.class.cast(this);
+ }
+
+ default JsonArray asJsonArray() {
+ return JsonArray.class.cast(this);
+ }
+
+}
\ No newline at end of file
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonArrayBuilderImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonArrayBuilderImpl.java
new file mode 100644
index 0000000..89653c0
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonArrayBuilderImpl.java
@@ -0,0 +1,125 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonValue;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class JsonArrayBuilderImpl implements JsonArrayBuilder {
+
+ private final javax.json.JsonArrayBuilder rawArrayBuilder;
+
+ public javax.json.JsonArrayBuilder getRawArrayBuilder() {
+ return rawArrayBuilder;
+ }
+
+ public JsonArrayBuilderImpl(javax.json.JsonArrayBuilder rawArrayBuilder) {
+ this.rawArrayBuilder = rawArrayBuilder;
+ }
+
+ @Override
+ public JsonArrayBuilder add(JsonValue value) {
+ if (!(value instanceof JsonValueImpl)) {
+ throw new UnsupportedOperationException();
+ }
+ rawArrayBuilder.add(((JsonValueImpl)value).getRawValue());
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(String value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(BigDecimal value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(BigInteger value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(int value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(long value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(double value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(boolean value) {
+ rawArrayBuilder.add(value);
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder addNull() {
+ rawArrayBuilder.addNull();
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(JsonObjectBuilder builder) {
+ if (!(builder instanceof JsonObjectBuilderImpl)) {
+ throw new UnsupportedOperationException();
+ }
+ rawArrayBuilder.add(((JsonObjectBuilderImpl)builder).getRawObjectBuilder());
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder add(JsonArrayBuilder builder) {
+ if (!(builder instanceof JsonArrayBuilderImpl)) {
+ throw new UnsupportedOperationException();
+ }
+ rawArrayBuilder.add(((JsonArrayBuilderImpl)builder).getRawArrayBuilder());
+ return this;
+ }
+
+ @Override
+ public JsonArrayBuilder remove(int index) {
+ rawArrayBuilder.remove(index);
+ return this;
+ }
+
+ @Override
+ public JsonArray build() {
+ return new JsonArrayImpl(rawArrayBuilder.build());
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonArrayImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonArrayImpl.java
new file mode 100644
index 0000000..7f972fa
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonArrayImpl.java
@@ -0,0 +1,234 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonNumber;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+public class JsonArrayImpl extends JsonValueImpl implements JsonArray {
+
+ private final javax.json.JsonArray rawArray;
+
+ public javax.json.JsonArray getRawArray() {
+ return rawArray;
+ }
+
+ public JsonArrayImpl(javax.json.JsonArray rawArray) {
+ super(rawArray);
+ this.rawArray = rawArray;
+ }
+
+ @Override
+ public JsonObject getJsonObject(int index) {
+ return (JsonObject)this.wrap(rawArray.getJsonObject(index));
+ }
+
+ @Override
+ public JsonArray getJsonArray(int index) {
+ return (JsonArray)this.wrap(rawArray.getJsonArray(index));
+ }
+
+ @Override
+ public JsonNumber getJsonNumber(int index) {
+ return (JsonNumber)this.wrap(rawArray.getJsonNumber(index));
+ }
+
+ @Override
+ public JsonString getJsonString(int index) {
+ return (JsonString)this.wrap(rawArray.getJsonString(index));
+ }
+
+ @Override
+ public <T extends JsonValue> List<T> getValuesAs(Class<T> clazz) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String getString(int index) {
+ return rawArray.getString(index);
+ }
+
+ @Override
+ public String getString(int index, String defaultValue) {
+ return rawArray.getString(index, defaultValue);
+ }
+
+ @Override
+ public int getInt(int index) {
+ return rawArray.getInt(index);
+ }
+
+ @Override
+ public int getInt(int index, int defaultValue) {
+ return rawArray.getInt(index, defaultValue);
+ }
+
+ @Override
+ public boolean getBoolean(int index) {
+ return rawArray.getBoolean(index);
+ }
+
+ @Override
+ public boolean getBoolean(int index, boolean defaultValue) {
+ return rawArray.getBoolean(index, defaultValue);
+ }
+
+ @Override
+ public boolean isNull(int index) {
+ return rawArray.isNull(index);
+ }
+
+ @Override
+ public int size() {
+ return rawArray.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return rawArray.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ if (o instanceof JsonValueImpl) {
+ return rawArray.contains(((JsonValueImpl)o).getRawValue());
+ } else {
+ return rawArray.contains(o);
+ }
+ }
+
+ @Override
+ public Iterator<JsonValue> iterator() {
+ return new Iterator<JsonValue>() {
+ private Iterator<javax.json.JsonValue> rawIterator = rawArray.iterator();
+
+ @Override
+ public boolean hasNext() {
+ return rawIterator.hasNext();
+ }
+
+ @Override
+ public JsonValue next() {
+ return wrap(rawIterator.next());
+ }
+ };
+ }
+
+ @Override
+ public Object[] toArray() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public <T> T[] toArray(T[] a) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean add(JsonValue jsonValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends JsonValue> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends JsonValue> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ rawArray.clear();
+ }
+
+ @Override
+ public JsonValue get(int index) {
+ return wrap(rawArray.get(index));
+ }
+
+ @Override
+ public JsonValue set(int index, JsonValue element) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void add(int index, JsonValue element) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public JsonValue remove(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ListIterator<JsonValue> listIterator() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ListIterator<JsonValue> listIterator(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<JsonValue> subList(int fromIndex, int toIndex) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonNumberImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonNumberImpl.java
new file mode 100644
index 0000000..6d8149d
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonNumberImpl.java
@@ -0,0 +1,87 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonNumber;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class JsonNumberImpl extends JsonValueImpl implements JsonNumber {
+
+ private final javax.json.JsonNumber rawNumber;
+
+ public javax.json.JsonNumber getRawNumber() {
+ return rawNumber;
+ }
+
+ public JsonNumberImpl(javax.json.JsonNumber rawNumber) {
+ super(rawNumber);
+ this.rawNumber = rawNumber;
+ }
+
+ @Override
+ public boolean isIntegral() {
+ return rawNumber.isIntegral();
+ }
+
+ @Override
+ public int intValue() {
+ return rawNumber.intValue();
+ }
+
+ @Override
+ public int intValueExact() {
+ return rawNumber.intValueExact();
+ }
+
+ @Override
+ public long longValue() {
+ return rawNumber.longValue();
+ }
+
+ @Override
+ public long longValueExact() {
+ return rawNumber.longValueExact();
+ }
+
+ @Override
+ public BigInteger bigIntegerValue() {
+ return rawNumber.bigIntegerValue();
+ }
+
+ @Override
+ public BigInteger bigIntegerValueExact() {
+ return rawNumber.bigIntegerValueExact();
+ }
+
+ @Override
+ public double doubleValue() {
+ return rawNumber.doubleValue();
+ }
+
+ @Override
+ public BigDecimal bigDecimalValue() {
+ return rawNumber.bigDecimalValue();
+ }
+
+ @Override
+ public Number numberValue() {
+ return rawNumber.numberValue();
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonObjectBuilderImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonObjectBuilderImpl.java
new file mode 100644
index 0000000..e427219
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonObjectBuilderImpl.java
@@ -0,0 +1,155 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonValue;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class JsonObjectBuilderImpl implements JsonObjectBuilder {
+
+ private final javax.json.JsonObjectBuilder rawObjectBuilder;
+
+ public javax.json.JsonObjectBuilder getRawObjectBuilder() {
+ return rawObjectBuilder;
+ }
+
+ public JsonObjectBuilderImpl(javax.json.JsonObjectBuilder rawObjectBuilder) {
+ this.rawObjectBuilder = rawObjectBuilder;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, JsonValue value) {
+ if (!(value instanceof JsonValueImpl)) {
+ throw new UnsupportedOperationException();
+ }
+ rawObjectBuilder.add(name, ((JsonValueImpl)value).getRawValue());
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, String value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, String value, JsonValue defaultValue) {
+ if (value != null) {
+ rawObjectBuilder.add(name, value);
+ } else {
+ add(name, defaultValue);
+ }
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, BigInteger value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, BigInteger value, JsonValue defaultValue) {
+ if (value != null) {
+ rawObjectBuilder.add(name, value);
+ } else {
+ add(name, defaultValue);
+ }
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, BigDecimal value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, BigDecimal value, JsonValue defaultValue) {
+ if (value != null) {
+ rawObjectBuilder.add(name, value);
+ } else {
+ add(name, defaultValue);
+ }
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, int value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, long value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, double value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, boolean value) {
+ rawObjectBuilder.add(name, value);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder addNull(String name) {
+ rawObjectBuilder.addNull(name);
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, JsonObjectBuilder builder) {
+ if (!(builder instanceof JsonObjectBuilderImpl)) {
+ throw new UnsupportedOperationException();
+ }
+ rawObjectBuilder.add(name, ((JsonObjectBuilderImpl)builder).getRawObjectBuilder());
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder add(String name, JsonArrayBuilder builder) {
+ if (!(builder instanceof JsonArrayBuilderImpl)) {
+ throw new UnsupportedOperationException();
+ }
+ rawObjectBuilder.add(name, ((JsonArrayBuilderImpl)builder).getRawArrayBuilder());
+ return this;
+ }
+
+ @Override
+ public JsonObjectBuilder remove(String name) {
+ rawObjectBuilder.remove(name);
+ return this;
+ }
+
+ @Override
+ public JsonObject build() {
+ return new JsonObjectImpl(rawObjectBuilder.build());
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonObjectImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonObjectImpl.java
new file mode 100644
index 0000000..39fb6ad
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonObjectImpl.java
@@ -0,0 +1,217 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonNumber;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
+
+import java.util.AbstractCollection;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+public class JsonObjectImpl extends JsonValueImpl implements JsonObject {
+
+ private final javax.json.JsonObject rawObject;
+
+ public javax.json.JsonObject getRawObject() {
+ return rawObject;
+ }
+
+ public JsonObjectImpl(javax.json.JsonObject rawObject) {
+ super(rawObject);
+ this.rawObject = rawObject;
+ }
+
+ @Override
+ public JsonArray getJsonArray(String name) {
+ return (JsonArray)wrap(rawObject.getJsonArray(name));
+ }
+
+ @Override
+ public JsonObject getJsonObject(String name) {
+ return (JsonObject)wrap(rawObject.getJsonObject(name));
+ }
+
+ @Override
+ public JsonNumber getJsonNumber(String name) {
+ return (JsonNumber)wrap(rawObject.getJsonNumber(name));
+ }
+
+ @Override
+ public JsonString getJsonString(String name) {
+ return (JsonString)wrap(rawObject.getJsonString(name));
+ }
+
+ @Override
+ public String getString(String name) {
+ return rawObject.getString(name);
+ }
+
+ @Override
+ public String getString(String name, String defaultValue) {
+ return rawObject.getString(name, defaultValue);
+ }
+
+ @Override
+ public int getInt(String name) {
+ return rawObject.getInt(name);
+ }
+
+ @Override
+ public int getInt(String name, int defaultValue) {
+ return rawObject.getInt(name, defaultValue);
+ }
+
+ @Override
+ public boolean getBoolean(String name) {
+ return rawObject.getBoolean(name);
+ }
+
+ @Override
+ public boolean getBoolean(String name, boolean defaultValue) {
+ return rawObject.getBoolean(name, defaultValue);
+ }
+
+ @Override
+ public boolean isNull(String name) {
+ return rawObject.isNull(name);
+ }
+
+ @Override
+ public int size() {
+ return rawObject.size();
+ }
+
+
+ @Override
+ public boolean isEmpty() {
+ return rawObject.isEmpty();
+ }
+
+
+ @Override
+ public boolean containsKey(Object key) {
+ return rawObject.containsKey(key);
+ }
+
+ @Override
+ public boolean containsValue(Object value) {
+ return rawObject.containsValue(value);
+ }
+
+ @Override
+ public JsonValue get(Object key) {
+ return wrap(rawObject.get(key));
+ }
+
+ @Override
+ public JsonValue put(String key, JsonValue value) {
+ if (!(value instanceof JsonValueImpl)) {
+ throw new UnsupportedOperationException();
+ }
+
+ javax.json.JsonValue rawValue = rawObject.put(key, ((JsonValueImpl)value).getRawValue());
+
+ return rawValue != null ? wrap(rawValue) : null;
+ }
+
+ @Override
+ public JsonValue remove(Object key) {
+ javax.json.JsonValue rawValue = rawObject.remove(key);
+
+ return rawValue != null ? wrap(rawValue) : null;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends JsonValue> m) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void clear() {
+ rawObject.clear();
+ }
+
+ @Override
+ public Set<String> keySet() {
+ return rawObject.keySet();
+ }
+
+ @Override
+ public Collection<JsonValue> values() {
+ return new AbstractCollection<JsonValue>() {
+ @Override
+ public Iterator<JsonValue> iterator() {
+ return new Iterator<JsonValue>() {
+ private Iterator<javax.json.JsonValue> rawIterator = rawObject.values().iterator();
+
+ @Override
+ public boolean hasNext() {
+ return rawIterator.hasNext();
+ }
+
+ @Override
+ public JsonValue next() {
+ return wrap(rawIterator.next());
+ }
+ };
+ }
+
+ @Override
+ public int size() {
+ return rawObject.size();
+ }
+ };
+ }
+
+ @Override
+ public Set<Map.Entry<String, JsonValue>> entrySet() {
+ return new AbstractSet<Map.Entry<String, JsonValue>>() {
+ @Override
+ public Iterator<Map.Entry<String, JsonValue>> iterator() {
+ return new Iterator<Map.Entry<String, JsonValue>>() {
+ private Iterator<Map.Entry<String, javax.json.JsonValue>> rawIterator = rawObject.entrySet().iterator();
+
+ @Override
+ public boolean hasNext() {
+ return rawIterator.hasNext();
+ }
+
+ @Override
+ public Map.Entry<String, JsonValue> next() {
+ Map.Entry<String, javax.json.JsonValue> rawEntry = rawIterator.next();
+
+ return rawEntry != null ? new AbstractMap.SimpleEntry<>(rawEntry.getKey(), wrap(rawEntry.getValue())) : null;
+ }
+ };
+ }
+
+ @Override
+ public int size() {
+ return rawObject.size();
+ }
+ };
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonStringImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonStringImpl.java
new file mode 100644
index 0000000..588b8fd
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonStringImpl.java
@@ -0,0 +1,44 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonString;
+
+public class JsonStringImpl extends JsonValueImpl implements JsonString {
+
+ private final javax.json.JsonString rawString;
+
+ public javax.json.JsonString getRawString() {
+ return rawString;
+ }
+
+ public JsonStringImpl(javax.json.JsonString rawString) {
+ super(rawString);
+ this.rawString = rawString;
+ }
+
+ @Override
+ public String getString() {
+ return rawString.getString();
+ }
+
+ @Override
+ public CharSequence getChars() {
+ return rawString.getChars();
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonValueImpl.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonValueImpl.java
new file mode 100644
index 0000000..3e94b4d
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/json/impl/JsonValueImpl.java
@@ -0,0 +1,116 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.artemis.json.impl;
+
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonValue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class JsonValueImpl implements JsonValue {
+
+ private Map<javax.json.JsonValue, JsonValue> cache = new HashMap<>();
+
+ public JsonValue wrap(javax.json.JsonValue rawValue) {
+ if (rawValue == null) {
+ return null;
+ }
+
+ JsonValue cacheValue = cache.get(rawValue);
+
+ if (cacheValue != null) {
+ return cacheValue;
+ } else if (rawValue == javax.json.JsonValue.EMPTY_JSON_OBJECT) {
+ return JsonValue.EMPTY_JSON_OBJECT;
+ } else if (rawValue == javax.json.JsonValue.EMPTY_JSON_ARRAY) {
+ return JsonValue.EMPTY_JSON_ARRAY;
+ } else if (rawValue == javax.json.JsonValue.TRUE) {
+ return JsonValue.TRUE;
+ } else if (rawValue == javax.json.JsonValue.FALSE) {
+ return JsonValue.FALSE;
+ } else if (rawValue == javax.json.JsonValue.NULL) {
+ return JsonValue.NULL;
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.ARRAY) {
+ cacheValue = new JsonArrayImpl((javax.json.JsonArray) rawValue);
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.OBJECT) {
+ cacheValue = new JsonObjectImpl((javax.json.JsonObject) rawValue);
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.STRING) {
+ cacheValue = new JsonStringImpl((javax.json.JsonString) rawValue);
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.NUMBER) {
+ cacheValue = new JsonNumberImpl((javax.json.JsonNumber) rawValue);
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.TRUE) {
+ cacheValue = new JsonValueImpl(rawValue);
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.FALSE) {
+ cacheValue = new JsonValueImpl(rawValue);
+ } else if (rawValue.getValueType() == javax.json.JsonValue.ValueType.NULL) {
+ cacheValue = new JsonValueImpl(rawValue);
+ } else {
+ throw new IllegalStateException("Unexpected value: " + rawValue.getValueType());
+ }
+
+ cache.put(rawValue, cacheValue);
+
+ return cacheValue;
+ }
+
+ private final javax.json.JsonValue rawValue;
+
+ public javax.json.JsonValue getRawValue() {
+ return rawValue;
+ }
+
+ public JsonValueImpl(javax.json.JsonValue rawValue) {
+ this.rawValue = rawValue;
+ }
+
+
+ @Override
+ public JsonValue.ValueType getValueType() {
+ return ValueType.valueOf(rawValue.getValueType().name());
+ }
+
+ @Override
+ public JsonObject asJsonObject() {
+ return JsonValue.super.asJsonObject();
+ }
+
+ @Override
+ public JsonArray asJsonArray() {
+ return JsonValue.super.asJsonArray();
+ }
+
+ @Override
+ public String toString() {
+ return rawValue.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof JsonValueImpl) {
+ return rawValue.equals(((JsonValueImpl)obj).getRawValue());
+ }
+ return super.equals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return rawValue.hashCode();
+ }
+}
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java
index 0e9df69..789e530 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/JsonLoader.java
@@ -17,15 +17,18 @@
package org.apache.activemq.artemis.utils;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.impl.JsonArrayBuilderImpl;
+import org.apache.activemq.artemis.json.impl.JsonArrayImpl;
+import org.apache.activemq.artemis.json.impl.JsonObjectBuilderImpl;
+import org.apache.activemq.artemis.json.impl.JsonObjectImpl;
+
import javax.json.JsonReader;
import javax.json.spi.JsonProvider;
import java.io.Reader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
/**
* This is to make sure we use the proper classLoader to load JSon libraries.
@@ -33,46 +36,25 @@ import java.security.PrivilegedAction;
*/
public class JsonLoader {
- private static final JsonProvider provider;
-
- static {
- provider = loadProvider();
- }
-
- private static JsonProvider loadProvider() {
- return AccessController.doPrivileged(new PrivilegedAction<JsonProvider>() {
- @Override
- public JsonProvider run() {
- ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(JsonLoader.class.getClassLoader());
- return JsonProvider.provider();
- } finally {
- Thread.currentThread().setContextClassLoader(originalLoader);
- }
- }
- });
-
- }
+ private static final JsonProvider provider = new org.apache.johnzon.core.JsonProviderImpl();
public static JsonObject readObject(Reader reader) {
try (JsonReader jsonReader = provider.createReader(reader)) {
- return jsonReader.readObject();
+ return new JsonObjectImpl(jsonReader.readObject());
}
}
public static JsonArray readArray(Reader reader) {
try (JsonReader jsonReader = provider.createReader(reader)) {
- return jsonReader.readArray();
+ return new JsonArrayImpl(jsonReader.readArray());
}
}
public static JsonArrayBuilder createArrayBuilder() {
- return provider.createArrayBuilder();
+ return new JsonArrayBuilderImpl(provider.createArrayBuilder());
}
public static JsonObjectBuilder createObjectBuilder() {
- return provider.createObjectBuilder();
+ return new JsonObjectBuilderImpl(provider.createObjectBuilder());
}
-
}
diff --git a/artemis-core-client-osgi/pom.xml b/artemis-core-client-osgi/pom.xml
index b84ba94..1fcfd77 100644
--- a/artemis-core-client-osgi/pom.xml
+++ b/artemis-core-client-osgi/pom.xml
@@ -98,8 +98,8 @@
<instructions>
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
<Import-Package>
+ org.glassfish.json*;resolution:=optional,
io.netty.buffer;io.netty.*;version="[4.1,5)",
- org.apache.johnzon.core,
*
</Import-Package>
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>
diff --git a/artemis-core-client/pom.xml b/artemis-core-client/pom.xml
index a4832e9..8743eda 100644
--- a/artemis-core-client/pom.xml
+++ b/artemis-core-client/pom.xml
@@ -87,14 +87,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- </dependency>
- <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>${netty-transport-native-epoll-classifier}</classifier>
@@ -136,6 +128,21 @@
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</dependency>
+
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -152,7 +159,7 @@
<maxmemory>512m</maxmemory>
<quiet>false</quiet>
<aggregate>true</aggregate>
- <excludePackageNames>org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils
+ <excludePackageNames>org.apache.activemq.artemis.core:org.apache.activemq.artemis.utils,org.apache.activemq.artemis.commons
</excludePackageNames>
</configuration>
<executions>
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java
index b1535bb..052a09b0 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JsonUtil.java
@@ -16,13 +16,13 @@
*/
package org.apache.activemq.artemis.api.core;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonString;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonNumber;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import java.io.ByteArrayInputStream;
@@ -264,7 +264,7 @@ public final class JsonUtil {
public static Map<String, String> readJsonProperties(String jsonString) {
Map<String, String> properties = new HashMap<>();
if (jsonString != null) {
- JsonUtil.readJsonObject(jsonString).forEach((k, v) -> properties.put(k, v.toString()));
+ JsonUtil.readJsonObject(jsonString).entrySet().forEach(e -> properties.put(e.getKey(), e.getValue().toString()));
}
return properties;
}
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java
index 15a3b52..2d9f415 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/TransportConfiguration.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.api.core;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObject;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java
index ebe030b..f96d28c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressSettingsInfo.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.api.core.management;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.api.core.JsonUtil;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java
index 3955a8b..36885ea 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/DayCounterInfo.java
@@ -16,10 +16,10 @@
*/
package org.apache.activemq.artemis.api.core.management;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.utils.JsonLoader;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java
index 462a7b7..678df28 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ManagementHelper.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.api.core.management;
-import javax.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArray;
import org.apache.activemq.artemis.api.core.ICoreMessage;
import org.apache.activemq.artemis.api.core.JsonUtil;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
index 5282387..e5c3cc9 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/MessageCounterInfo.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.api.core.management;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.api.core.JsonUtil;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/NodeInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/NodeInfo.java
index 1f60e0c..9c00cae 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/NodeInfo.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/NodeInfo.java
@@ -17,8 +17,8 @@
package org.apache.activemq.artemis.api.core.management;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.api.core.JsonUtil;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java
index bbf12aa..808fb65 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/RoleInfo.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.api.core.management;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.api.core.JsonUtil;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/TransformerConfiguration.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/TransformerConfiguration.java
index e05bba9..cc9622c 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/TransformerConfiguration.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/config/TransformerConfiguration.java
@@ -18,9 +18,9 @@ package org.apache.activemq.artemis.core.config;
import org.apache.activemq.artemis.utils.JsonLoader;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
import java.io.Serializable;
import java.io.StringReader;
import java.util.HashMap;
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
index 7757b3b..fcaa974 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/security/Role.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.security;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObject;
import java.io.Serializable;
import org.apache.activemq.artemis.utils.JsonLoader;
diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java
index ab87cf2..40ea35a 100644
--- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java
+++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/api/core/JsonUtilTest.java
@@ -17,10 +17,10 @@
package org.apache.activemq.artemis.api.core;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.junit.Assert;
diff --git a/artemis-distribution/pom.xml b/artemis-distribution/pom.xml
index 1ff3270..08dc65d 100644
--- a/artemis-distribution/pom.xml
+++ b/artemis-distribution/pom.xml
@@ -304,14 +304,6 @@
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>${netty-transport-native-kqueue-classifier}</classifier>
</dependency>
- <dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- </dependency>
<dependency>
<groupId>jakarta.security.auth.message</groupId>
<artifactId>jakarta.security.auth.message-api</artifactId>
diff --git a/artemis-distribution/src/main/assembly/dep.xml b/artemis-distribution/src/main/assembly/dep.xml
index dc982e6..342a0cf 100644
--- a/artemis-distribution/src/main/assembly/dep.xml
+++ b/artemis-distribution/src/main/assembly/dep.xml
@@ -107,8 +107,6 @@
<include>org.apache.commons:commons-lang3</include>
<include>org.fusesource.hawtbuf:hawtbuf</include>
<include>org.jgroups:jgroups</include>
- <include>jakarta.json:jakarta.json-api</include>
- <include>org.apache.johnzon:johnzon-core</include>
<include>jakarta.xml.bind:jakarta.xml.bind-api</include>
<include>com.sun.xml.bind:jaxb-impl</include>
<include>jakarta.activation:jakarta.activation-api</include>
diff --git a/artemis-features/src/main/resources/features.xml b/artemis-features/src/main/resources/features.xml
index 5de8675..d5894b1 100644
--- a/artemis-features/src/main/resources/features.xml
+++ b/artemis-features/src/main/resources/features.xml
@@ -53,9 +53,6 @@
<bundle dependency="true">mvn:org.jboss.logging/jboss-logging/${jboss.logging.version}</bundle>
<bundle dependency="true">mvn:org.jgroups/jgroups/${jgroups.version}</bundle>
-
- <bundle dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.json-api-1.1/${servicemix.json-1.1.spec.version}</bundle>
- <bundle>mvn:org.apache.johnzon/johnzon-core/${johnzon.version}</bundle>
</feature>
<feature name="artemis-core" version="${pom.version}" description="ActiveMQ Artemis broker libraries">
diff --git a/artemis-jakarta-client-all/pom.xml b/artemis-jakarta-client-all/pom.xml
index e15d22f..4611104 100644
--- a/artemis-jakarta-client-all/pom.xml
+++ b/artemis-jakarta-client-all/pom.xml
@@ -30,7 +30,6 @@
<properties>
<activemq.basedir>${project.basedir}/..</activemq.basedir>
<jakarta.jms-api.version>3.0.0</jakarta.jms-api.version>
- <jakarta.json-api.version>2.0.1</jakarta.json-api.version>
</properties>
<dependencies>
@@ -111,10 +110,6 @@
<shadedPattern>org.apache.activemq.artemis.shaded.com.google</shadedPattern>
</relocation>
<relocation>
- <pattern>org.apache.johnzon</pattern>
- <shadedPattern>org.apache.activemq.artemis.shaded.org.apache.johnzon</shadedPattern>
- </relocation>
- <relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>org.apache.activemq.artemis.shaded.org.apache.commons</shadedPattern>
</relocation>
diff --git a/artemis-jakarta-server/pom.xml b/artemis-jakarta-server/pom.xml
index 38b685c..35c12cf 100644
--- a/artemis-jakarta-server/pom.xml
+++ b/artemis-jakarta-server/pom.xml
@@ -32,7 +32,6 @@
<jakarta.jms-api.version>3.0.0</jakarta.jms-api.version>
<jakarta.transaction-api.version>2.0.0</jakarta.transaction-api.version>
<jakarta.resource-api.version>2.0.0</jakarta.resource-api.version>
- <jakarta.json-api.version>2.0.1</jakarta.json-api.version>
</properties>
<dependencies>
@@ -96,11 +95,6 @@
<artifactId>jakarta.transaction-api</artifactId>
<version>${jakarta.transaction-api.version}</version>
</dependency>
- <dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- <version>${jakarta.json-api.version}</version>
- </dependency>
</dependencies>
<build>
diff --git a/artemis-jms-client-all/pom.xml b/artemis-jms-client-all/pom.xml
index 166e66e..40299db 100644
--- a/artemis-jms-client-all/pom.xml
+++ b/artemis-jms-client-all/pom.xml
@@ -109,10 +109,6 @@
<shadedPattern>org.apache.activemq.artemis.shaded.com.google</shadedPattern>
</relocation>
<relocation>
- <pattern>org.apache.johnzon</pattern>
- <shadedPattern>org.apache.activemq.artemis.shaded.org.apache.johnzon</shadedPattern>
- </relocation>
- <relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>org.apache.activemq.artemis.shaded.org.apache.commons</shadedPattern>
</relocation>
diff --git a/artemis-jms-client-osgi/pom.xml b/artemis-jms-client-osgi/pom.xml
index 9b653fc..e95708f 100644
--- a/artemis-jms-client-osgi/pom.xml
+++ b/artemis-jms-client-osgi/pom.xml
@@ -107,8 +107,8 @@
<instructions>
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
<Import-Package>
+ org.glassfish.json*;resolution:=optional,
io.netty.buffer;io.netty.*;version="[4.1,5)",
- org.apache.johnzon.core,
*
</Import-Package>
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>
diff --git a/artemis-jms-server/pom.xml b/artemis-jms-server/pom.xml
index 029a69f..5d2db14 100644
--- a/artemis-jms-server/pom.xml
+++ b/artemis-jms-server/pom.xml
@@ -90,10 +90,6 @@
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
</dependency>
- <dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- </dependency>
</dependencies>
<profiles>
diff --git a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java
index 533fc6b..97b5fbc 100644
--- a/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java
+++ b/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisClientPlugin.java
@@ -16,7 +16,10 @@
*/
package org.apache.activemq.artemis.maven;
+import java.io.File;
import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Properties;
import org.apache.maven.plugin.MojoExecutionException;
@@ -37,6 +40,10 @@ public class ArtemisClientPlugin extends ArtemisAbstractPlugin {
@Parameter
String[] args;
+
+ @Parameter
+ String classPath;
+
@Parameter(defaultValue = "${noClient}")
boolean ignore;
@@ -50,13 +57,31 @@ public class ArtemisClientPlugin extends ArtemisAbstractPlugin {
return ignore;
}
+
+ protected ClassLoader defineClassLoader(String classPath) throws Exception {
+ String[] classPathArray = classPath.split(File.pathSeparator);
+ URL[] elements = new URL[classPathArray.length];
+ for (int i = 0; i < classPathArray.length; i++) {
+ elements[i] = new File(classPathArray[i]).toPath().toUri().toURL();
+ }
+ return new URLClassLoader(elements);
+ }
+
+
@Override
protected void doExecute() throws MojoExecutionException, MojoFailureException {
try {
if (systemProperties != null && !systemProperties.isEmpty()) {
System.getProperties().putAll(systemProperties);
}
- Class aClass = Class.forName(clientClass);
+
+ Class aClass;
+ if (classPath != null) {
+ ClassLoader loader = defineClassLoader(classPath);
+ aClass = loader.loadClass(clientClass);
+ } else {
+ aClass = Class.forName(clientClass);
+ }
Method method = aClass.getDeclaredMethod("main", new Class[]{String[].class});
method.invoke(null, new Object[]{args});
} catch (Exception e) {
diff --git a/artemis-server-osgi/pom.xml b/artemis-server-osgi/pom.xml
index 7fb37ce..c80cb47 100644
--- a/artemis-server-osgi/pom.xml
+++ b/artemis-server-osgi/pom.xml
@@ -146,9 +146,9 @@
<instructions>
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
<Import-Package>
+ org.glassfish.json*;resolution:=optional,
org.postgresql*;resolution:=optional,
io.netty.buffer;io.netty.*;version="[4.1,5)",
- org.apache.johnzon.core,
*
</Import-Package>
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>
diff --git a/artemis-server/pom.xml b/artemis-server/pom.xml
index 1cfedd4..1591885 100644
--- a/artemis-server/pom.xml
+++ b/artemis-server/pom.xml
@@ -157,10 +157,6 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -219,6 +215,21 @@
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
+
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java
index aaafebd..da8709c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/BridgeConfiguration.java
@@ -16,16 +16,17 @@
*/
package org.apache.activemq.artemis.core.config;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonString;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
import java.io.Serializable;
import java.io.StringReader;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
@@ -172,9 +173,11 @@ public final class BridgeConfiguration implements Serializable {
setFilterString(value);
} else if (key.equals(STATIC_CONNECTORS)) {
// convert JSON array to string list
- List<String> stringList = JsonLoader.readArray(new StringReader(value)).stream()
- .map(v -> ((JsonString) v).getString())
- .collect(Collectors.toList());
+ List<String> stringList = new ArrayList<>();
+ JsonArray staticConnectors = JsonLoader.readArray(new StringReader(value));
+ for (int i = 0; i < staticConnectors.size(); i++) {
+ stringList.add(staticConnectors.getString(i));
+ }
setStaticConnectors(stringList);
} else if (key.equals(DISCOVERY_GROUP_NAME)) {
setDiscoveryGroupName(value);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index 70f8a2d..2e0520f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -16,10 +16,10 @@
*/
package org.apache.activemq.artemis.core.management.impl;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanNotificationInfo;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
index b2f5209..ac45a30 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl;
-import javax.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import java.text.SimpleDateFormat;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BrokerBalancerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BrokerBalancerControlImpl.java
index 72963bb..298c956 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BrokerBalancerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/BrokerBalancerControlImpl.java
@@ -24,7 +24,7 @@ import org.apache.activemq.artemis.core.server.balancing.BrokerBalancer;
import org.apache.activemq.artemis.core.server.balancing.targets.Target;
import org.apache.activemq.artemis.utils.JsonLoader;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import javax.management.NotCompliantMBeanException;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index fe19ff7..4b4550d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -16,9 +16,9 @@
*/
package org.apache.activemq.artemis.core.management.impl;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
import javax.management.openmbean.CompositeData;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
index 265fb42..9522a28 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
@@ -16,9 +16,9 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java
index 2594f20..0964de5 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import org.apache.activemq.artemis.core.management.impl.view.predicate.AddressFilterPredicate;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java
index 18b8d30..6f38df3 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import java.util.Date;
import java.util.List;
import java.util.Set;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java
index 17919ca..0c8c50c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import java.util.Date;
import org.apache.activemq.artemis.api.core.client.ClientSession;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java
index fb4a6d6..30f2b68 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.core.management.impl.view.predicate.ProducerFilterPredicate;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java
index e38831a..cf5f303 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.core.management.impl.view.predicate.QueueFilterPredicate;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
index f1ece69..279e24f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import java.util.Date;
import org.apache.activemq.artemis.core.management.impl.view.predicate.SessionFilterPredicate;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
index 8e0b6f4..2439961 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
@@ -24,10 +24,9 @@ import java.util.GregorianCalendar;
import java.util.List;
import org.apache.activemq.artemis.core.server.Queue;
+import org.apache.activemq.artemis.json.JsonValue;
import org.apache.activemq.artemis.utils.JsonLoader;
-import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
-
/**
* This class stores message count informations for a given queue
*
@@ -336,8 +335,8 @@ public class MessageCounter {
String updateTimestamp = dateFormat.format(new Date(this.getLastUpdate()));
return JsonLoader
.createObjectBuilder()
- .add("destinationName", nullSafe(this.getDestinationName()))
- .add("destinationSubscription", nullSafe(this.getDestinationSubscription()))
+ .add("destinationName", this.getDestinationName(), JsonValue.NULL)
+ .add("destinationSubscription", this.getDestinationSubscription(), JsonValue.NULL)
.add("destinationDurable", this.isDestinationDurable())
.add("count", this.getCount())
.add("countDelta", this.getCountDelta())
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
index 9be9412..eff638f 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ServerSession.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.core.server;
-import javax.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
import javax.transaction.xa.Xid;
import java.util.EnumSet;
import java.util.List;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
index 0da2946..1c3cd0c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AddressInfo.java
@@ -16,13 +16,13 @@
*/
package org.apache.activemq.artemis.core.server.impl;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonString;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonNumber;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonString;
+import org.apache.activemq.artemis.json.JsonValue;
import java.io.StringReader;
import java.util.EnumSet;
import java.util.Map;
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index e80f91c..e36e54a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -16,8 +16,8 @@
*/
package org.apache.activemq.artemis.core.server.impl;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import java.security.cert.X509Certificate;
import javax.transaction.xa.XAException;
import javax.transaction.xa.Xid;
@@ -91,6 +91,7 @@ import org.apache.activemq.artemis.core.transaction.Transaction.State;
import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes;
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
+import org.apache.activemq.artemis.json.JsonValue;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
@@ -102,8 +103,6 @@ import org.apache.activemq.artemis.utils.collections.MaxSizeMap;
import org.apache.activemq.artemis.utils.collections.TypedProperties;
import org.jboss.logging.Logger;
-import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
-
/**
* Server side Session implementation
*/
@@ -1964,7 +1963,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
if (entry.getValue().getA() != null) {
uuid = entry.getValue().getA().toString();
}
- JsonObjectBuilder producerInfo = JsonLoader.createObjectBuilder().add("connectionID", this.getConnectionID().toString()).add("sessionID", this.getName()).add("destination", entry.getKey().toString()).add("lastUUIDSent", nullSafe(uuid)).add("msgSent", entry.getValue().getB().longValue());
+ JsonObjectBuilder producerInfo = JsonLoader.createObjectBuilder().add("connectionID", this.getConnectionID().toString()).add("sessionID", this.getName()).add("destination", entry.getKey().toString()).add("lastUUIDSent", uuid, JsonValue.NULL).add("msgSent", entry.getValue().getB().longValue());
array.add(producerInfo);
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
index 800aec3..255b041 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/TransactionDetail.java
@@ -16,9 +16,9 @@
*/
package org.apache.activemq.artemis.core.transaction;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonArrayBuilder;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import javax.transaction.xa.Xid;
import java.text.DateFormat;
import java.util.Date;
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/BridgeConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/BridgeConfigurationTest.java
index 85ed6b9..65f9b99 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/BridgeConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/BridgeConfigurationTest.java
@@ -21,10 +21,9 @@ import org.apache.activemq.artemis.utils.JsonLoader;
import org.junit.Assert;
import org.junit.Test;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonValue;
-import javax.json.spi.JsonProvider;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
+import org.apache.activemq.artemis.json.JsonValue;
import java.io.StringReader;
import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -162,7 +161,7 @@ public class BridgeConfigurationTest {
objectBuilder.add(BridgeConfiguration.FORWARDING_ADDRESS, "forwarding-address");
objectBuilder.add(BridgeConfiguration.FILTER_STRING, "filter-string");
objectBuilder.add(BridgeConfiguration.STATIC_CONNECTORS,
- JsonProvider.provider().createArrayBuilder()
+ JsonLoader.createArrayBuilder()
.add("connector1")
.add("connector2"));
objectBuilder.add(BridgeConfiguration.DISCOVERY_GROUP_NAME, "dg");
diff --git a/examples/features/standard/pom.xml b/examples/features/standard/pom.xml
index f29decd..37b95ab 100644
--- a/examples/features/standard/pom.xml
+++ b/examples/features/standard/pom.xml
@@ -160,6 +160,7 @@ under the License.
<module>pre-acknowledge</module>
<module>producer-rate-limit</module>
<module>queue</module>
+ <module>queue-jakarta</module>
<module>queue-requestor</module>
<module>queue-selector</module>
<module>reattach-node</module>
diff --git a/examples/features/standard/queue-jakarta/pom.xml b/examples/features/standard/queue-jakarta/pom.xml
index 9de4243..a9ba415 100644
--- a/examples/features/standard/queue-jakarta/pom.xml
+++ b/examples/features/standard/queue-jakarta/pom.xml
@@ -50,6 +50,20 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
+ <id>snapshot-check</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>dependency-scan</goal>
+ </goals>
+ <configuration>
+ <libList>
+ <arg>org.apache.activemq:artemis-jakarta-client-all:${project.version}</arg>
+ <arg>org.apache.activemq.examples.broker:queue-jakarta:${project.version}</arg>
+ </libList>
+ <variableName>ARTEMIS-JAKARTA</variableName>
+ </configuration>
+ </execution>
+ <execution>
<id>create</id>
<goals>
<goal>create</goal>
@@ -79,6 +93,7 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.QueueExample</clientClass>
+ <classPath>${ARTEMIS-JAKARTA}</classPath>
</configuration>
</execution>
<execution>
diff --git a/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
index d85c5ed..9ffed08 100644
--- a/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
+++ b/examples/features/standard/queue-jakarta/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
@@ -23,7 +23,7 @@ import jakarta.jms.MessageProducer;
import jakarta.jms.Queue;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
-import javax.naming.InitialContext;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
/**
* A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
@@ -31,39 +31,28 @@ import javax.naming.InitialContext;
public class QueueExample {
public static void main(final String[] args) throws Exception {
+
Connection connection = null;
- InitialContext initialContext = null;
try {
- // Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. Perform a lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
- // Step 3. Perform a lookup on the Connection Factory
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
+ ConnectionFactory cf = new ActiveMQConnectionFactory();
- // Step 4.Create a JMS Connection
connection = cf.createConnection();
- // Step 5. Create a JMS Session
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- // Step 6. Create a JMS Message Producer
+ Queue queue = session.createQueue("exampleQueue");
+
MessageProducer producer = session.createProducer(queue);
- // Step 7. Create a Text Message
TextMessage message = session.createTextMessage("This is a text message");
System.out.println("Sent message: " + message.getText());
- // Step 8. Send the Message
producer.send(message);
- // Step 9. Create a JMS Message Consumer
MessageConsumer messageConsumer = session.createConsumer(queue);
- // Step 10. Start the Connection
connection.start();
// Step 11. Receive the message
@@ -71,10 +60,6 @@ public class QueueExample {
System.out.println("Received message: " + messageReceived.getText());
} finally {
- // Step 12. Be sure to close our JMS resources!
- if (initialContext != null) {
- initialContext.close();
- }
if (connection != null) {
connection.close();
}
diff --git a/examples/features/standard/queue-jakarta/src/main/resources/jndi.properties b/examples/features/standard/queue-jakarta/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/features/standard/queue-jakarta/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-queue.queue/exampleQueue=exampleQueue
diff --git a/pom.xml b/pom.xml
index bfc05e8..fa6438a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,6 +105,7 @@
<errorprone.version>2.9.0</errorprone.version>
<maven.enforcer.plugin.version>3.0.0-M3</maven.enforcer.plugin.version>
<maven.bundle.plugin.version>5.1.2</maven.bundle.plugin.version>
+ <maven.shade.plugin.version>3.2.4</maven.shade.plugin.version>
<maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
<sevntu.checks.version>1.39.0</sevntu.checks.version>
<checkstyle.version>8.43</checkstyle.version>
@@ -481,12 +482,6 @@
<!-- License: EPL 2.0 -->
</dependency>
<dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- <version>${jakarta.json-api.version}</version>
- <!-- License: EPL 2.0 -->
- </dependency>
- <dependency>
<groupId>jakarta.ejb</groupId>
<artifactId>jakarta.ejb-api</artifactId>
<version>${jakarta.ejb-api.version}</version>
@@ -689,13 +684,6 @@
<version>${slf4j.version}</version>
<!-- License: MIT -->
</dependency>
- <!-- json -->
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <version>${johnzon.version}</version>
- </dependency>
-
<!--needed for the rest support-->
<dependency>
<groupId>org.jboss.resteasy</groupId>
@@ -930,6 +918,29 @@
<artifactId>zookeeper-jute</artifactId>
<version>${zookeeper.version}</version>
</dependency>
+
+
+
+ <!-- johnzon and jakarta.json are shaded on artemis-commons.
+ However during internal builds and test phase original bits may be used,
+ and this library would still be needed for test phase.
+ I am declaring scope as test by default to avoid any accidental use.
+ The only place where we are allowed to use this library is within artemis-commons.
+ anything other than that need to be carefully thought.
+ -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>${johnzon.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <version>${jakarta.json-api.version}</version>
+ <scope>test</scope>
+ <!-- License: EPL 2.0 -->
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -1441,7 +1452,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
- <version>3.2.0</version>
+ <version>${maven.shade.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
diff --git a/tests/compatibility-tests/pom.xml b/tests/compatibility-tests/pom.xml
index c98fd10..611656e 100644
--- a/tests/compatibility-tests/pom.xml
+++ b/tests/compatibility-tests/pom.xml
@@ -209,11 +209,6 @@
<artifactId>mqtt-client</artifactId>
</dependency>
<dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>jakarta.resource</groupId>
<artifactId>jakarta.resource-api</artifactId>
</dependency>
@@ -230,11 +225,6 @@
<artifactId>jakarta.management.j2ee-api</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
@@ -300,6 +290,21 @@
<artifactId>jboss-marshalling-river</artifactId>
<version>2.0.9.Final</version>
</dependency>
+
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQServerControlMultiThreadTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQServerControlMultiThreadTest.java
index 081ab88..1767630 100644
--- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQServerControlMultiThreadTest.java
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/ActiveMQServerControlMultiThreadTest.java
@@ -17,8 +17,8 @@
package org.apache.activemq.artemis.tests.extras.byteman;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 03f13c0..1f37374 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -214,11 +214,6 @@
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
</dependency>
<dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>jakarta.resource</groupId>
<artifactId>jakarta.resource-api</artifactId>
</dependency>
@@ -235,11 +230,6 @@
<artifactId>jakarta.management.j2ee-api</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
@@ -463,6 +453,22 @@
</exclusion>
</exclusions>
</dependency>
+
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMXManagementTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMXManagementTest.java
index f32153a..42b94c5 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMXManagementTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMXManagementTest.java
@@ -40,8 +40,8 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.Map;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java
index dfffee1..e67a828 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java
@@ -26,9 +26,7 @@ import javax.jms.QueueBrowser;
import javax.jms.QueueRequestor;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonString;
+import org.apache.activemq.artemis.json.JsonArray;
import javax.security.auth.Subject;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -38,13 +36,13 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
-import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
+import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.karaf.jaas.boot.principal.RolePrincipal;
import org.apache.karaf.jaas.boot.principal.UserPrincipal;
import org.apache.karaf.shell.api.console.Session;
@@ -183,8 +181,8 @@ public class ArtemisFeatureTest extends Assert {
m.setText("[\"ANYCAST\"]");
Message reply = requestor.request(m);
String json = ((TextMessage) reply).getText();
- JsonArray array = Json.createReader(new StringReader(json)).readArray();
- List<JsonString> queues = (List<JsonString>) array.get(0);
+ JsonArray array = JsonLoader.readArray(new StringReader(json));
+ JsonArray queues = array.getJsonArray(0);
assertNotNull(queues);
assertFalse(queues.isEmpty());
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index c4e3c26..8cda6cc 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -22,8 +22,8 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import java.nio.ByteBuffer;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
index 55c0f4d..73b39e1 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlTest.java
@@ -22,8 +22,8 @@ import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.json.JsonArray;
-import javax.json.JsonString;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonString;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.EnumSet;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
index bf447c7..93a141e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BroadcastGroupControlTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.tests.integration.management;
-import javax.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArray;
import java.util.ArrayList;
import java.util.List;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BrokerBalancerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BrokerBalancerControlTest.java
index 08716ca..005de61 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BrokerBalancerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/BrokerBalancerControlTest.java
@@ -28,8 +28,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import javax.json.JsonObject;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonValue;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.openmbean.CompositeData;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
index 092bce2..70d725b 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ClusterConnectionControlTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.artemis.tests.integration.management;
-import javax.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArray;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import java.util.ArrayList;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsChannelBroadcastGroupControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsChannelBroadcastGroupControlTest.java
index bef5b7c..13878bd 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsChannelBroadcastGroupControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsChannelBroadcastGroupControlTest.java
@@ -35,7 +35,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import javax.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArray;
import java.util.ArrayList;
import java.util.List;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsFileBroadcastGroupControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsFileBroadcastGroupControlTest.java
index ca8646e..4710bc0 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsFileBroadcastGroupControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/JGroupsFileBroadcastGroupControlTest.java
@@ -29,7 +29,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import javax.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonArray;
import java.util.ArrayList;
import java.util.List;
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
index 3b79b13..47164ca 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
@@ -16,9 +16,10 @@
*/
package org.apache.activemq.artemis.tests.integration.management;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonValue;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonNumber;
+import org.apache.activemq.artemis.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonValue;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -40,7 +41,6 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.johnzon.core.JsonLongImpl;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -88,7 +88,7 @@ public class ManagementWithPagingServerTest extends ManagementTestBase {
List<Long> longs = new ArrayList<>();
for (JsonValue jsonValue : array) {
JsonValue val = ((JsonObject) jsonValue).get("messageID");
- Long l = ((JsonLongImpl) val).longValue();
+ Long l = ((JsonNumber) val).longValue();
longs.add(l);
}
assertEquals(num, array.size());
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
index 4b2a58f..7d4804c 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
@@ -22,8 +22,8 @@ import javax.jms.DeliveryMode;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import javax.management.Notification;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
diff --git a/tests/joram-tests/pom.xml b/tests/joram-tests/pom.xml
index e29af9a..3b4386f 100644
--- a/tests/joram-tests/pom.xml
+++ b/tests/joram-tests/pom.xml
@@ -107,6 +107,20 @@
<artifactId>error_prone_core</artifactId>
</dependency>
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml
index 7de98a7..6552742 100644
--- a/tests/smoke-tests/pom.xml
+++ b/tests/smoke-tests/pom.xml
@@ -202,6 +202,21 @@
<artifactId>zookeeper-jute</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- The johnzon-core and json-api contents are repackaged in -commons,
+ However maven can still need them during tests, which run against
+ the original -commons classes when built+run in the same reactor,
+ and not the jar containing the shaded bits. -->
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx2/JmxServerControlTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx2/JmxServerControlTest.java
index a7802e7..ad16adb 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx2/JmxServerControlTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmx2/JmxServerControlTest.java
@@ -19,8 +19,8 @@ package org.apache.activemq.artemis.tests.smoke.jmx2;
import javax.jms.MessageConsumer;
import javax.jms.Session;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.remote.JMXConnector;
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmxmultiplefailback/ReplicatedMultipleFailbackTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmxmultiplefailback/ReplicatedMultipleFailbackTest.java
index 95a2346..7bfe660 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmxmultiplefailback/ReplicatedMultipleFailbackTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jmxmultiplefailback/ReplicatedMultipleFailbackTest.java
@@ -17,10 +17,8 @@
package org.apache.activemq.artemis.tests.smoke.jmxmultiplefailback;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
@@ -44,6 +42,7 @@ import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
+import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.Wait;
import org.jboss.logging.Logger;
import org.junit.Assert;
@@ -92,23 +91,21 @@ public class ReplicatedMultipleFailbackTest extends SmokeTestBase {
if (networkTopologyJson == null || networkTopologyJson.isEmpty()) {
return Collections.emptyMap();
}
- try (JsonReader jsonReader = Json.createReader(new StringReader(networkTopologyJson))) {
- final JsonArray nodeIDs = jsonReader.readArray();
- final int nodeCount = nodeIDs.size();
- Map<String, Pair<String, String>> networkTopology = new HashMap<>(nodeCount);
- for (int i = 0; i < nodeCount; i++) {
- final JsonObject nodePair = nodeIDs.getJsonObject(i);
- try {
- final String nodeID = nodePair.getString("nodeID");
- final String live = nodePair.getString("live");
- final String backup = nodePair.getString("backup", null);
- networkTopology.put(nodeID, new Pair<>(live, backup));
- } catch (Exception e) {
- LOGGER.warnf(e, "Error on %s", nodePair);
- }
+ final JsonArray nodeIDs = JsonLoader.readArray(new StringReader(networkTopologyJson));
+ final int nodeCount = nodeIDs.size();
+ Map<String, Pair<String, String>> networkTopology = new HashMap<>(nodeCount);
+ for (int i = 0; i < nodeCount; i++) {
+ final JsonObject nodePair = nodeIDs.getJsonObject(i);
+ try {
+ final String nodeID = nodePair.getString("nodeID");
+ final String live = nodePair.getString("live");
+ final String backup = nodePair.getString("backup", null);
+ networkTopology.put(nodeID, new Pair<>(live, backup));
+ } catch (Exception e) {
+ LOGGER.warnf(e, "Error on %s", nodePair);
}
- return networkTopology;
}
+ return networkTopology;
}
private static long countMembers(Map<String, Pair<String, String>> networkTopology) {
diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/utils/Jmx.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/utils/Jmx.java
index 5c5f044..b36b029 100644
--- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/utils/Jmx.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/utils/Jmx.java
@@ -16,10 +16,8 @@
*/
package org.apache.activemq.artemis.tests.smoke.utils;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
+import org.apache.activemq.artemis.json.JsonArray;
+import org.apache.activemq.artemis.json.JsonObject;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
@@ -38,6 +36,7 @@ import java.util.stream.Stream;
import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
+import org.apache.activemq.artemis.utils.JsonLoader;
import org.jboss.logging.Logger;
public class Jmx {
@@ -96,23 +95,21 @@ public class Jmx {
if (networkTopologyJson == null || networkTopologyJson.isEmpty()) {
return Collections.emptyMap();
}
- try (JsonReader jsonReader = Json.createReader(new StringReader(networkTopologyJson))) {
- final JsonArray nodeIDs = jsonReader.readArray();
- final int nodeCount = nodeIDs.size();
- Map<String, Pair<String, String>> networkTopology = new HashMap<>(nodeCount);
- for (int i = 0; i < nodeCount; i++) {
- final JsonObject nodePair = nodeIDs.getJsonObject(i);
- try {
- final String nodeID = nodePair.getString("nodeID");
- final String live = nodePair.getString("live");
- final String backup = nodePair.getString("backup", null);
- networkTopology.put(nodeID, new Pair<>(live, backup));
- } catch (Exception e) {
- LOGGER.warnf(e, "Error on %s", nodePair);
- }
+ final JsonArray nodeIDs = JsonLoader.readArray(new StringReader(networkTopologyJson));
+ final int nodeCount = nodeIDs.size();
+ Map<String, Pair<String, String>> networkTopology = new HashMap<>(nodeCount);
+ for (int i = 0; i < nodeCount; i++) {
+ final JsonObject nodePair = nodeIDs.getJsonObject(i);
+ try {
+ final String nodeID = nodePair.getString("nodeID");
+ final String live = nodePair.getString("live");
+ final String backup = nodePair.getString("backup", null);
+ networkTopology.put(nodeID, new Pair<>(live, backup));
+ } catch (Exception e) {
+ LOGGER.warnf(e, "Error on %s", nodePair);
}
- return networkTopology;
}
+ return networkTopology;
}
private static long countMembers(Map<String, Pair<String, String>> networkTopology) {