-
-
Notifications
You must be signed in to change notification settings - Fork 191
[feature] Add ModuleFactory and IndexFactory SPI for auto-discovery of bundled modules and indexes #6551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
[feature] Add ModuleFactory and IndexFactory SPI for auto-discovery of bundled modules and indexes #6551
Changes from all commits
a19e921
9ec6fd7
fcb5d34
e80ba7a
f67b3a6
7f25cd0
cd0eac2
2cda6d2
9e914d9
e52b754
c03d824
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| * eXist-db Open Source Native XML Database | ||
| * Copyright (C) 2001 The eXist-db Authors | ||
| * | ||
| * info@exist-db.org | ||
| * http://www.exist-db.org | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
| package org.exist.indexing; | ||
|
|
||
| /** | ||
| * SPI for index module auto-discovery via {@code ServiceLoader}. | ||
| * | ||
| * <p>Register implementations in | ||
| * {@code META-INF/services/org.exist.indexing.IndexFactory}. | ||
| * A conf.xml {@code <module>} entry with the same id takes precedence; | ||
| * an entry with {@code enabled="no"} suppresses the SPI-registered module.</p> | ||
| */ | ||
| public interface IndexFactory { | ||
|
|
||
| /** | ||
| * The default conf.xml {@code id} for this index (e.g. {@code "lucene-index"}). | ||
| * Used as the key in the index registry and to match conf.xml override entries. | ||
| */ | ||
| String getDefaultId(); | ||
|
|
||
| /** The concrete {@link AbstractIndex} subclass to instantiate. */ | ||
| Class<? extends AbstractIndex> getIndexClass(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,6 +255,10 @@ private static Properties parseProperties(final Node container, final String ele | |
| for (int i = 0; i < params.getLength(); i++) { | ||
| final Element param = ((Element) params.item(i)); | ||
|
|
||
| if ("no".equalsIgnoreCase(param.getAttribute("enabled"))) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "no" or "false" or both?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "no" only — |
||
| continue; | ||
| } | ||
|
|
||
| final String name = param.getAttribute("name"); | ||
| final String value = param.getAttribute("value"); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * eXist-db Open Source Native XML Database | ||
| * Copyright (C) 2001 The eXist-db Authors | ||
| * | ||
| * info@exist-db.org | ||
| * http://www.exist-db.org | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
| package org.exist.xquery; | ||
|
|
||
| /** | ||
| * SPI interface for automatic XQuery module registration. | ||
| * | ||
| * <p>A JAR that bundles an XQuery module can self-register by: | ||
| * <ol> | ||
| * <li>Providing an implementation of this interface (conventionally a static | ||
| * inner class named {@code Factory} on the module class).</li> | ||
| * <li>Listing the implementation's fully-qualified class name in | ||
| * {@code META-INF/services/org.exist.xquery.ModuleFactory}.</li> | ||
| * </ol> | ||
| * | ||
| * <p>At startup, {@code Configuration} discovers all {@code ModuleFactory} | ||
| * implementations on the classpath via {@link java.util.ServiceLoader} and | ||
| * pre-populates the module registry before processing {@code conf.xml} entries. | ||
| * A {@code conf.xml} entry always wins over an SPI-discovered entry for the | ||
| * same namespace URI; {@code enabled="no"} suppresses an SPI-discovered module. | ||
| */ | ||
| public interface ModuleFactory { | ||
|
|
||
| /** | ||
| * The namespace URI that uniquely identifies the module. | ||
| * Must match the value returned by {@link Module#getNamespaceURI()} for | ||
| * the module class returned by {@link #getModuleClass()}. | ||
| * | ||
| * @return namespace URI | ||
| */ | ||
| String getNamespaceURI(); | ||
|
|
||
| /** | ||
| * The concrete {@link Module} implementation class to register. | ||
| * The class must have a public constructor accepting | ||
| * {@code Map<String, List<?>> parameters}. | ||
| * | ||
| * @return module implementation class | ||
| */ | ||
| Class<? extends Module> getModuleClass(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if if==null or "" or blank?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handled —
id != null && !id.isBlank()covers null, empty, and whitespace-only together; see the guard right above this line (21cd10a8cf, renumbered from11d1c929d9by today's rebase).