From 7ae62c106049d77434fee2531cfa2bb18fda49f3 Mon Sep 17 00:00:00 2001 From: Marko Strukelj Date: Tue, 7 Jul 2015 16:26:55 +0200 Subject: [PATCH] KEYCLOAK-1529 Drop InfinispanCacheActivator and make subsystem do it --- .../wildfly/InfinispanCacheActivator.java | 29 ------------------- .../org.jboss.msc.service.ServiceActivator | 1 - .../KeycloakAdapterConfigService.java | 2 +- .../KeycloakServerDeploymentProcessor.java | 17 +++++++++++ 4 files changed, 18 insertions(+), 31 deletions(-) delete mode 100644 distribution/subsystem-war/src/main/java/org/keycloak/provider/wildfly/InfinispanCacheActivator.java delete mode 100644 distribution/subsystem-war/src/main/resources/META-INF/services/org.jboss.msc.service.ServiceActivator 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 deleted file mode 100644 index 943f7a4cb4..0000000000 --- a/distribution/subsystem-war/src/main/java/org/keycloak/provider/wildfly/InfinispanCacheActivator.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index bfed2e10c4..0000000000 --- a/distribution/subsystem-war/src/main/resources/META-INF/services/org.jboss.msc.service.ServiceActivator +++ /dev/null @@ -1 +0,0 @@ -org.keycloak.provider.wildfly.InfinispanCacheActivator \ No newline at end of file diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java b/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java index 8f3a59d641..1863549ceb 100755 --- a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java +++ b/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java @@ -26,7 +26,7 @@ public final class KeycloakAdapterConfigService { static final KeycloakAdapterConfigService INSTANCE = new KeycloakAdapterConfigService(); - static final String DEPLOYMENT_NAME = "keycloak-server"; + static final String DEPLOYMENT_NAME = "keycloak-server.war"; private String webContext; diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java b/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java index e951c7fd6b..150dbbd1d5 100644 --- a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java +++ b/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java @@ -21,6 +21,8 @@ import org.jboss.as.server.deployment.DeploymentPhaseContext; import org.jboss.as.server.deployment.DeploymentUnit; import org.jboss.as.server.deployment.DeploymentUnitProcessingException; import org.jboss.as.server.deployment.DeploymentUnitProcessor; +import org.jboss.msc.service.ServiceName; +import org.jboss.msc.service.ServiceTarget; /** * DUP responsible for setting the web context of a Keycloak auth server. @@ -29,6 +31,8 @@ import org.jboss.as.server.deployment.DeploymentUnitProcessor; */ public class KeycloakServerDeploymentProcessor implements DeploymentUnitProcessor { + private static final ServiceName cacheContainerService = ServiceName.of("jboss", "infinispan", "keycloak"); + @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); @@ -45,6 +49,19 @@ public class KeycloakServerDeploymentProcessor implements DeploymentUnitProcesso throw new DeploymentUnitProcessingException("Can't determine web context/module for Keycloak Server"); } description.setModuleName(webContext); + + addInfinispanCaches(phaseContext); + } + + private void addInfinispanCaches(DeploymentPhaseContext context) { + 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")); + } } @Override