org.jboss.arquillian.container.spi.client.container.DeployableContainer Java Examples

The following examples show how to use org.jboss.arquillian.container.spi.client.container.DeployableContainer. 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: Registry.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private Container domainContainer(ServiceLoader loader, ContainerDef definition) {
    for (Container container : containers) {
        String adapterImplClassValue = container.getContainerConfiguration().getContainerProperties()
                .get(ADAPTER_IMPL_CONFIG_STRING);

        if (isServiceLoaderClassAssignableFromAdapterImplClass(loader, adapterImplClassValue.trim())) {
            try {
                return addContainer((Container) injector.inject(
                        new ContainerImpl(
                                definition.getContainerName(),
                                (DeployableContainer) loader.onlyOne(DeployableContainer.class),
                                definition)));
            } catch (Exception ex) {
                throw new ContainerCreationException(
                        "Could not create Container " + definition.getContainerName(), ex);
            }
        }
    }
    return null;
}
 
Example #2
Source File: RegistryCreator.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public static DeployableContainer<?> getContainerAdapter(String adapterImplClass, Collection<DeployableContainer> containers) {
    Validate.notNullOrEmpty(adapterImplClass, "The value of " + ADAPTER_IMPL_CONFIG_STRING + " can not be a null object "
            + "nor an empty string!");

    Class<?> foundAdapter;

    if (isClassPresent(adapterImplClass)) {
        foundAdapter = loadClass(adapterImplClass);
    } else {
        return null;
    }

    for (DeployableContainer<?> container : containers) {
        if (foundAdapter.isInstance(container)) {
            return container;
        }
    }

    return null;
}
 
Example #3
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 #4
Source File: RemoteTomEEExtension.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void register(final ExtensionBuilder builder) {
    if (ArquillianUtil.isCurrentAdapter(ADAPTER)) {

        final ReentrantLock l = lock;
        l.lock();

        try {

            if (!registered.getAndSet(true)) {

                try {
                    builder.observer(RemoteInitialContextObserver.class);
                    builder.observer(DeploymentExceptionObserver.class);
                    builder.service(DeployableContainer.class, RemoteTomEEContainer.class)
                                                .service(AuxiliaryArchiveAppender.class, RemoteTomEEEJBEnricherArchiveAppender.class)
                                                .service(ResourceProvider.class, DeploymentExceptionProvider.class);
                } catch (final IllegalArgumentException e) {
                    Logger.getLogger(RemoteTomEEExtension.class.getName()).log(Level.WARNING, "RemoteTomEEExtension: " + e.getMessage());
                }
            }
        } finally {
            l.unlock();
        }
    }
}
 
Example #5
Source File: EmbeddedTomEEExtension.java    From tomee with Apache License 2.0 6 votes vote down vote up
@Override
public void register(final ExtensionBuilder builder) {
    if (ArquillianUtil.isCurrentAdapter(ADAPTER)) {
        builder.service(DeployableContainer.class, EmbeddedTomEEContainer.class)
            .observer(DeploymentExceptionObserver.class)
            .observer(RemoteInitialContextObserver.class)
            .observer(TestObserver.class)
            .service(TestEnricher.class, TomEEInjectionEnricher.class)
            .service(ResourceProvider.class, DeploymentExceptionProvider.class);

        try {
            builder.service(TransactionProvider.class,
                    (Class<? extends TransactionProvider>) Thread.currentThread().getContextClassLoader()
                            .loadClass("org.apache.openejb.arquillian.transaction.OpenEJBTransactionProvider"));
        } catch (final Throwable t) {
            // skip, not mandatory
        }
    }
}
 
Example #6
Source File: QuarkusExtension.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder.service(DeployableContainer.class, QuarkusDeployableContainer.class);
    builder.service(Protocol.class, QuarkusProtocol.class);
    builder.service(TestEnricher.class, InjectionEnricher.class);
    builder.service(TestEnricher.class, ArquillianResourceURLEnricher.class);
    builder.observer(CreationalContextDestroyer.class);
    builder.observer(QuarkusBeforeAfterLifecycle.class);
    builder.observer(RequestContextLifecycle.class);
    builder.observer(ClassLoaderExceptionTransformer.class);
}
 
Example #7
Source File: UndertowAppServerArquillianExtension.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder
            .service(DeployableContainer.class, UndertowAppServer.class)
            .service(ApplicationArchiveProcessor.class, UndertowDeploymentArchiveProcessor.class);

}
 
