Skip to content

Commit

Permalink
Issue #385: Allow import of type systems published through SPI
Browse files Browse the repository at this point in the history
- Added capabilities for the new unified provider
- Checking if a provider has already been processed when scanning legacy and new providers does not help because they are instantiated freshly on every call to the service provider scanner, so remove that
- Log different messages when loading through the legacy SPI interfaces and through the new one
  • Loading branch information
reckart committed Sep 30, 2024
1 parent 4f0776c commit aa50d4c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 24 deletions.
11 changes: 6 additions & 5 deletions uimafit-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@
org.apache.uima.fit.*
</Export-Package>
<Require-Capability>
osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypeSystemDescriptionProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypePrioritiesProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.FsIndexCollectionProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.fit.validation.ValidationCheck)";cardinality:=multiple;resolution:=optional
osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypeSystemProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypeSystemDescriptionProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypePrioritiesProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.FsIndexCollectionProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.fit.validation.ValidationCheck)";cardinality:=multiple;resolution:=optional
</Require-Capability>
</instructions>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,15 @@ static void loadFsIndexCollectionsfromSPIs(List<FsIndexDescription> fsIndexList)
var loaded = Collections.newSetFromMap(new IdentityHashMap<>());

ServiceLoader.load(FsIndexCollectionProvider.class).forEach(provider -> {
loaded.add(provider);
for (var fsIdxCol : provider.listFsIndexCollections()) {
loaded.add(fsIdxCol);
fsIndexList.addAll(asList(fsIdxCol.getFsIndexes()));
LOG.debug("Loaded SPI-provided index collection at [{}]", fsIdxCol.getSourceUrlString());
LOG.debug("Loaded legacy SPI-provided index collection at [{}]",
fsIdxCol.getSourceUrlString());
}
});

ServiceLoader.load(TypeSystemProvider.class).forEach(provider -> {
if (loaded.contains(provider)) {
return;
}

for (var fsIdxCol : provider.listFsIndexCollections()) {
if (loaded.contains(fsIdxCol)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,14 @@ static void loadTypePrioritiesFromSPIs(List<TypePriorities> typePrioritiesList)
var loaded = Collections.newSetFromMap(new IdentityHashMap<>());

ServiceLoader.load(TypePrioritiesProvider.class).forEach(provider -> {
loaded.add(provider);

for (var desc : provider.listTypePriorities()) {
loaded.add(desc);
typePrioritiesList.add(desc);
LOG.debug("Loaded SPI-provided type priorities at [{}]", desc.getSourceUrlString());
LOG.debug("Loaded legacy SPI-provided type priorities at [{}]", desc.getSourceUrlString());
}
});

ServiceLoader.load(TypeSystemProvider.class).forEach(provider -> {
if (loaded.contains(provider)) {
return;
}

for (var desc : provider.listTypePriorities()) {
if (loaded.contains(desc)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,14 @@ static void loadTypeSystemDescriptionsFromSPIs(List<TypeSystemDescription> tsdLi
var loaded = Collections.newSetFromMap(new IdentityHashMap<>());

ServiceLoader.load(TypeSystemDescriptionProvider.class).forEach(provider -> {
loaded.add(provider);
for (var desc : provider.listTypeSystemDescriptions()) {
loaded.add(desc);
tsdList.add(desc);
LOG.debug("Loaded SPI-provided type system at [{}]", desc.getSourceUrlString());
LOG.debug("Loaded legacy SPI-provided type system at [{}]", desc.getSourceUrlString());
}
});

ServiceLoader.load(TypeSystemProvider.class).forEach(provider -> {
if (loaded.contains(provider)) {
return;
}

for (var desc : provider.listTypeSystemDescriptions()) {
if (loaded.contains(desc)) {
continue;
Expand Down
1 change: 1 addition & 0 deletions uimaj-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
<Require-Capability>
osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.JCasClassProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypeSystemProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypeSystemDescriptionProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.TypePrioritiesProvider)";cardinality:=multiple;resolution:=optional,
osgi.serviceloader;filter:="(osgi.serviceloader=org.apache.uima.spi.FsIndexCollectionProvider)";cardinality:=multiple;resolution:=optional
Expand Down

0 comments on commit aa50d4c

Please sign in to comment.