-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Implement CompatibilityMetadataProvider for Cache CLI args #41163
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
Merged
ahus1
merged 6 commits into
keycloak:main
from
ryanemerson:41138/cache_cli_option_compatibility_metadata_provider
Jul 16, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c1c4558
Implement CompatibilityMetadataProvider for Cache CLI args
ryanemerson 5d184f0
Add Provider id as a ctor param for AbstractCompatibilityMetadataProv…
ryanemerson ff900a6
Add isEnabled method to AbstractCompatibilityMetadataProvider
ryanemerson 57231a5
s/meta/customMeta
ryanemerson e49e3c4
Remove 'persistence' element from metadata as now tracked by FeatureC…
ryanemerson a23a7e5
Add test for adding a new Feature
ryanemerson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...ispan/src/main/java/org/keycloak/compatibility/AbstractCompatibilityMetadataProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.keycloak.compatibility; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import org.keycloak.Config; | ||
|
||
|
||
public abstract class AbstractCompatibilityMetadataProvider implements CompatibilityMetadataProvider { | ||
|
||
final String spi; | ||
final Config.Scope config; | ||
|
||
public AbstractCompatibilityMetadataProvider(String spi, String providerId) { | ||
this.spi = spi; | ||
this.config = Config.scope(spi, providerId); | ||
} | ||
|
||
abstract protected boolean isEnabled(Config.Scope scope); | ||
|
||
@Override | ||
public Map<String, String> metadata() { | ||
if (!isEnabled(config)) | ||
return Map.of(); | ||
|
||
Map<String, String> metadata = new HashMap<>(customMeta()); | ||
configKeys().forEach(key -> { | ||
String value = config.get(key); | ||
if (value != null) | ||
metadata.put(key, value); | ||
}); | ||
return metadata; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return spi; | ||
} | ||
|
||
protected Map<String, String> customMeta() { | ||
return Map.of(); | ||
} | ||
|
||
protected Stream<String> configKeys() { | ||
return Stream.of(); | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
...main/java/org/keycloak/infinispan/compatibility/CachingCompatibilityMetadataProvider.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
.../src/main/java/org/keycloak/infinispan/compatibility/CachingEmbeddedMetadataProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.keycloak.infinispan.compatibility; | ||
|
||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import org.infinispan.commons.util.Version; | ||
import org.keycloak.Config; | ||
import org.keycloak.compatibility.AbstractCompatibilityMetadataProvider; | ||
import org.keycloak.infinispan.util.InfinispanUtils; | ||
import org.keycloak.spi.infinispan.CacheEmbeddedConfigProviderSpi; | ||
import org.keycloak.spi.infinispan.impl.embedded.DefaultCacheEmbeddedConfigProviderFactory; | ||
|
||
public class CachingEmbeddedMetadataProvider extends AbstractCompatibilityMetadataProvider { | ||
|
||
public CachingEmbeddedMetadataProvider() { | ||
super(CacheEmbeddedConfigProviderSpi.SPI_NAME, DefaultCacheEmbeddedConfigProviderFactory.PROVIDER_ID); | ||
} | ||
|
||
@Override | ||
protected boolean isEnabled(Config.Scope scope) { | ||
return InfinispanUtils.isEmbeddedInfinispan(); | ||
} | ||
|
||
@Override | ||
public Map<String, String> customMeta() { | ||
return Map.of( | ||
"version", Version.getVersion(), | ||
"jgroupsVersion", org.jgroups.Version.printVersion() | ||
); | ||
} | ||
|
||
@Override | ||
public Stream<String> configKeys() { | ||
return Stream.of(DefaultCacheEmbeddedConfigProviderFactory.CONFIG, DefaultCacheEmbeddedConfigProviderFactory.STACK); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...an/src/main/java/org/keycloak/infinispan/compatibility/CachingRemoteMetadataProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.keycloak.infinispan.compatibility; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.keycloak.Config; | ||
import org.keycloak.compatibility.AbstractCompatibilityMetadataProvider; | ||
import org.keycloak.infinispan.util.InfinispanUtils; | ||
import org.keycloak.spi.infinispan.CacheRemoteConfigProviderSpi; | ||
import org.keycloak.spi.infinispan.impl.remote.DefaultCacheRemoteConfigProviderFactory; | ||
|
||
public class CachingRemoteMetadataProvider extends AbstractCompatibilityMetadataProvider { | ||
|
||
public CachingRemoteMetadataProvider() { | ||
super(CacheRemoteConfigProviderSpi.SPI_NAME, DefaultCacheRemoteConfigProviderFactory.PROVIDER_ID); | ||
} | ||
|
||
@Override | ||
protected boolean isEnabled(Config.Scope scope) { | ||
return InfinispanUtils.isRemoteInfinispan(); | ||
} | ||
|
||
@Override | ||
protected Stream<String> configKeys() { | ||
return Stream.of(DefaultCacheRemoteConfigProviderFactory.HOSTNAME, DefaultCacheRemoteConfigProviderFactory.PORT); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
.../src/main/java/org/keycloak/jgroups/certificates/JGroupsCertificatesMetadataProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.keycloak.jgroups.certificates; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.keycloak.Config; | ||
import org.keycloak.compatibility.AbstractCompatibilityMetadataProvider; | ||
import org.keycloak.infinispan.util.InfinispanUtils; | ||
import org.keycloak.spi.infinispan.JGroupsCertificateProviderSpi; | ||
|
||
public class JGroupsCertificatesMetadataProvider extends AbstractCompatibilityMetadataProvider { | ||
|
||
public JGroupsCertificatesMetadataProvider() { | ||
super(JGroupsCertificateProviderSpi.SPI_NAME, DefaultJGroupsCertificateProviderFactory.PROVIDER_ID); | ||
} | ||
|
||
@Override | ||
protected boolean isEnabled(Config.Scope scope) { | ||
return InfinispanUtils.isEmbeddedInfinispan(); | ||
} | ||
|
||
@Override | ||
public Stream<String> configKeys() { | ||
return Stream.of(DefaultJGroupsCertificateProviderFactory.ENABLED); | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
...main/resources/META-INF/services/org.keycloak.compatibility.CompatibilityMetadataProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
org.keycloak.infinispan.compatibility.CachingCompatibilityMetadataProvider | ||
org.keycloak.infinispan.compatibility.CachingEmbeddedMetadataProvider | ||
org.keycloak.infinispan.compatibility.CachingRemoteMetadataProvider | ||
org.keycloak.jgroups.certificates.JGroupsCertificatesMetadataProvider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure if this should be a combination of SPI and the Provider ID. For example,
InfinispanUserSessionProviderFactory
andRemoteUserSessionProviderFactory
both implement the same SPI.But let's leave it as is for now.