private Instance<ServiceLoader> loader;
public void createRegistry(@Observes ArquillianDescriptor event)
{
ContainerRegistry reg = new ContainerRegistry();
ServiceLoader serviceLoader = loader.get();
String activeConfiguration = getActivatedConfiguration();
for(ContainerDef container : event.getContainers())
{
if(
(activeConfiguration != null && activeConfiguration.equals(container.getContainerName())) ||
(activeConfiguration == null && container.isDefault()))
{
reg.create(container, serviceLoader);
}
}
if(activeConfiguration != null)
{
for(GroupDef group : event.getGroups())
{
if(activeConfiguration.equals(group.getGroupName()))
{
for(ContainerDef container : group.getGroupContainers())
{
reg.create(container, serviceLoader);
}
}
}
}
else if(reg.getContainers().size() == 0)
{
try
{
DeployableContainer<?> deployableContainer = serviceLoader.onlyOne(DeployableContainer.class);
if(deployableContainer != null)
{
reg.create(new ContainerDefImpl("arquillian.xml").setContainerName("default"), serviceLoader);
}
}