Skip to content

Commit

Permalink
[WFCORE-114] Make the new RuntimeVaultReader service provider loadable
Browse files Browse the repository at this point in the history
Deal with NCDFE that will happen if picketbox is not present
Change the module.xml to not see the legacy server subsystem service loader class
This will allow a WildFly Core based server to have vault support if picketbox is present
  • Loading branch information
bstansberry committed May 8, 2015
1 parent 835884c commit 1a55006
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
<module name="org.jboss.as.protocol"/>
<module name="org.jboss.as.remoting"/>
<module name="org.wildfly.security.manager" services="import"/>
<module name="org.jboss.as.security" optional="true" services="import"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.as.server" services="import"/>
<module name="org.jboss.as.version"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logmanager" services="import"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<module name="org.jboss.as.remoting"/>
<module name="org.jboss.as.self-contained" optional="true"/>
<module name="org.wildfly.security.manager" services="import"/>
<module name="org.jboss.as.security" optional="true" services="import"/>
<module name="org.jboss.as.version"/>
<module name="org.picketbox" optional="true"/>
<module name="io.undertow.core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -110,6 +111,7 @@
import org.jboss.as.domain.controller.HostRegistrations;
import org.jboss.as.domain.controller.LocalHostControllerInfo;
import org.jboss.as.domain.controller.SlaveRegistrationException;
import org.jboss.as.domain.controller.logging.DomainControllerLogger;
import org.jboss.as.domain.controller.operations.ApplyMissingDomainModelResourcesHandler;
import org.jboss.as.domain.controller.operations.coordination.PrepareStepHandler;
import org.jboss.as.domain.controller.resources.DomainRootDefinition;
Expand Down Expand Up @@ -223,7 +225,7 @@ static ServiceController<ModelController> addService(final ServiceTarget service
final ConcurrentMap<String, ProxyController> hostProxies = new ConcurrentHashMap<String, ProxyController>();
final Map<String, ProxyController> serverProxies = new ConcurrentHashMap<String, ProxyController>();
final LocalHostControllerInfoImpl hostControllerInfo = new LocalHostControllerInfoImpl(processState, environment);
final AbstractVaultReader vaultReader = service(AbstractVaultReader.class);
final AbstractVaultReader vaultReader = loadVaultReaderService();
ROOT_LOGGER.debugf("Using VaultReader %s", vaultReader);
final ContentRepository contentRepository = ContentRepository.Factory.create(environment.getDomainContentDir());
final IgnoredDomainResourceRegistry ignoredRegistry = new IgnoredDomainResourceRegistry(hostControllerInfo);
Expand Down Expand Up @@ -1080,11 +1082,24 @@ public boolean awaitServerSuspend(Set<String> waitForServers, int timeout) {
}
}

private static <S> S service(final Class<S> service) {
final ServiceLoader<S> serviceLoader = ServiceLoader.load(service);
final Iterator<S> it = serviceLoader.iterator();
if (it.hasNext())
return it.next();
private static AbstractVaultReader loadVaultReaderService() {
final ServiceLoader<AbstractVaultReader> serviceLoader = ServiceLoader.load(AbstractVaultReader.class,
DomainModelControllerService.class.getClassLoader());
final Iterator<AbstractVaultReader> it = serviceLoader.iterator();
// TODO WFCORE-114 get rid of catching/suppressing errors once we have a complete impl in WFCORE
ServiceConfigurationError sce = null;
while (it.hasNext()) {
try {
return it.next();
} catch (ServiceConfigurationError e) {
if (sce == null) {
sce = e;
}
}
}
if (sce != null) {
DomainControllerLogger.HOST_CONTROLLER_LOGGER.debugf(sce, "Cannot instantiate provider of service %s", AbstractVaultReader.class);
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.TreeSet;

Expand Down Expand Up @@ -150,7 +151,7 @@ public synchronized void start(final StartContext context) throws StartException
ServiceModuleLoader.addService(serviceTarget, configuration);
ExternalModuleService.addService(serviceTarget);
ModuleIndexService.addService(serviceTarget);
final AbstractVaultReader vaultReader = service(AbstractVaultReader.class);
final AbstractVaultReader vaultReader = loadVaultReaderService();
ServerLogger.AS_ROOT_LOGGER.debugf("Using VaultReader %s", vaultReader);
ServerService.addService(serviceTarget, configuration, processState, bootstrapListener, runningModeControl, vaultReader, configuration.getAuditLogger(), configuration.getAuthorizer());
final ServiceActivatorContext serviceActivatorContext = new ServiceActivatorContext() {
Expand Down Expand Up @@ -217,11 +218,24 @@ private String getVMArguments() {
return result.toString();
}

private static <S> S service(final Class<S> service) {
final ServiceLoader<S> serviceLoader = ServiceLoader.load(service);
final Iterator<S> it = serviceLoader.iterator();
if (it.hasNext())
return it.next();
private static AbstractVaultReader loadVaultReaderService() {
final ServiceLoader<AbstractVaultReader> serviceLoader = ServiceLoader.load(AbstractVaultReader.class,
ApplicationServerService.class.getClassLoader());
final Iterator<AbstractVaultReader> it = serviceLoader.iterator();
// TODO WFCORE-114 get rid of catching/suppressing errors once we have a complete impl in WFCORE
ServiceConfigurationError sce = null;
while (it.hasNext()) {
try {
return it.next();
} catch (ServiceConfigurationError e) {
if (sce == null) {
sce = e;
}
}
}
if (sce != null) {
ServerLogger.AS_ROOT_LOGGER.debugf(sce, "Cannot instantiate provider of service %s", AbstractVaultReader.class);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.jboss.as.server.services.security.RuntimeVaultReader

0 comments on commit 1a55006

Please sign in to comment.