From e929dae29c1d02d288b2e9820db40fedbd73f483 Mon Sep 17 00:00:00 2001 From: Adam Retter Date: Mon, 31 Jul 2023 21:29:40 +0200 Subject: [PATCH] [bugfix] Allow for one ExistXqueryRegistry per BrokerPool instance --- .../java/org/exist/storage/NativeBroker.java | 2 +- .../impl/RestXqServiceRegistryManager.java | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) 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;