Example #8
Source File: Registry.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public Container create(ContainerDef definition, ServiceLoader loader) {
    Validate.notNull(definition, "Definition must be specified");

    try {
        logger.log(Level.FINE, "Registering container: {0}", definition.getContainerName());

        @SuppressWarnings("rawtypes")
        Collection<DeployableContainer> containerAdapters = loader.all(DeployableContainer.class);

        DeployableContainer<?> dcService = null;

        if (containerAdapters.size() == 1) {
            // just one container on cp
            dcService = containerAdapters.iterator().next();
        } else {
            Container domainContainer = domainContainer(loader, definition);
            if (domainContainer != null) {
                return domainContainer;
            }
            if (dcService == null) {
                dcService = getContainerAdapter(getAdapterImplClassValue(definition), containerAdapters);
            }
            if (dcService == null) {
                throw new ConfigurationException("Unable to get container adapter from Arquillian configuration.");
            }
        }

        // before a Container is added to a collection of containers, inject into its injection point
        return addContainer(injector.inject(
                new ContainerImpl(definition.getContainerName(), dcService, definition)));

    } catch (ConfigurationException e) {
        throw new ContainerCreationException("Could not create Container " + definition.getContainerName(), e);
    }
}
 
Example #9
Source File: MultipleContainersExtension.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {

    logger.info("Multiple containers extension registering.");

    builder.service(DeployableContainer.class, KeycloakQuarkusServerDeployableContainer.class);

    builder.context(ContainerContextImpl.class).context(DeploymentContextImpl.class);

    builder.observer(RegistryCreator.class)
            .observer(ContainerDeploymentContextHandler.class)
            .observer(ContainerLifecycleController.class)
            .observer(ArchiveDeploymentExporter.class)
            .observer(DeploymentExceptionHandler.class);
}
 
Example #10
Source File: RegistryCreator.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
private boolean isAdapterImplClassAvailable(ContainerDef containerDef) {

    if (hasAdapterImplClassProperty(containerDef)) {
        if (isClassPresent(getAdapterImplClassValue(containerDef))) {
            return DeployableContainer.class.isAssignableFrom(
                    loadClass(getAdapterImplClassValue(containerDef)));
        } else {
            log.warn("Cannot load adapterImpl class for " + containerDef.getContainerName());
        }
    }

    return false;
}
 
Example #11
Source File: OpenEJBExtension.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void register(final ExtensionBuilder extensionBuilder) {
    if (ArquillianUtil.isCurrentAdapter(OPENEJB_ADAPTER_NAME)) {
        extensionBuilder.service(DeployableContainer.class, OpenEJBDeployableContainer.class)
            .service(TestEnricher.class, OpenEJBInjectionEnricher.class)
            .service(ResourceProvider.class, DeploymentExceptionProvider.class)
            .service(TransactionProvider.class, OpenEJBTransactionProvider.class)
            .observer(TestObserver.class)
            .observer(DeploymentExceptionObserver.class);
    }
}
 
Example #12
Source File: ArquillianUtil.java    From tomee with Apache License 2.0 5 votes vote down vote up
public static void undeploy(final DeployableContainer<?> container, final Collection<Archive<?>> containerArchives) {
    if (containerArchives != null) {
        for (final Archive<?> a  : containerArchives) {
            try {
                container.undeploy(a);
            } catch (final DeploymentException e) {
                Logger.getLogger(container.getClass().getName()).log(Level.SEVERE, e.getMessage(), e);
            }
        }
    }
}
 
Example #13
Source File: TomEEWebappExtension.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Override
public void register(final ExtensionBuilder builder) {
    if (ArquillianUtil.isCurrentAdapter(ADAPTER)) {

        final ReentrantLock l = lock;
        l.lock();

        try {

            if (!registered.getAndSet(true)) {

                try {
                    builder.observer(DeploymentExceptionObserver.class);
                    builder.observer(RemoteInitialContextObserver.class);

                    builder.service(DeployableContainer.class, TomEEWebappContainer.class)
                            .service(AuxiliaryArchiveAppender.class, TomEEWebappEJBEnricherArchiveAppender.class)
                            .service(ResourceProvider.class, DeploymentExceptionProvider.class);
                } catch (final IllegalArgumentException e) {
                    Logger.getLogger(TomEEWebappExtension.class.getName()).log(Level.WARNING, "TomEEWebappExtension: " + e.getMessage());
                }
            }
        } finally {
            l.unlock();
        }
    }
}
 
