• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ContainerRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getContainerByDeployableContainer

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
public static Container getContainerByDeployableContainer(ContainerRegistry registry, DeployableContainer<?> dc) {
    for (Container container : registry.getContainers()) {
        if (dc == container.getDeployableContainer()) {
            return container;
        }
    }
    return null;
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:9,代码来源:ContainerUtil.java


示例17: startCubeMappedContainer

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
public void startCubeMappedContainer(@Observes BeforeStart event, CubeRegistry cubeRegistry,
    ContainerRegistry containerRegistry, CubeConfiguration cubeConfiguration) {
    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
    }
    ConnectionMode connectionMode = cubeConfiguration.getConnectionMode();

    if (connectionMode.isAllowReconnect() && cube.isRunningOnRemote()) {
        controlEvent.fire(new PreRunningCube(cube));
        return;
    }

    controlEvent.fire(new CreateCube(cube));
    controlEvent.fire(new StartCube(cube));

    if (connectionMode.isAllowReconnect() && !connectionMode.isStoppable()) {
        // If we allow reconnections and containers are none stoppable which means that they will be able to be
        // reused in next executions then at this point we can assume that the container is a prerunning container.

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


示例18: updateGroupMembersContainerState

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Update all Arquillian Containers in the Group with the new State.
 *
 * The Group can start/stop nodes outside of Arquillian's control.
 */
private void updateGroupMembersContainerState(State newState) {
    Set<Server> servers = domain.getServersInGroup(serverGroup);

    ContainerRegistry registry = containerRegistryInst.get();

    for (Server server : servers) {
        registry.getContainer(server.getContainerName()).setState(newState);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:15,代码来源:ServerGroupContainer.java


示例19: updateDomainMembersState

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * Update all Arquillian Containers in the Domain (group and server) with the new State.
 *
 * The Domain Controller can start/stop nodes outside of Arquillian's control.
 */
private void updateDomainMembersState(State newState) {
    ContainerRegistry registry = containerRegistryInstance.get();
    Domain domain = domainInst.get();

    for (Server server : domain.getServers()) {
        registry.getContainer(server.getContainerName()).setState(newState);
    }

    for (ServerGroup group : domain.getServerGroups()) {
        registry.getContainer(group.getContainerName()).setState(newState);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:18,代码来源:CommonDomainDeployableContainer.java


示例20: stop

import org.jboss.arquillian.container.spi.ContainerRegistry; //导入依赖的package包/类
/**
 * @see org.jboss.arquillian.container.test.impl.client.container.ClientContainerController#stop(java.lang.String)
 */
@Override
public void stop(String containerQualifier, int timeout) {
    {
        DeploymentScenario scenario = getDeploymentScenario().get();
        if (scenario == null) {
            throw new IllegalArgumentException("No deployment scenario in context");
        }

        ContainerRegistry registry = getContainerRegistry().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 (!isControllableContainer(registry.getContainers(), containerQualifier)) {
            throw new IllegalArgumentException("Could not start " + containerQualifier + " container. The container life cycle is controlled by Arquillian");
        }

        Container container = getContainerRegistry().get().getContainer(new TargetDescription(containerQualifier));

        List<Deployment> managedDeployments = scenario.startupDeploymentsFor(new TargetDescription(containerQualifier));

        for (Deployment d : managedDeployments) {
            if (d.isDeployed()) {
                log.info("Automatic undeploying of the managed deployment with name " + d.getDescription().getName() +
                        " from the container with name " + container.getName());
                getContainerControllerEvent().fire(new UnDeployDeployment(container, d));
            }
        }

        log.info("Manual stopping of a server instance with timeout=" + timeout);

        getContainerControllerEvent().fire(new StopContainerWithTimeout(container, timeout));
    }
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:42,代码来源:ClientWildFlyContainerController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResolverException类代码示例发布时间:2022-05-22
下一篇:
Java MultipleDocumentHandling类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap