org.jboss.arquillian.container.spi.ContainerRegistry Java Examples

The following examples show how to use org.jboss.arquillian.container.spi.ContainerRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegistryCreator.java    From keycloak with Apache License 2.0 6 votes vote down vote up
public void createRegistry(@Observes ArquillianDescriptor event) {
    ContainerRegistry reg = new Registry(injector.get());
    ServiceLoader serviceLoader = loader.get();

    log.info("arquillian.xml: " + System.getProperty("arquillian.xml"));

    @SuppressWarnings("rawtypes")
    Collection<DeployableContainer> containers = serviceLoader.all(DeployableContainer.class);

    if (containers.isEmpty()) {
        throw new IllegalStateException("There are not any container adapters on the classpath");
    }

    List<ContainerDef> containersDefs = event.getContainers();//arquillian.xml
    List<GroupDef> groupDefs = event.getGroups();//arquillian.xml

    addAppServerContainers(containersDefs, groupDefs);//dynamically loaded containers/groups

    createRegistry(containersDefs, reg, serviceLoader);

    for (GroupDef group : groupDefs) {
        createRegistry(group.getGroupContainers(), reg, serviceLoader);
    }

    registry.set(reg);
}
 
Example #2
Source File: ArquillianSuiteExtension.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
public void deploy(@Observes final AfterStart event, final ContainerRegistry registry) {
    executeInClassScope(new Callable<Void>() {
        public Void call() throws Exception {
            for (Deployment d : suiteDeploymentScenario.deployments()) {
                deploymentEvent.fire(new DeployDeployment(findContainer(registry, event.getDeployableContainer()), d));
            }
            return null;
        }
    });
}
 
Example #3
Source File: ArquillianSuiteExtension.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
public void undeploy(@Observes final BeforeStop event, final ContainerRegistry registry) {
    executeInClassScope(new Callable<Void>() {
        public Void call() throws Exception {
            for (Deployment d : suiteDeploymentScenario.deployments()) {
                deploymentEvent.fire(new UnDeployDeployment(findContainer(registry, event.getDeployableContainer()), d));
            }
            return null;
        }
    });
}
 
Example #4
Source File: ArquillianSuiteExtension.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
private Container findContainer(ContainerRegistry registry, DeployableContainer<?> deployable) {
    for (Container container : registry.getContainers()) {
        if (container.getDeployableContainer() == deployable) {
            return container;
        }
    }
    return null;
}
 
Example #5
Source File: RegistryCreator.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void createRegistry(List<ContainerDef> containerDefs, ContainerRegistry reg, ServiceLoader serviceLoader) {
    for (ContainerDef container : containerDefs) {
        if (isAdapterImplClassAvailable(container)) {
            if (isEnabled(container)) {
                log.info("Registering container: " + container.getContainerName());
                reg.create(container, serviceLoader);
            } else {
                log.info("Container is disabled: " + container.getContainerName());
            }
        }
    }
}
 
Example #6
Source File: KeycloakContainerDeployController.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void forEachDeployment(List<Deployment> deployments, ContainerDeployController.Operation<Container, Deployment> operation)
    throws Exception {
    injector.get().inject(operation);
    ContainerRegistry containerRegistry = this.containerRegistry.get();
    if (containerRegistry == null) {
        return;
    }
    for (Deployment deployment : deployments) {
        Container container = containerRegistry.getContainer(deployment.getDescription().getTarget());
        operation.perform(container, deployment);
    }
}
 
Example #7
Source File: LoadBalancerControllerProvider.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    String balancerName = null;

    // Check for the presence of possible qualifiers
    for (Annotation a : qualifiers) {
        Class<? extends Annotation> annotationType = a.annotationType();

        if (annotationType.equals(LoadBalancer.class)) {
            balancerName = ((LoadBalancer) a).value();
        }
    }

    ContainerRegistry reg = registry.get();
    Container container = null;
    if (balancerName == null || "".equals(balancerName.trim())) {
        if (reg.getContainers().size() == 1) {
            container = reg.getContainers().get(0);
        } else {
            throw new IllegalArgumentException("Invalid load balancer configuration request - need to specify load balancer name in @LoadBalancerController");
        }
    } else {
        container = reg.getContainer(balancerName);
    }

    if (container == null) {
        throw new IllegalArgumentException("Invalid load balancer configuration - load balancer not found: '" + balancerName + "'");
    }
    if (! (container.getDeployableContainer() instanceof LoadBalancerController)) {
        throw new IllegalArgumentException("Invalid load balancer configuration - container " + container.getName() + " is not a load balancer");
    }

    return container.getDeployableContainer();
}