Search in sources :

Example 31 with WARArchive

use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.

the class ArquillianTest method createDeployment.

@Deployment
public static Archive createDeployment() throws Exception {
    WARArchive deployment = ShrinkWrap.create(WARArchive.class, "services.war");
    deployment.addClass(ServicesServlet.class);
    deployment.addClass(TransformerServlet.class);
    return deployment;
}
Also used : WARArchive(org.wildfly.swarm.undertow.WARArchive) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 32 with WARArchive

use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.

the class FlywayMigrationArchivePreparer method process.

@Override
public void process() {
    if (archive.getName().endsWith(".war")) {
        WARArchive webArchive = archive.as(WARArchive.class);
        WebXmlAsset webXml = webArchive.findWebXmlAsset();
        webXml.addListener("org.wildfly.swarm.flyway.deployment.FlywayMigrationServletContextListener");
        FlywayFraction flywayFraction = flywayFractionInstance.get();
        if (flywayFraction.usePrimaryDataSource()) {
            String dataSourceJndi = getDatasourceNameJndi();
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JNDI_DATASOURCE, dataSourceJndi);
        } else {
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JDBC_URL, flywayFraction.jdbcUrl());
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JDBC_USER, flywayFraction.jdbcUser());
            webXml.setContextParam(FlywayMigrationServletContextListener.FLYWAY_JDBC_PASSWORD, flywayFraction.jdbcPassword());
        }
    }
}
Also used : WebXmlAsset(org.wildfly.swarm.undertow.descriptors.WebXmlAsset) FlywayFraction(org.wildfly.swarm.flyway.FlywayFraction) WARArchive(org.wildfly.swarm.undertow.WARArchive)

Example 33 with WARArchive

use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.

the class JaegerInstaller method process.

@Override
public void process() throws Exception {
    JaegerFraction fraction = jaegerFractionInstance.get();
    logger.info("Determining whether to install Jaeger integration or not.");
    logger.info("JaegerFraction instance: " + fraction);
    if (archive.getName().endsWith(".war")) {
        logger.logf(Logger.Level.INFO, "Installing the Jaeger integration for the deployment %s", archive.getName());
        WARArchive webArchive = archive.as(WARArchive.class);
        WebXmlAsset webXml = webArchive.findWebXmlAsset();
        logger.logf(Logger.Level.INFO, "Adding the listener org.wildfly.swarm.jaeger.deployment.JaegerInitializer");
        webXml.addListener("org.wildfly.swarm.jaeger.deployment.JaegerInitializer");
        setContextParamIfNotNull(webXml, JAEGER_SERVICE_NAME, fraction.getServiceName());
        setContextParamIfNotNull(webXml, JAEGER_SERVICE_NAME, fraction.getServiceName());
        setContextParamIfNotNull(webXml, JAEGER_SAMPLER_TYPE, fraction.getSamplerType());
        setContextParamIfNotNull(webXml, JAEGER_SAMPLER_PARAM, fraction.getSamplerParameter());
        setContextParamIfNotNull(webXml, JAEGER_SAMPLER_MANAGER_HOST_PORT, fraction.getSamplerManagerHost());
        setContextParamIfNotNull(webXml, JAEGER_REPORTER_LOG_SPANS, fraction.getReporterLogSpans());
        setContextParamIfNotNull(webXml, JAEGER_AGENT_HOST, fraction.getAgentHost());
        setContextParamIfNotNull(webXml, JAEGER_AGENT_PORT, fraction.getAgentPort());
        setContextParamIfNotNull(webXml, JAEGER_REPORTER_FLUSH_INTERVAL, fraction.getReporterFlushInterval());
        setContextParamIfNotNull(webXml, JAEGER_REPORTER_MAX_QUEUE_SIZE, fraction.getReporterMaxQueueSize());
        webXml.setContextParam("skipOpenTracingResolver", "true");
    }
}
Also used : WebXmlAsset(org.wildfly.swarm.undertow.descriptors.WebXmlAsset) WARArchive(org.wildfly.swarm.undertow.WARArchive) JaegerFraction(org.wildfly.swarm.jaeger.JaegerFraction)

Example 34 with WARArchive

use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.

the class SwaggerArchivePreparer method process.