Example #14
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 #15
Source File: FurnaceLoadableExtension.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void register(ExtensionBuilder builder)
{
   builder.service(DeployableContainer.class, FurnaceDeployableContainer.class);
   builder.service(DeploymentScenarioGenerator.class, FurnaceDeploymentScenarioGenerator.class);
   builder.service(Protocol.class, FurnaceProtocol.class);
   builder.service(AuxiliaryArchiveProcessor.class, FurnaceAuxiliaryArchiveProcessor.class);
}
 
Example #16
Source File: TargetController.java    From arquillian-container-chameleon with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public TargetController(ContainerAdapter adapter, Injector injector, File resolverCacheFolder) throws Exception {
    // init
    this.classloader = resolveClasspathDependencies(adapter, resolverCacheFolder);
    final Class<?> delegateClass = classloader.loadClass(adapter.adapterClass());
    this.delegate = injector.inject((DeployableContainer) delegateClass.newInstance());
    this.adapter = adapter;
}
 
Example #17
Source File: WildFlySwarmExtension.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder.service(Protocol.class, DaemonProtocol.class)
            .service(AuxiliaryArchiveAppender.class, WildFlySwarmDeploymentAppender.class)
            .service(DeployableContainer.class, WildFlySwarmContainer.class)
            .override(ResourceProvider.class, URLResourceProvider.class, SwarmURLResourceProvider.class)
            .override(ResourceProvider.class, URIResourceProvider.class, SwarmURIResourceProvider.class)
            .observer(WildFlySwarmObserver.class);
}
 
Example #18
Source File: WildFlySwarmExtension.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder.service(Protocol.class, DaemonProtocol.class)
            .service(AuxiliaryArchiveAppender.class, WildFlySwarmDeploymentAppender.class)
            .service(DeployableContainer.class, WildFlySwarmContainer.class)
            .override(DeploymentScenarioGenerator.class, AnnotationDeploymentScenarioGenerator.class, DefaultDeploymentScenarioGenerator.class)
            .override(ResourceProvider.class, URLResourceProvider.class, SwarmURLResourceProvider.class)
            .override(ResourceProvider.class, URIResourceProvider.class, SwarmURIResourceProvider.class)
            .observer(WildFlySwarmObserver.class);
}
 
Example #19
Source File: ChameleonExtension.java    From arquillian-container-chameleon with Apache License 2.0 4 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder.service(DeployableContainer.class, ChameleonContainer.class);
    builder.observer(InitiateContainer.class);
}
 
Example #20
Source File: MeecrowaveExtension.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
@Override
public void register(final ExtensionBuilder extensionBuilder) {
    extensionBuilder.service(DeployableContainer.class, MeecrowaveContainer.class);
}
 
Example #21
Source File: PiranhaServerLoadableExtension.java    From piranha with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder.service(DeployableContainer.class, PiranhaServerDeployableContainer.class);
}
 
Example #22
Source File: KeycloakOnUndertowArquillianExtension.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder.service(DeployableContainer.class, KeycloakOnUndertow.class);
    builder.service(DeployableContainer.class, SimpleUndertowLoadBalancerContainer.class);
}
 
Example #23
Source File: ManagedSEContainerExtension.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void register(final ExtensionBuilder builder) {
    builder.service(DeployableContainer.class, ManagedSEDeployableContainer.class);
    builder.service(Protocol.class, CustomJMXProtocol.class);
    builder.service(AuxiliaryArchiveAppender.class, SEContainerAppender.class);
}
 
Example #24
Source File: JettyAppServerArquillianExtension.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {
    builder
            .service(DeployableContainer.class, JettyAppServer.class)
            .service(ApplicationArchiveProcessor.class, JettyDeploymentArchiveProcessor.class);
}
 
Example #25
Source File: Fuse63AppServerArquillianExtension.java    From keycloak with Apache License 2.0 2 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {

    builder.service(DeployableContainer.class, CustomFuseContainer.class);

}
 
Example #26
Source File: Fuse7xAppServerArquillianExtension.java    From keycloak with Apache License 2.0 2 votes vote down vote up
@Override
public void register(ExtensionBuilder builder) {

    builder.service(DeployableContainer.class, CustomFuseContainer.class);

}