diff --git a/exist-core/src/main/java/org/exist/storage/NativeBroker.java b/exist-core/src/main/java/org/exist/storage/NativeBroker.java
index 5aded217d84..8d81cbb8820 100644
--- a/exist-core/src/main/java/org/exist/storage/NativeBroker.java
+++ b/exist-core/src/main/java/org/exist/storage/NativeBroker.java
@@ -248,8 +248,8 @@ public NativeBroker(final BrokerPool pool, final Configuration config) throws EX
this.indexConfiguration = (IndexSpec) config.getProperty(Indexer.PROPERTY_INDEXER_CONFIG);
this.xmlSerializerPool = new XmlSerializerPool(this, config, 5);
+ pushSubject(pool.getSecurityManager().getSystemSubject());
try {
- pushSubject(pool.getSecurityManager().getSystemSubject());
//TODO : refactor so that we can,
//1) customize the different properties (file names, cache settings...)
//2) have a consistent READ-ONLY behaviour (based on *mandatory* files ?)
diff --git a/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceRegistryManager.java b/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceRegistryManager.java
index f651ab7d08e..b614e9ae47c 100644
--- a/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceRegistryManager.java
+++ b/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceRegistryManager.java
@@ -32,20 +32,31 @@
import org.exquery.restxq.RestXqServiceRegistry;
import org.exquery.restxq.impl.RestXqServiceRegistryImpl;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Map;
+
/**
*
* @author Adam Retter
*/
public final class RestXqServiceRegistryManager {
- private final static Logger LOG = LogManager.getLogger(RestXqServiceRegistryManager.class);
+ private static final Logger LOG = LogManager.getLogger(RestXqServiceRegistryManager.class);
- private static RestXqServiceRegistryImpl registry = null;
+ private static Map registries = null;
public static synchronized RestXqServiceRegistry getRegistry(final BrokerPool pool) {
-
- if(registry == null) {
+
+ RestXqServiceRegistryImpl registry = null;
+ if (registries == null) {
+ registries = new IdentityHashMap<>();
+ } else {
+ registry = registries.get(pool);
+ }
+
+ if (registry == null) {
LOG.info("Initialising RESTXQ...");
registry = new RestXqServiceRegistryImpl();
@@ -64,7 +75,9 @@ public static synchronized RestXqServiceRegistry getRegistry(final BrokerPool po
//NOTE: must load registry before listening for registered events
registry.addListener(persistence);
- LOG.info("RESTXQ is ready.");
+ LOG.info("RESTXQ is ready for eXist-db BrokerPool: " + pool.getId());
+
+ registries.put(pool, registry);
}
return registry;