@Override
public void process() {
    if (this.deploymentContext != null && this.deploymentContext.isImplicit()) {
        return;
    }
    if (archive.getName().endsWith(".war")) {
        // Create a JAX-RS deployment archive
        WARArchive deployment = archive.as(WARArchive.class);
        deployment.addModule("io.swagger");
        // Make the deployment a swagger archive
        SwaggerArchive swaggerArchive = deployment.as(SwaggerArchive.class);
        // SWARM-1667: Add the custom CDI extension to the deployment to provide a workaround solution.
        deployment.addModule("org.wildfly.swarm.swagger", "deployment");
        deployment.addAsServiceProvider(Extension.class.getName(), "org.wildfly.swarm.swagger.deployment.SwaggerExtension");
        if (this.title != null) {
            swaggerArchive.setTitle(this.title);
        }
        if (this.description != null) {
            swaggerArchive.setDescription(this.description);
        }
        if (this.packages != null && !this.packages.isEmpty()) {
            swaggerArchive.setResourcePackages(this.packages.toArray(new String[this.packages.size()]));
        }
        if (this.tosUrl != null) {
            swaggerArchive.setTermsOfServiceUrl(this.tosUrl);
        }
        if (this.license != null) {
            swaggerArchive.setLicense(this.license);
        }
        if (this.licenseUrl != null) {
            swaggerArchive.setLicenseUrl(this.licenseUrl);
        }
        if (this.version != null) {
            swaggerArchive.setVersion(this.version);
        }
        if (this.schemes != null && !this.schemes.isEmpty()) {
            swaggerArchive.setSchemes(this.schemes.toArray(new String[this.schemes.size()]));
        }
        if (this.host != null) {
            swaggerArchive.setHost(this.host);
        }
        // get the context root from the deployment and tell swagger about it
        if (this.root != null) {
            swaggerArchive.setContextRoot(this.root);
        } else {
            if (!swaggerArchive.hasContextRoot()) {
                if (deployment.getContextRoot() != null) {
                    swaggerArchive.setContextRoot(deployment.getContextRoot());
                } else {
                    swaggerArchive.setContextRoot(contextPath.get());
                }
            }
        }
        // org.wildfly.swarm package space
        if (!swaggerArchive.hasResourcePackages()) {
            String packageName = null;
            for (Map.Entry<ArchivePath, Node> entry : deployment.getContent().entrySet()) {
                final ArchivePath key = entry.getKey();
                if (key.get().endsWith(".class")) {
                    String parentPath = key.getParent().get();
                    parentPath = parentPath.replaceFirst("/", "");
                    String parentPackage = parentPath.replaceFirst(".*/classes/", "");
                    parentPackage = parentPackage.replaceAll("/", ".");
                    if (parentPackage.startsWith("org.wildfly.swarm")) {
                        SwaggerMessages.MESSAGES.ignoringPackage(parentPackage);
                    } else {
                        packageName = parentPackage;
                        break;
                    }
                }
            }
            if (packageName == null) {
                SwaggerMessages.MESSAGES.noEligiblePackages(archive.getName());
            } else {
                SwaggerMessages.MESSAGES.configureSwaggerForPackage(archive.getName(), packageName);
                swaggerArchive.setResourcePackages(packageName);
            }
        } else {
            SwaggerMessages.MESSAGES.configureSwaggerForSeveralPackages(archive.getName(), Arrays.asList(swaggerArchive.getResourcePackages()));
        }
        // Now add the swagger resources to our deployment
        deployment.addClass(io.swagger.jaxrs.listing.ApiListingResource.class);
        deployment.addClass(io.swagger.jaxrs.listing.SwaggerSerializers.class);
    }
}
Also used : Extension(javax.enterprise.inject.spi.Extension) ArchivePath(org.jboss.shrinkwrap.api.ArchivePath) Node(org.jboss.shrinkwrap.api.Node) WARArchive(org.wildfly.swarm.undertow.WARArchive) Map(java.util.Map) SwaggerArchive(org.wildfly.swarm.swagger.SwaggerArchive)

Example 35 with WARArchive

use of org.wildfly.swarm.undertow.WARArchive in project wildfly-swarm by wildfly-swarm.

the class ODataWarDeploymentProducer method odataWar.

@Produces
public Archive odataWar() throws Exception {
    // TODO: Keycloak Integration for security (see Jolokia project)
    WARArchive war = ShrinkWrap.create(WARArchive.class, "odata.war").setContextRoot(this.fraction.getContext()).setWebXML(this.getClass().getResource("/web.xml"));
    war.addModule("org.jboss.teiid.olingo");
    return war;
}
Also used : WARArchive(org.wildfly.swarm.undertow.WARArchive) Produces(javax.enterprise.inject.Produces)

Aggregations

WARArchive (org.wildfly.swarm.undertow.WARArchive)39 Deployment (org.jboss.arquillian.container.test.api.Deployment)15 Test (org.junit.Test)8 WebXmlAsset (org.wildfly.swarm.undertow.descriptors.WebXmlAsset)5 Produces (javax.enterprise.inject.Produces)4 Node (org.jboss.shrinkwrap.api.Node)4 URL (java.net.URL)3 ClassLoaderAsset (org.jboss.shrinkwrap.api.asset.ClassLoaderAsset)3 MockTracer (io.opentracing.mock.MockTracer)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 InputStreamReader (java.io.InputStreamReader)2 List (java.util.List)2 Map (java.util.Map)2 Module (org.jboss.modules.Module)2 ArchivePath (org.jboss.shrinkwrap.api.ArchivePath)2 Asset (org.jboss.shrinkwrap.api.asset.Asset)2 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)2 JBossWebAsset (org.wildfly.swarm.undertow.descriptors.JBossWebAsset)2 UndertowExternalMountsAsset (org.wildfly.swarm.undertow.internal.UndertowExternalMountsAsset)2