Search in sources :

Example 16 with JARArchive

use of org.wildfly.swarm.spi.api.JARArchive in project wildfly-swarm by wildfly-swarm.

the class RemoteMessagingArquillianTest method createDeployment.

@Deployment
public static Archive createDeployment() {
    JARArchive deployment = ShrinkWrap.create(JARArchive.class);
    deployment.add(EmptyAsset.INSTANCE, "nothing");
    deployment.addModule("org.wildfly.swarm.messaging");
    return deployment;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 17 with JARArchive

use of org.wildfly.swarm.spi.api.JARArchive in project wildfly-swarm by wildfly-swarm.

the class SimplifiedRemoteMessagingArquillianTest method createDeployment.

@Deployment
public static Archive createDeployment() {
    JARArchive deployment = ShrinkWrap.create(JARArchive.class);
    deployment.add(EmptyAsset.INSTANCE, "nothing");
    deployment.addModule("org.wildfly.swarm.messaging");
    return deployment;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 18 with JARArchive

use of org.wildfly.swarm.spi.api.JARArchive in project wildfly-swarm by wildfly-swarm.

the class ArqRequestControllerTest method createDeployment.

@Deployment(testable = false)
public static Archive createDeployment() {
    JARArchive deployment = ShrinkWrap.create(JARArchive.class);
    deployment.add(EmptyAsset.INSTANCE, "nothing");
    return deployment;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 19 with JARArchive

use of org.wildfly.swarm.spi.api.JARArchive in project wildfly-swarm by wildfly-swarm.

the class DeploymentProducer method index.

private void index(Archive<?> archive, List<IndexView> indexes) throws IOException {
    LOGGER.debugv("Indexing archive: {0}", archive.getName());
    // First try to load attached index
    Node indexNode = archive.get(ArchivePaths.create(INDEX_LOCATION));
    if (indexNode != null) {
        try (InputStream indexStream = indexNode.getAsset().openStream()) {
            LOGGER.debugv("Loading attached index from archive: {0}", archive.getName());
            indexes.add(new IndexReader(indexStream).read());
        }
    } else {
        // No index found - index all classes found
        Indexer indexer = new Indexer();
        for (Map.Entry<ArchivePath, Node> entry : archive.getContent(this::isClass).entrySet()) {
            try (InputStream contentStream = entry.getValue().getAsset().openStream()) {
                LOGGER.debugv("Indexing asset: {0} from archive: {1}", entry.getKey().get(), archive.getName());
                indexer.index(contentStream);
            } catch (IOException indexerIOException) {
                LOGGER.warnv(indexerIOException, "Failed parsing: {0} from archive: {1}", entry.getKey().get(), archive.getName());
            }
        }
        Index index = indexer.complete();
        indexes.add(index);
    }
    if (archive instanceof LibraryContainer) {
        for (Map.Entry<ArchivePath, Node> entry : archive.getContent(a -> a.get().endsWith(JAR_SUFFIX)).entrySet()) {
            if (entry.getValue().getAsset() instanceof ArchiveAsset) {
                ArchiveAsset archiveAsset = (ArchiveAsset) entry.getValue().getAsset();
                index(archiveAsset.getArchive(), indexes);
            } else {
                try (InputStream contentStream = entry.getValue().getAsset().openStream()) {
                    JARArchive jarArchive = ShrinkWrap.create(JARArchive.class, entry.getKey().get()).as(ZipImporter.class).importFrom(contentStream).as(JARArchive.class);
                    index(jarArchive, indexes);
                }
            }
        }
    }
}
Also used : Produces(javax.enterprise.inject.Produces) DeploymentScoped(org.wildfly.swarm.spi.runtime.annotations.DeploymentScoped) Logger(org.jboss.logging.Logger) Node(org.jboss.shrinkwrap.api.Node) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Indexer(org.jboss.jandex.Indexer) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) ArchivePaths(org.jboss.shrinkwrap.api.ArchivePaths) CompositeIndex(org.jboss.jandex.CompositeIndex) Map(java.util.Map) Index(org.jboss.jandex.Index) DeploymentContext(org.wildfly.swarm.container.runtime.cdi.DeploymentContext) IndexView(org.jboss.jandex.IndexView) ZipImporter(org.jboss.shrinkwrap.api.importer.ZipImporter) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) IndexReader(org.jboss.jandex.IndexReader) JARArchive(org.wildfly.swarm.spi.api.JARArchive) IOException(java.io.IOException) Archive(org.jboss.shrinkwrap.api.Archive) List(java.util.List) LibraryContainer(org.jboss.shrinkwrap.api.container.LibraryContainer) ApplicationScoped(javax.enterprise.context.ApplicationScoped) InputStream(java.io.InputStream) ArchiveAsset(org.jboss.shrinkwrap.api.asset.ArchiveAsset) InputStream(java.io.InputStream) Node(org.jboss.shrinkwrap.api.Node) CompositeIndex(org.jboss.jandex.CompositeIndex) Index(org.jboss.jandex.Index) ArchiveAsset(org.jboss.shrinkwrap.api.asset.ArchiveAsset) IOException(java.io.IOException) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) Indexer(org.jboss.jandex.Indexer) IndexReader(org.jboss.jandex.IndexReader) LibraryContainer(org.jboss.shrinkwrap.api.container.LibraryContainer) JARArchive(org.wildfly.swarm.spi.api.JARArchive) Map(java.util.Map)

Example 20 with JARArchive

use of org.wildfly.swarm.spi.api.JARArchive in project wildfly-swarm by wildfly-swarm.

the class DefaultJarDeploymentFactory method create.

@Override
public Archive create() throws Exception {
    JARArchive archive = ShrinkWrap.create(JARArchive.class, determineName());
    setup(archive);
    return archive;
}
Also used : JARArchive(org.wildfly.swarm.spi.api.JARArchive)

Aggregations

JARArchive (org.wildfly.swarm.spi.api.JARArchive)84 Deployment (org.jboss.arquillian.container.test.api.Deployment)52 Test (org.junit.Test)25 File (java.io.File)12 ShrinkWrap (org.jboss.shrinkwrap.api.ShrinkWrap)12 Files (java.nio.file.Files)11 ZipExporter (org.jboss.shrinkwrap.api.exporter.ZipExporter)11 Assertions.assertThat (org.fest.assertions.Assertions.assertThat)10 FractionUsageAnalyzer (org.wildfly.swarm.fractions.FractionUsageAnalyzer)10 IOException (java.io.IOException)5 Asset (org.jboss.shrinkwrap.api.asset.Asset)5 ServiceActivatorArchive (org.wildfly.swarm.msc.ServiceActivatorArchive)5 Assertions (org.fest.assertions.Assertions)4 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)4 Node (org.jboss.shrinkwrap.api.Node)4 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)4 InputStream (java.io.InputStream)3 Map (java.util.Map)3 ZipImporter (org.jboss.shrinkwrap.api.importer.ZipImporter)3 TopologyArchive (org.wildfly.swarm.topology.TopologyArchive)3