private Instance<ServiceLoader> loader;
public void createRegistry(@Observes ArquillianDescriptor event)
{
LocalContainerRegistry reg = new LocalContainerRegistry(injector.get());
ServiceLoader serviceLoader = loader.get();
validateConfiguration(event);
String activeConfiguration = getActivatedConfiguration();
for(ContainerDef container : event.getContainers())
{
if(
(activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
(activeConfiguration == null && container.isDefault()))
{
reg.create(container, serviceLoader);
}
}
for(GroupDef group : event.getGroups())
{
if(
(activeConfiguration != null && activeConfiguration.equals(group.getGroupName())) ||
(activeConfiguration == null && group.isGroupDefault()))
{
for(ContainerDef container : group.getGroupContainers())
{
reg.create(container, serviceLoader);
}
}
}
if(activeConfiguration == null && reg.getContainers().size() == 0)
{
DeployableContainer<?> deployableContainer = null;
try
{
// 'check' if there are any DeployableContainers on CP
deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
}
catch (IllegalStateException e)
{
throw new IllegalStateException(
"Could not add a default container to registry because multipe " +