Skip to content

Commit

Permalink
[bugfix] Allow for one ExistXqueryRegistry per BrokerPool instance
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Jul 31, 2023
1 parent a97ecdc commit e929dae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,31 @@
import org.exquery.restxq.RestXqServiceRegistry;
import org.exquery.restxq.impl.RestXqServiceRegistryImpl;

import java.util.HashMap;

Check notice on line 35 in extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceRegistryManager.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceRegistryManager.java#L35

Unused import - java.util.HashMap.
import java.util.IdentityHashMap;
import java.util.Map;

/**
*
* @author <a href="mailto:adam.retter@googlemail.com">Adam Retter</a>
*/
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<BrokerPool, RestXqServiceRegistryImpl> 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();

Expand All @@ -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;
Expand Down

0 comments on commit e929dae

Please sign in to comment.