From 1b0c4e5d1fca016d8fd6045189952c47bd9812a1 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 16 Jun 2015 13:29:27 +0200 Subject: [PATCH] KEYCLOAK-1468 Infinispan cache not available in JNDI --- .../feature-pack-build.xml | 3 + .../standalone/subsystems-ha.xml | 36 +++++++ .../configuration/standalone/subsystems.xml | 19 +++- distribution/subsystem-war/pom.xml | 12 +++ .../wildfly/InfinispanCacheActivator.java | 29 ++++++ .../org.jboss.msc.service.ServiceActivator | 1 + .../WEB-INF/jboss-deployment-structure.xml | 2 + .../keycloak-infinispan.xml | 93 +++++++++++++++++++ 8 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems-ha.xml create mode 100644 distribution/subsystem-war/src/main/java/org/keycloak/provider/wildfly/InfinispanCacheActivator.java create mode 100644 distribution/subsystem-war/src/main/resources/META-INF/services/org.jboss.msc.service.ServiceActivator create mode 100644 integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml diff --git a/distribution/feature-packs/server-feature-pack/feature-pack-build.xml b/distribution/feature-packs/server-feature-pack/feature-pack-build.xml index 8737c28576..48b588e0b9 100644 --- a/distribution/feature-packs/server-feature-pack/feature-pack-build.xml +++ b/distribution/feature-packs/server-feature-pack/feature-pack-build.xml @@ -4,6 +4,9 @@ + + + diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems-ha.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems-ha.xml new file mode 100644 index 0000000000..c402990ed1 --- /dev/null +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems-ha.xml @@ -0,0 +1,36 @@ + + + + + logging.xml + batch.xml + bean-validation.xml + keycloak-datasources.xml + ee.xml + ejb3.xml + io.xml + keycloak-infinispan.xml + jaxrs.xml + jca.xml + jdr.xml + jgroups.xml + jmx.xml + jpa.xml + jsf.xml + mail.xml + mod_cluster.xml + naming.xml + pojo.xml + remoting.xml + resource-adapters.xml + request-controller.xml + sar.xml + security-manager.xml + security.xml + transactions.xml + undertow.xml + webservices.xml + weld.xml + keycloak-server.xml + + \ No newline at end of file diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems.xml index d20bf2e610..f1dff3279e 100644 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems.xml +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/configuration/standalone/subsystems.xml @@ -3,21 +3,32 @@ logging.xml - + batch.xml bean-validation.xml keycloak-datasources.xml - ee.xml + ee.xml + ejb3.xml io.xml - infinispan.xml + keycloak-infinispan.xml jaxrs.xml jca.xml + jdr.xml + jmx.xml jpa.xml - naming.xml + jsf.xml + mail.xml + naming.xml + pojo.xml + remoting.xml + resource-adapters.xml request-controller.xml + sar.xml security-manager.xml security.xml transactions.xml undertow.xml + webservices.xml + weld.xml keycloak-server.xml diff --git a/distribution/subsystem-war/pom.xml b/distribution/subsystem-war/pom.xml index 4be6a118a8..66c20fdb34 100755 --- a/distribution/subsystem-war/pom.xml +++ b/distribution/subsystem-war/pom.xml @@ -15,6 +15,18 @@ Keycloak Subsystem Server WAR + + + org.jboss.msc + jboss-msc + 1.2.6.Final + + + org.keycloak + keycloak-core + + + auth-server diff --git a/distribution/subsystem-war/src/main/java/org/keycloak/provider/wildfly/InfinispanCacheActivator.java b/distribution/subsystem-war/src/main/java/org/keycloak/provider/wildfly/InfinispanCacheActivator.java new file mode 100644 index 0000000000..943f7a4cb4 --- /dev/null +++ b/distribution/subsystem-war/src/main/java/org/keycloak/provider/wildfly/InfinispanCacheActivator.java @@ -0,0 +1,29 @@ +package org.keycloak.provider.wildfly; + +import org.jboss.msc.service.*; +import org.keycloak.Config; + +import java.util.List; + +/** + * Used to add a dependency on Infinispan caches to make sure they are started. + * + * @author Stian Thorgersen + */ +public class InfinispanCacheActivator implements ServiceActivator { + + private static final ServiceName cacheContainerService = ServiceName.of("jboss", "infinispan", "keycloak"); + + @Override + public void activate(ServiceActivatorContext context) throws ServiceRegistryException { + if (context.getServiceRegistry().getService(cacheContainerService) != null) { + ServiceTarget st = context.getServiceTarget(); + st.addDependency(cacheContainerService); + st.addDependency(cacheContainerService.append("realms")); + st.addDependency(cacheContainerService.append("users")); + st.addDependency(cacheContainerService.append("sessions")); + st.addDependency(cacheContainerService.append("loginFailures")); + } + } + +} diff --git a/distribution/subsystem-war/src/main/resources/META-INF/services/org.jboss.msc.service.ServiceActivator b/distribution/subsystem-war/src/main/resources/META-INF/services/org.jboss.msc.service.ServiceActivator new file mode 100644 index 0000000000..bfed2e10c4 --- /dev/null +++ b/distribution/subsystem-war/src/main/resources/META-INF/services/org.jboss.msc.service.ServiceActivator @@ -0,0 +1 @@ +org.keycloak.provider.wildfly.InfinispanCacheActivator \ No newline at end of file diff --git a/distribution/subsystem-war/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/distribution/subsystem-war/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 816245c538..f67884e3b7 100755 --- a/distribution/subsystem-war/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/distribution/subsystem-war/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -56,6 +56,8 @@ + + diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml b/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml new file mode 100644 index 0000000000..30706ac978 --- /dev/null +++ b/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml @@ -0,0 +1,93 @@ + + + + org.jboss.as.clustering.infinispan + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file