KEYCLOAK-1529 Drop InfinispanCacheActivator and make subsystem do it

This commit is contained in:
Marko Strukelj 2015-07-07 16:26:55 +02:00
parent df6d75e2c5
commit 7ae62c1060
4 changed files with 18 additions and 31 deletions

View file

@ -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 <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/
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"));
}
}
}

View file

@ -1 +0,0 @@
org.keycloak.provider.wildfly.InfinispanCacheActivator

View file

@ -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;

View file

@ -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