当前位置: 首页>>代码示例>>Java>>正文


Java ContainerRegistry类代码示例

本文整理汇总了Java中org.jboss.arquillian.container.spi.ContainerRegistry的典型用法代码示例。如果您正苦于以下问题:Java ContainerRegistry类的具体用法?Java ContainerRegistry怎么用?Java ContainerRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContainerRegistry类属于org.jboss.arquillian.container.spi包,在下文中一共展示了ContainerRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stopNodesAndContainersForClass

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Destroys test class level WildFly containers (and related Nodes) in test classes annotated with {@link WithWildFlyContainer}.
 */
public void stopNodesAndContainersForClass(@Observes StopClassContainers event, TestClass testClass, ContainerRegistry registry,
        CloudsRegistry cloudProviderRegistry) throws Exception {
    final Set<String> nodeNames = new HashSet<>();

    WithNode[] withNodes = testClass.getJavaClass().getAnnotationsByType(WithNode.class);
    if (withNodes != null) {
        Arrays.stream(withNodes).forEach(wn -> nodeNames.add(wn.value()));
    }

    WithWildFlyContainer[] containers = testClass.getJavaClass().getAnnotationsByType(WithWildFlyContainer.class);
    if (containers != null) {
        for (WithWildFlyContainer wflyContainer : containers) {
            final String nodeName = wflyContainer.value();
            nodeNames.add(nodeName);
            LOGGER.debug("Removing WildFly container configuration for class level node '{}'", nodeName);
            cloudProviderRegistry.stopWildFlyContainerInRegistry(nodeName, registry, containerContext.get());
        }
    }
    cloudProviderRegistry.cleanupNodes(node->nodeNames.contains(node.getName()));
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:24,代码来源:SunstoneObserver.java

示例2: stopNodesForSuite

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Removes nodes created on suite level and destroys provider listed in "arquillian.suite.destroy.providers" cloud property.
 */
public void stopNodesForSuite(@Observes AfterSuite event, ContainerRegistry registry, CloudsRegistry cloudsRegistry)
        throws LifecycleException {
    try {
        final Set<String> nodeNameSet = new HashSet<>();
        processSuiteLeveNodes(nodeProperties -> {
            LOGGER.debug("WildFly container {}  will be destroyed", nodeProperties.getName());
            nodeNameSet.add(nodeProperties.getName());
            if (nodeProperties.getPropertyAsBoolean(ArquillianConfig.Node.CONTAINER_REGISTER, false)) {
                try {
                    cloudsRegistry.stopWildFlyContainerInRegistry(nodeProperties.getName(), registry,
                            containerContext.get());
                } catch (Exception e) {
                    throw new RuntimeException("Stopping WildFly container failed", e);
                }
            }

        });
        cloudsRegistry.cleanupNodes(node -> nodeNameSet.contains(node.getName()));
    } finally {
        iterateSuiteCsvProperty(ArquillianConfig.Suite.DESTROY_PROVIDERS, cloudsRegistry::destroyProvider);
    }
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:26,代码来源:SunstoneObserver.java

示例3: configureArquillianForRemoteWildfly

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
private void configureArquillianForRemoteWildfly(GenericContainer dockerContainer, ContainerRegistry registry) {
   Integer wildflyHttpPort = dockerContainer.getMappedPort(WILDFLY_HTTP_PORT);
   Integer wildflyManagementPort = dockerContainer.getMappedPort(WILDFLY_MANAGEMENT_PORT);

   String containerIpAddress = dockerContainer.getContainerIpAddress();
   Container arquillianContainer = registry.getContainers().iterator().next();
   ContainerDef containerConfiguration = arquillianContainer.getContainerConfiguration();
   containerConfiguration.property(ContainerConfiguration.MANAGEMENT_ADDRESS_KEY, containerIpAddress);
   containerConfiguration.property(ContainerConfiguration.MANAGEMENT_PORT_KEY,
      String.valueOf(wildflyManagementPort));
   containerConfiguration.property(ContainerConfiguration.USERNAME_KEY, "admin");
   containerConfiguration.property(ContainerConfiguration.PASSWORD_KEY, "Admin#007");

   ProtocolDef protocolConfiguration = arquillianContainer
      .getProtocolConfiguration(new ProtocolDescription(ServletProtocolDefinition.NAME));
   protocolConfiguration.property(ServletProtocolDefinition.HOST_KEY, containerIpAddress);
   protocolConfiguration.property(ServletProtocolDefinition.PORT_KEY, String.valueOf(wildflyHttpPort));
}
 
开发者ID:kaiwinter,项目名称:testcontainers-examples,代码行数:19,代码来源:WildflyMariaDBDockerExtension.java

示例4: setup

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
@Before
public void setup() {

    Yaml yaml = new Yaml();
    @SuppressWarnings("unchecked")
    Map<String, Object> content = (Map<String, Object>) yaml.load(CONTENT);

    when(cube.getId()).thenReturn(CUBE_ID);
    when(cube.configuration()).thenReturn(content);
    when(container.getName()).thenReturn(CUBE_ID);
    when(container.getDeployableContainer()).thenReturn(deployableContainer);
    when(deployableContainer.getConfigurationClass()).thenReturn(ContainerConfiguration.class);
    when(container.getContainerConfiguration()).thenReturn(containerDef);
    when(containerRegistry.getContainers()).thenReturn(Arrays.asList(container));
    when(hasPortBindings.getContainerIP()).thenReturn("192.168.0.1");
    registry = new LocalCubeRegistry();
    registry.addCube(cube);

    bind(ApplicationScoped.class, CubeRegistry.class, registry);
    bind(ApplicationScoped.class, ContainerRegistry.class, containerRegistry);

}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:23,代码来源:DockerServerIPConfiguratorTest.java

示例5: stopCubeMappedContainer

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
public void stopCubeMappedContainer(@Observes AfterStop event, CubeRegistry cubeRegistry,
    ContainerRegistry containerRegistry) {
    Container container = ContainerUtil.getContainerByDeployableContainer(containerRegistry,
        event.getDeployableContainer());
    if (container == null) {
        return;
    }

    Cube<?> cube = cubeRegistry.getCube(ContainerUtil.getCubeIDForContainer(container));
    if (cube == null) {
        return; // No Cube found matching Container name, not managed by Cube
    }

    controlEvent.fire(new StopCube(cube));
    controlEvent.fire(new DestroyCube(cube));
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:17,代码来源:CubeContainerLifecycleController.java

示例6: setup

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
@Before
public void setup() {

    Yaml yaml = new Yaml();
    @SuppressWarnings("unchecked")
    Map<String, Object> content = (Map<String, Object>) yaml.load(CONTENT);

    when(cube.getId()).thenReturn(CUBE_ID);
    when(cube.configuration()).thenReturn(content);
    when(cube.getMetadata(HasPortBindings.class)).thenReturn(
        new TestPortBindings(new Binding("localhost").addPortBinding(8089, 8090)));
    when(container.getName()).thenReturn(CUBE_ID);
    when(container.getDeployableContainer()).thenReturn(deployableContainer);
    when(deployableContainer.getConfigurationClass()).thenReturn(ContainerConfiguration.class);
    when(container.getContainerConfiguration()).thenReturn(containerDef);
    when(containerRegistry.getContainers()).thenReturn(Arrays.asList(container));
    registry = new LocalCubeRegistry();
    registry.addCube(cube);

    bind(ApplicationScoped.class, CubeRegistry.class, registry);
    bind(ApplicationScoped.class, ContainerRegistry.class, containerRegistry);
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:23,代码来源:ContainerConfigurationControllerTest.java

示例7: setup

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setup() {
    when(cube.getId()).thenReturn(CUBE_ID);
    when(container.getName()).thenReturn(CUBE_ID);
    when(container.getDeployableContainer()).thenReturn(deployableContainer);
    when(container.getContainerConfiguration()).thenReturn(containerDef);
    when(containerDef.getContainerProperties()).thenReturn(Collections.EMPTY_MAP);
    when(containerRegistry.getContainers()).thenReturn(Arrays.asList(container));
    registry = new LocalCubeRegistry();
    registry.addCube(cube);

    bind(ApplicationScoped.class, CubeRegistry.class, registry);
    bind(ApplicationScoped.class, ContainerRegistry.class, containerRegistry);
    bind(ApplicationScoped.class, CubeConfiguration.class, new CubeConfiguration());
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:17,代码来源:CubeContainerLifecycleControllerTest.java

示例8: lookupInContainerContext

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Looks up the object in the containers context. The container used is provided by the {@link TargetsContainer}
 * annotation.
 *
 * @param targetsContainer the target container
 * @param resource         the resource annotation
 * @param qualifiers       any qualifier annotations
 *
 * @return the object found in the context
 */
protected Object lookupInContainerContext(final TargetsContainer targetsContainer, final ArquillianResource resource, final Annotation... qualifiers) {
    final ContainerRegistry registry = containerRegistryInstance.get();
    final ContainerContext context = containerContext.get();
    boolean contextActivated = false;
    try {
        final String name = targetsContainer.value();
        final Container container = registry.getContainer(name);
        if (container == null) {
            throw new IllegalArgumentException(String.format("No container named %s found in the registry.", name));
        }
        context.activate(name);
        contextActivated = true;
        return doLookup(resource, qualifiers);
    } finally {
        if (contextActivated) {
            context.deactivate();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:30,代码来源:AbstractTargetsContainerProvider.java

示例9: getDomainController

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
private DomainManager getDomainController(final String containerQualifier, boolean requiresControllable) {
    final ContainerRegistry registry = containerRegistry.get();
    if (registry == null) {
        throw new IllegalArgumentException("No container registry in context");
    }

    if (!containerExists(registry.getContainers(), containerQualifier)) {
        throw new IllegalArgumentException("No container with the specified name exists");
    }
    if (requiresControllable && !isControllableContainer(registry.getContainers(), containerQualifier)) {
        throw new IllegalArgumentException("Could not stop " + containerQualifier + " container. The container life cycle is controlled by Arquillian");
    }

    if (!isStarted(containerQualifier)) {
        throw new IllegalArgumentException(String.format("Container %s has not been started.", containerQualifier));
    }

    final Container container = registry.getContainer(containerQualifier);
    final DeployableContainer<?> deployableContainer = container.getDeployableContainer();
    if (deployableContainer instanceof CommonDomainDeployableContainer) {
        return CommonDomainDeployableContainer.class.cast(deployableContainer).getDomainManager();
    }
    throw new IllegalArgumentException(String.format("The container defined with %s is not a domain controller", containerQualifier));
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:25,代码来源:ClientDomainContainerController.java

示例10: lookupInContainerContext

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Looks up the object in the containers context. The container used is provided by the {@link TargetsContainer}
 * annotation.
 *
 * @param targetsContainer the target container
 * @param resource         the resource annotation
 * @param qualifiers       any qualifier annotations
 *
 * @return the object found in the context
 */
private Object lookupInContainerContext(final TargetsContainer targetsContainer, final ArquillianResource resource, final Annotation... qualifiers) {
    final ContainerRegistry registry = containerRegistryInstance.get();
    final ContainerContext context = containerContext.get();
    boolean contextActivated = false;
    try {
        final String name = targetsContainer.value();
        final Container container = registry.getContainer(name);
        if (container == null) {
            throw new IllegalArgumentException(String.format("No container named %s found in the registry.", name));
        }
        context.activate(name);
        contextActivated = true;
        return doLookup(resource, qualifiers);
    } finally {
        if (contextActivated) {
            context.deactivate();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:30,代码来源:AbstractTargetsContainerProvider.java

示例11: stopWildFlyContainerInRegistry

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
public void stopWildFlyContainerInRegistry(final String nodeName, ContainerRegistry registry,
        ContainerContext containerContext) throws LifecycleException {
    Container container = registry.getContainer(nodeName);
    if (container != null) {
        LOGGER.debug("Stoping container {}", nodeName);
        try {
            containerContext.activate(container.getName());
            container.stop();
        } finally {
            containerContext.deactivate();
        }
    } else {
        LOGGER.warn("Container {} was not found, so it can't be destroyed.", nodeName);
    }
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:16,代码来源:CloudsRegistry.java

示例12: registerInstance

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Method which observes {@link ContainerRegistry}. Gets called by Arquillian at startup time.
 * 
 * @param registry
 *           contains containers defined in arquillian.xml
 * @param serviceLoader
 */
public void registerInstance(@Observes ContainerRegistry registry, ServiceLoader serviceLoader) {
   GenericContainer dockerContainer = new GenericContainer(DOCKER_IMAGE)
      .withExposedPorts(WILDFLY_MANAGEMENT_PORT);
   dockerContainer.start();

   configureArquillianForRemoteWildfly(dockerContainer, registry);

   setupDb(dockerContainer);
}
 
开发者ID:kaiwinter,项目名称:testcontainers-examples,代码行数:17,代码来源:WildflyMariaDBDockerExtension.java

示例13: configure

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
public void configure(@Observes CubeDockerConfiguration event, ArquillianDescriptor arquillianDescriptor,
    ContainerRegistry registry) {

    if (event.getAutoStartContainers() == null) {
        AutoStartParser autoStartParser = resolveNotSetAutoStart(registry, event.getDockerContainersContent());
        event.setAutoStartContainers(autoStartParser);
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:9,代码来源:CubeDockerAutoStartConfigurator.java

示例14: resolveNotSetAutoStart

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
private AutoStartParser resolveNotSetAutoStart(ContainerRegistry containerRegistry, DockerCompositions containers) {
    //we want to use the automatic autoconfiguration
    List<String> containersName = toContainersName(containerRegistry.getContainers());

    if (containers.getNetworkIds().size() > 0) {
        //if network defined then you should not mix links and network
        return new AutomaticResolutionNetworkAutoStartParser(containersName, containers);
    } else {
        // if no network defined then links approach is used.
        return new AutomaticResolutionLinksAutoStartParser(containersName, containers);
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:13,代码来源:CubeDockerAutoStartConfigurator.java

示例15: applyDockerServerIpChange

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
public void applyDockerServerIpChange(@Observes BeforeSetup event, CubeRegistry cubeRegistry,
    ContainerRegistry containerRegistry)
    throws InstantiationException, IllegalAccessException, MalformedURLException {

    Container container = ContainerUtil.getContainerByDeployableContainer(containerRegistry,
        event.getDeployableContainer());
    if (container == null) {
        return;
    }
    Cube<?> cube = cubeRegistry.getCube(org.arquillian.cube.impl.util.ContainerUtil.getCubeIDForContainer(container));
    if (cube == null) {
        return; // No Cube found matching Container name, not managed by Cube
    }

    HasPortBindings portBindings = cube.getMetadata(HasPortBindings.class);
    if (portBindings == null) {
        return;
    }

    ContainerDef containerConfiguration = container.getContainerConfiguration();
    boolean foundAttribute =
        resolveConfigurationPropertiesWithDockerServerIp(containerConfiguration, portBindings.getContainerIP());

    //if user doesn't configured in arquillian.xml the host then we can override the default value.
    if (!foundAttribute) {
        Class<?> configurationClass = container.getDeployableContainer().getConfigurationClass();
        List<PropertyDescriptor> configurationClassHostOrAddressFields =
            filterConfigurationClassPropertiesByHostOrAddressAttribute(configurationClass);
        for (PropertyDescriptor propertyDescriptor : configurationClassHostOrAddressFields) {
            //we get default address value and we replace to boot2docker ip
            containerConfiguration.overrideProperty(propertyDescriptor.getName(), portBindings.getContainerIP());
        }
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:35,代码来源:DockerServerIPConfigurator.java


注:本文中的org.jboss.arquillian.container.spi.ContainerRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。