ARTEMIS-565 Dealing with ClassLoading issues on managements. Caching provider loaded

This commit is contained in:
Clebert Suconic 2016-07-28 16:16:52 -04:00
parent ec64e674ee
commit fccf1c8243
15 changed files with 191 additions and 59 deletions

View File

@ -18,6 +18,7 @@ package org.apache.activemq.artemis.api.core;
import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.StringEscapeUtils;
import javax.json.Json;
@ -40,13 +41,13 @@ import java.util.Set;
public final class JsonUtil {
public static JsonArray toJSONArray(final Object[] array) throws Exception {
JsonArrayBuilder jsonArray = Json.createArrayBuilder();
JsonArrayBuilder jsonArray = JsonLoader.createArrayBuilder();
for (Object parameter : array) {
if (parameter instanceof Map) {
Map<String, Object> map = (Map<String, Object>) parameter;
JsonObjectBuilder jsonObject = Json.createObjectBuilder();
JsonObjectBuilder jsonObject = JsonLoader.createObjectBuilder();
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
@ -73,12 +74,12 @@ public final class JsonUtil {
Object[] innerArray = (Object[]) parameter;
if (innerArray instanceof CompositeData[]) {
JsonArrayBuilder innerJsonArray = Json.createArrayBuilder();
JsonArrayBuilder innerJsonArray = JsonLoader.createArrayBuilder();
for (Object data : innerArray) {
String s = Base64.encodeObject((CompositeDataSupport) data);
innerJsonArray.add(s);
}
JsonObjectBuilder jsonObject = Json.createObjectBuilder();
JsonObjectBuilder jsonObject = JsonLoader.createObjectBuilder();
jsonObject.add(CompositeData.class.getName(), innerJsonArray);
jsonArray.add(jsonObject);
}
@ -237,7 +238,7 @@ public final class JsonUtil {
}
public static JsonArray toJsonArray(List<String> strings) {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
if (strings != null) {
for (String connector : strings) {
array.add(connector);
@ -247,7 +248,7 @@ public final class JsonUtil {
}
public static JsonObject toJsonObject(Map<String, Object> map) {
JsonObjectBuilder jsonObjectBuilder = Json.createObjectBuilder();
JsonObjectBuilder jsonObjectBuilder = JsonLoader.createObjectBuilder();
if (map != null) {
for (Map.Entry<String, Object> entry : map.entrySet()) {
addToObject(entry.getKey(), entry.getValue(), jsonObjectBuilder);

View File

@ -23,9 +23,9 @@ import java.util.Map;
import org.apache.activemq.artemis.core.client.ActiveMQClientMessageBundle;
import org.apache.activemq.artemis.core.remoting.impl.TransportConfigurationUtil;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.UUIDGenerator;
import javax.json.Json;
import javax.json.JsonObject;
/**
@ -65,7 +65,7 @@ public class TransportConfiguration implements Serializable {
private static final byte TYPE_STRING = 3;
public JsonObject toJson() {
return Json.createObjectBuilder()
return JsonLoader.createObjectBuilder()
.add("name", name)
.add("factoryClassName", factoryClassName)
.add("params", JsonUtil.toJsonObject(params))

View File

@ -17,8 +17,8 @@
package org.apache.activemq.artemis.api.core.management;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.utils.JsonLoader;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
@ -37,14 +37,14 @@ public final class DayCounterInfo {
// Static --------------------------------------------------------
public static String toJSON(final DayCounterInfo[] infos) {
JsonObjectBuilder json = Json.createObjectBuilder();
JsonArrayBuilder counters = Json.createArrayBuilder();
JsonObjectBuilder json = JsonLoader.createObjectBuilder();
JsonArrayBuilder counters = JsonLoader.createArrayBuilder();
for (DayCounterInfo info : infos) {
JsonArrayBuilder counter = Json.createArrayBuilder();
JsonArrayBuilder counter = JsonLoader.createArrayBuilder();
for (int c : info.getCounters()) {
counter.add(c);
}
JsonObjectBuilder dci = Json.createObjectBuilder()
JsonObjectBuilder dci = JsonLoader.createObjectBuilder()
.add("date", info.getDate())
.add("counters", counter);
counters.add(dci);

View File

@ -16,10 +16,11 @@
*/
package org.apache.activemq.artemis.core.security;
import javax.json.Json;
import javax.json.JsonObject;
import java.io.Serializable;
import org.apache.activemq.artemis.utils.JsonLoader;
/**
* A role is used by the security store to define access rights and is configured on a connection factory or an address.
*/
@ -46,7 +47,7 @@ public class Role implements Serializable {
private final boolean browse;
public JsonObject toJson() {
return Json.createObjectBuilder()
return JsonLoader.createObjectBuilder()
.add("name", name)
.add("send", send)
.add("consume", consume)

View File

@ -0,0 +1,130 @@
/**
* 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.utils;
import javax.json.JsonArrayBuilder;
import javax.json.JsonBuilderFactory;
import javax.json.JsonObjectBuilder;
import javax.json.JsonReader;
import javax.json.JsonReaderFactory;
import javax.json.JsonWriter;
import javax.json.JsonWriterFactory;
import javax.json.spi.JsonProvider;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonGeneratorFactory;
import javax.json.stream.JsonParser;
import javax.json.stream.JsonParserFactory;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
/** This is to make sure we use the proper classLoader to load JSon libraries.
* This is equivalent to using {@link javax.json.Json} */
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);
}
}
});
}
public static JsonParser createParser(Reader reader) {
return provider.createParser(reader);
}
public static JsonParser createParser(InputStream in) {
return provider.createParser(in);
}
public static JsonGenerator createGenerator(Writer writer) {
return provider.createGenerator(writer);
}
public static JsonGenerator createGenerator(OutputStream out) {
return provider.createGenerator(out);
}
public static JsonParserFactory createParserFactory(Map<String, ?> config) {
return provider.createParserFactory(config);
}
public static JsonGeneratorFactory createGeneratorFactory(Map<String, ?> config) {
return provider.createGeneratorFactory(config);
}
public static JsonWriter createWriter(Writer writer) {
return provider.createWriter(writer);
}
public static JsonWriter createWriter(OutputStream out) {
return provider.createWriter(out);
}
public static JsonReader createReader(Reader reader) {
return provider.createReader(reader);
}
public static JsonReader createReader(InputStream in) {
return provider.createReader(in);
}
public static JsonReaderFactory createReaderFactory(Map<String, ?> config) {
return provider.createReaderFactory(config);
}
public static JsonWriterFactory createWriterFactory(Map<String, ?> config) {
return provider.createWriterFactory(config);
}
public static JsonArrayBuilder createArrayBuilder() {
return provider.createArrayBuilder();
}
public static JsonObjectBuilder createObjectBuilder() {
return provider.createObjectBuilder();
}
public static JsonBuilderFactory createBuilderFactory(Map<String, ?> config) {
return provider.createBuilderFactory(config);
}
}

View File

@ -17,7 +17,6 @@
package org.apache.activemq.artemis.jms.management.impl;
import javax.jms.InvalidSelectorException;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.management.MBeanInfo;
import javax.management.StandardMBean;
@ -48,6 +47,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
import org.apache.activemq.artemis.jms.management.impl.openmbean.JMSOpenTypeSupport;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.apache.activemq.artemis.utils.UUIDGenerator;
@ -75,7 +75,7 @@ public class JMSQueueControlImpl extends StandardMBean implements JMSQueueContro
}
static String toJSON(final Map<String, Object>[] messages) {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
for (Map<String, Object> message : messages) {
array.add(JsonUtil.toJsonObject(message));
}

View File

@ -17,7 +17,6 @@
package org.apache.activemq.artemis.jms.management.impl;
import javax.jms.JMSRuntimeException;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
@ -65,6 +64,7 @@ import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfigurat
import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
import org.apache.activemq.artemis.jms.server.management.JMSNotificationType;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.TypedProperties;
public class JMSServerControlImpl extends AbstractControl implements JMSServerControl, NotificationEmitter, org.apache.activemq.artemis.core.server.management.NotificationListener {
@ -602,7 +602,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
clearIO();
try {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
Set<RemotingConnection> connections = server.getActiveMQServer().getRemotingService().getConnections();
@ -620,7 +620,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
for (RemotingConnection connection : connections) {
ServerSession session = jmsSessions.get(connection.getID());
if (session != null) {
JsonObjectBuilder objectBuilder = Json.createObjectBuilder()
JsonObjectBuilder objectBuilder = JsonLoader.createObjectBuilder()
.add("connectionID", connection.getID().toString())
.add("clientAddress", connection.getRemoteAddress())
.add("creationTime", connection.getCreationTime());
@ -650,7 +650,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
clearIO();
try {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
Set<RemotingConnection> connections = server.getActiveMQServer().getRemotingService().getConnections();
for (RemotingConnection connection : connections) {
@ -822,7 +822,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
clearIO();
try {
JsonArrayBuilder brokers = Json.createArrayBuilder();
JsonArrayBuilder brokers = JsonLoader.createArrayBuilder();
ClusterManager clusterManager = server.getActiveMQServer().getClusterManager();
if (clusterManager != null) {
Set<ClusterConnection> clusterConnections = clusterManager.getClusterConnections();
@ -831,7 +831,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
Collection<TopologyMemberImpl> members = topology.getMembers();
for (TopologyMemberImpl member : members) {
JsonObjectBuilder obj = Json.createObjectBuilder();
JsonObjectBuilder obj = JsonLoader.createObjectBuilder();
TransportConfiguration live = member.getLive();
if (live != null) {
obj.add("nodeID", member.getNodeId())
@ -862,7 +862,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
if (destinationInfo == null) {
return null;
}
JsonObjectBuilder obj = Json.createObjectBuilder()
JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("consumerID", consumer.getID())
.add("connectionID", consumer.getConnectionID().toString())
.add("sessionID", consumer.getSessionID())
@ -905,7 +905,7 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
}
private JsonArray toJsonArray(Collection<ServerSession> sessions) {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
for (ServerSession session : sessions) {
Set<ServerConsumer> consumers = session.getServerConsumers();

View File

@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.management.MBeanInfo;
@ -39,6 +38,7 @@ import org.apache.activemq.artemis.core.server.management.ManagementService;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.SelectorTranslator;
import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
@ -292,7 +292,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
private String listSubscribersInfosAsJSON(final DurabilityType durability) throws Exception {
try {
List<QueueControl> queues = getQueues(durability);
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
for (QueueControl queue : queues) {
String clientID = null;
@ -313,7 +313,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
String filter = queue.getFilter() != null ? queue.getFilter() : null;
JsonObject info = Json.createObjectBuilder()
JsonObject info = JsonLoader.createObjectBuilder()
.add("queueName", queue.getName())
.add("clientID", nullSafe(clientID))
.add("selector", nullSafe(filter))

View File

@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.jms.server.impl;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
@ -88,6 +87,7 @@ import org.apache.activemq.artemis.jms.server.management.JMSNotificationType;
import org.apache.activemq.artemis.jms.server.management.impl.JMSManagementServiceImpl;
import org.apache.activemq.artemis.jms.transaction.JMSTransactionDetail;
import org.apache.activemq.artemis.spi.core.naming.BindingRegistry;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator;
import org.apache.activemq.artemis.utils.TypedProperties;
@ -1351,7 +1351,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
});
JsonArrayBuilder txDetailListJson = Json.createArrayBuilder();
JsonArrayBuilder txDetailListJson = JsonLoader.createArrayBuilder();
for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime) {
Xid xid = entry.getKey();
Transaction tx = resourceManager.getTransaction(xid);

View File

@ -21,8 +21,8 @@ import java.util.Date;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.core.messagecounter.MessageCounter;
import org.apache.activemq.artemis.utils.JsonLoader;
import javax.json.Json;
import javax.json.JsonObject;
import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
@ -62,7 +62,7 @@ public final class MessageCounterInfo {
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
String lastAddTimestamp = dateFormat.format(new Date(counter.getLastAddedMessageTime()));
String updateTimestamp = dateFormat.format(new Date(counter.getLastUpdate()));
return Json.createObjectBuilder()
return JsonLoader.createObjectBuilder()
.add("destinationName", nullSafe(counter.getDestinationName()))
.add("destinationSubscription", nullSafe(counter.getDestinationSubscription()))
.add("destinationDurable", counter.isDestinationDurable())

View File

@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.core.management.impl;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
@ -88,6 +87,7 @@ import org.apache.activemq.artemis.core.transaction.TransactionDetail;
import org.apache.activemq.artemis.core.transaction.impl.CoreTransactionDetail;
import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.SecurityFormatter;
import org.apache.activemq.artemis.utils.TypedProperties;
@ -974,7 +974,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
});
JsonArrayBuilder txDetailListJson = Json.createArrayBuilder();
JsonArrayBuilder txDetailListJson = JsonLoader.createArrayBuilder();
for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime) {
Xid xid = entry.getKey();
@ -1349,7 +1349,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
*/
@Override
public String listProducersInfoAsJSON() throws Exception {
JsonArrayBuilder producers = Json.createArrayBuilder();
JsonArrayBuilder producers = JsonLoader.createArrayBuilder();
for (ServerSession session : server.getSessions()) {
session.describeProducersInfo(producers);
@ -1365,12 +1365,12 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
try {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
Set<RemotingConnection> connections = server.getRemotingService().getConnections();
for (RemotingConnection connection : connections) {
JsonObjectBuilder obj = Json.createObjectBuilder()
JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("connectionID", connection.getID().toString())
.add("clientAddress", connection.getRemoteAddress())
.add("creationTime", connection.getCreationTime())
@ -1391,11 +1391,11 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
try {
List<ServerSession> sessions = server.getSessions(connectionID);
for (ServerSession sess : sessions) {
JsonObjectBuilder obj = Json.createObjectBuilder()
JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("sessionID", sess.getName())
.add("creationTime", sess.getCreationTime())
.add("consumerCount", sess.getServerConsumers().size());
@ -1420,7 +1420,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
try {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
Set<RemotingConnection> connections = server.getRemotingService().getConnections();
for (RemotingConnection connection : connections) {
@ -1451,7 +1451,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
try {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
Set<ServerSession> sessions = server.getSessions();
for (ServerSession session : sessions) {
@ -1471,7 +1471,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
private JsonObject toJSONObject(ServerConsumer consumer) throws Exception {
JsonObjectBuilder obj = Json.createObjectBuilder()
JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("consumerID", consumer.getID())
.add("connectionID", consumer.getConnectionID().toString())
.add("sessionID", consumer.getSessionID())
@ -1520,7 +1520,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
try {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
for (TransportConfiguration config : configuration.getConnectorConfigurations().values()) {
array.add(config.toJson());
@ -1615,7 +1615,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
clearIO();
try {
JsonArrayBuilder json = Json.createArrayBuilder();
JsonArrayBuilder json = JsonLoader.createArrayBuilder();
Set<Role> roles = server.getSecurityRepository().getMatch(addressMatch);
for (Role role : roles) {
@ -1635,7 +1635,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
String policy = addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.PAGE ? "PAGE" : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.BLOCK ? "BLOCK" : addressSettings.getAddressFullMessagePolicy() == AddressFullMessagePolicy.DROP ? "DROP" : "FAIL";
String consumerPolicy = addressSettings.getSlowConsumerPolicy() == SlowConsumerPolicy.NOTIFY ? "NOTIFY" : "KILL";
JsonObjectBuilder settings = Json.createObjectBuilder();
JsonObjectBuilder settings = JsonLoader.createObjectBuilder();
if (addressSettings.getDeadLetterAddress() != null) {
settings.add("DLA", addressSettings.getDeadLetterAddress().toString());
}

View File

@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.core.management.impl;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;
@ -36,6 +35,7 @@ import org.apache.activemq.artemis.core.postoffice.QueueBinding;
import org.apache.activemq.artemis.core.security.CheckType;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.utils.JsonLoader;
public class AddressControlImpl extends AbstractControl implements AddressControl {
@ -140,7 +140,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
public String getRolesAsJSON() throws Exception {
clearIO();
try {
JsonArrayBuilder json = Json.createArrayBuilder();
JsonArrayBuilder json = JsonLoader.createArrayBuilder();
Set<Role> roles = securityRepository.getMatch(address.toString());
for (Role role : roles) {

View File

@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.core.management.impl;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObjectBuilder;
@ -58,6 +57,7 @@ import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.LinkedListIterator;
import org.apache.activemq.artemis.utils.UUID;
@ -88,7 +88,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
}
private static JsonArray toJSONMsgArray(final Map<String, Object>[] messages) {
JsonArrayBuilder array = Json.createArrayBuilder();
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
for (Map<String, Object> message : messages) {
array.add(JsonUtil.toJsonObject(message));
}
@ -96,9 +96,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
}
private static String toJSON(final Map<String, Map<String, Object>[]> messages) {
JsonArrayBuilder arrayReturn = Json.createArrayBuilder();
JsonArrayBuilder arrayReturn = JsonLoader.createArrayBuilder();
for (Map.Entry<String, Map<String, Object>[]> entry : messages.entrySet()) {
JsonObjectBuilder objectItem = Json.createObjectBuilder();
JsonObjectBuilder objectItem = JsonLoader.createObjectBuilder();
objectItem.add("consumerName", entry.getKey());
objectItem.add("elements", toJSONMsgArray(entry.getValue()));
arrayReturn.add(objectItem);
@ -973,14 +973,14 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
try {
Collection<Consumer> consumers = queue.getConsumers();
JsonArrayBuilder jsonArray = Json.createArrayBuilder();
JsonArrayBuilder jsonArray = JsonLoader.createArrayBuilder();
for (Consumer consumer : consumers) {
if (consumer instanceof ServerConsumer) {
ServerConsumer serverConsumer = (ServerConsumer) consumer;
JsonObjectBuilder obj = Json.createObjectBuilder()
JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("consumerID", serverConsumer.getID())
.add("connectionID", serverConsumer.getConnectionID().toString())
.add("sessionID", serverConsumer.getSessionID())

View File

@ -16,7 +16,6 @@
*/
package org.apache.activemq.artemis.core.server.impl;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObjectBuilder;
import javax.transaction.xa.XAException;
@ -84,6 +83,7 @@ import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes;
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.TypedProperties;
import org.apache.activemq.artemis.utils.UUID;
import org.jboss.logging.Logger;
@ -1413,7 +1413,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
if (entry.getValue().getA() != null) {
uuid = entry.getValue().getA().toString();
}
JsonObjectBuilder producerInfo = Json.createObjectBuilder()
JsonObjectBuilder producerInfo = JsonLoader.createObjectBuilder()
.add("connectionID", this.getConnectionID().toString())
.add("sessionID", this.getName())
.add("destination", entry.getKey().toString())

View File

@ -21,7 +21,6 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
@ -31,6 +30,7 @@ import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
import org.apache.activemq.artemis.utils.JsonLoader;
public abstract class TransactionDetail {
@ -66,14 +66,14 @@ public abstract class TransactionDetail {
public JsonObject toJSON() throws Exception {
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
JsonObjectBuilder detailJson = Json.createObjectBuilder()
JsonObjectBuilder detailJson = JsonLoader.createObjectBuilder()
.add(KEY_CREATION_TIME, dateFormat.format(new Date(this.creationTime)))
.add(KEY_XID_AS_BASE64, XidImpl.toBase64String(this.xid))
.add(KEY_XID_FORMAT_ID, this.xid.getFormatId())
.add(KEY_XID_GLOBAL_TXID, new String(this.xid.getGlobalTransactionId()))
.add(KEY_XID_BRANCH_QUAL, new String(this.xid.getBranchQualifier()));
JsonArrayBuilder msgsJson = Json.createArrayBuilder();
JsonArrayBuilder msgsJson = JsonLoader.createArrayBuilder();
List<TransactionOperation> txops = null;
@ -100,7 +100,7 @@ public abstract class TransactionDetail {
}
for (MessageReference ref : msgs) {
JsonObjectBuilder msgJson = Json.createObjectBuilder();
JsonObjectBuilder msgJson = JsonLoader.createObjectBuilder();
msgJson.add(KEY_MSG_OP_TYPE, opType);