[KEYCLOAK-12909] - Keycloak uses embedded cache manager instead of container-managed one

This commit is contained in:
Pedro Igor 2020-02-05 22:15:05 -03:00 committed by Stian Thorgersen
parent b6c5acef25
commit 199e5dfa3e
4 changed files with 9 additions and 3 deletions

View file

@ -29,6 +29,7 @@
<module name="org.keycloak.keycloak-core"/> <module name="org.keycloak.keycloak-core"/>
<module name="org.keycloak.keycloak-server-spi"/> <module name="org.keycloak.keycloak-server-spi"/>
<module name="org.keycloak.keycloak-server-spi-private"/> <module name="org.keycloak.keycloak-server-spi-private"/>
<module name="org.keycloak.keycloak-wildfly-extensions" export="true" services="import"/>
<module name="org.infinispan"/> <module name="org.infinispan"/>
<module name="org.infinispan.commons"/> <module name="org.infinispan.commons"/>
<module name="org.infinispan.persistence.remote"/> <module name="org.infinispan.persistence.remote"/>

View file

@ -101,7 +101,7 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
synchronized (this) { synchronized (this) {
if (cacheManager == null) { if (cacheManager == null) {
EmbeddedCacheManager managedCacheManager = null; EmbeddedCacheManager managedCacheManager = null;
Iterator<ManagedCacheManagerProvider> providers = ServiceLoader.load(ManagedCacheManagerProvider.class) Iterator<ManagedCacheManagerProvider> providers = ServiceLoader.load(ManagedCacheManagerProvider.class, DefaultInfinispanConnectionProvider.class.getClassLoader())
.iterator(); .iterator();
if (providers.hasNext()) { if (providers.hasNext()) {
@ -115,6 +115,9 @@ public class DefaultInfinispanConnectionProviderFactory implements InfinispanCon
} }
if (managedCacheManager == null) { if (managedCacheManager == null) {
if (!config.getBoolean("embedded", false)) {
throw new RuntimeException("No " + ManagedCacheManagerProvider.class.getName() + " found. If running in embedded mode set the [embedded] property to this provider.");
}
initEmbedded(); initEmbedded();
} else { } else {
initContainerManaged(managedCacheManager); initContainerManaged(managedCacheManager);

View file

@ -140,7 +140,8 @@
"remoteStoreEnabled": "${keycloak.connectionsInfinispan.remoteStoreEnabled:false}", "remoteStoreEnabled": "${keycloak.connectionsInfinispan.remoteStoreEnabled:false}",
"remoteStoreHost": "${keycloak.connectionsInfinispan.remoteStoreServer:localhost}", "remoteStoreHost": "${keycloak.connectionsInfinispan.remoteStoreServer:localhost}",
"remoteStorePort": "${keycloak.connectionsInfinispan.remoteStorePort:11222}", "remoteStorePort": "${keycloak.connectionsInfinispan.remoteStorePort:11222}",
"hotrodProtocolVersion": "${keycloak.connectionsInfinispan.hotrodProtocolVersion}" "hotrodProtocolVersion": "${keycloak.connectionsInfinispan.hotrodProtocolVersion}",
"embedded": "${keycloak.connectionsInfinispan.embedded:true}"
} }
}, },

View file

@ -105,7 +105,8 @@
"remoteStoreEnabled": "${keycloak.connectionsInfinispan.remoteStoreEnabled:false}", "remoteStoreEnabled": "${keycloak.connectionsInfinispan.remoteStoreEnabled:false}",
"remoteStoreHost": "${keycloak.connectionsInfinispan.remoteStoreServer:localhost}", "remoteStoreHost": "${keycloak.connectionsInfinispan.remoteStoreServer:localhost}",
"remoteStorePort": "${keycloak.connectionsInfinispan.remoteStorePort:11222}", "remoteStorePort": "${keycloak.connectionsInfinispan.remoteStorePort:11222}",
"hotrodProtocolVersion": "${keycloak.connectionsInfinispan.hotrodProtocolVersion}" "hotrodProtocolVersion": "${keycloak.connectionsInfinispan.hotrodProtocolVersion}",
"embedded": "${keycloak.connectionsInfinispan.embedded:true}"
} }
}, },