org.wildfly.swarm.undertow.WARArchive Java Examples
The following examples show how to use
org.wildfly.swarm.undertow.WARArchive.
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: FlywayMigrationArchivePreparer.java From thorntail with Apache License 2.0 | 6 votes |
@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()); } } }
Example #2
Source File: TopologyWebAppConfiguration.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
@Override public List<Archive> getImplicitDeployments(TopologyWebAppFraction fraction) throws Exception { String context = System.getProperty(TopologyProperties.CONTEXT_PATH); if (context == null) context = DEFAULT_CONTEXT; List<Archive> list = new ArrayList<>(); WARArchive war = ShrinkWrap.create(WARArchive.class, "topology-webapp.war"); war.addAsWebInfResource(new StringAsset(getWebXml(fraction)), "web.xml"); war.addClass(TopologySSEServlet.class); war.addModule("swarm.application"); war.addModule("org.wildfly.swarm.topology"); war.addAsWebResource(new ClassLoaderAsset("topology.js", this.getClass().getClassLoader()), "topology.js"); war.setContextRoot(context); war.as(TopologyArchive.class); list.add(war); return list; }
Example #3
Source File: RestClientArchiveProcessor.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void process(Archive<?> appArchive, TestClass testClass) { if (!(appArchive instanceof WebArchive)) { return; } log.info("Preparing archive: " + appArchive); WARArchive war = appArchive.as(WARArchive.class); PomEquippedResolveStage pom = Maven.resolver().loadPomFromFile("pom.xml"); // Wiremock classes that need to be present File[] wiremockDeps = pom .resolve("com.github.tomakehurst:wiremock") .withTransitivity() .asFile(); war.addAsLibraries(wiremockDeps); // TCK Classes that need to present war.addPackages(true, "org.eclipse.microprofile.rest.client.tck.ext"); log.fine("Augmented war: \n" + war.toString(true)); }
Example #4
Source File: SwaggerWebAppConfiguration.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
@Override public List<Archive> getImplicitDeployments(SwaggerWebAppFraction fraction) throws Exception { List<Archive> list = new ArrayList<>(); try { // Get the swagger-ui bits as an Archive WARArchive war = Swarm.artifact("org.wildfly.swarm:swagger-webapp-ui:war:" + Container.VERSION, "swagger-webapp-ui.war") .as(WARArchive.class) .setContextRoot(fraction.getContext()); // If any user content has been provided, merge that with the swagger-ui bits Archive<?> userContent = fraction.getWebContent(); if (userContent != null) { war.merge(userContent); } //war.as(ZipExporter.class).exportTo(new File("swagger-webapp-ui.war"), true); list.add(war); } catch (Exception e) { e.printStackTrace(); } return list; }
Example #5
Source File: SkipPatternTest.java From thorntail with Apache License 2.0 | 6 votes |
@Deployment public static Archive createDeployment() throws Exception { WARArchive deployment = ShrinkWrap.create(WARArchive.class); // on real world deployments, these parts would come from a dependency of the target application deployment.addClass(MockTracerResolver.class); deployment.addPackage(MockTracer.class.getPackage()); deployment.addAsServiceProvider(TracerResolver.class, MockTracerResolver.class); // this is a simple servlet, that we can hit with our tests deployment.addClass(SimpleServlet.class); deployment.addClass(HealthServlet.class); deployment.addAsResource("project-skip-pattern.yml", "/project-defaults.yml"); return deployment; }
Example #6
Source File: TopologyWebAppDeploymentProducer.java From thorntail with Apache License 2.0 | 6 votes |
@Produces @Dependent() Archive deployment() { String context = TopologyWebAppFraction.DEFAULT_CONTEXT; if (this.contextPath != null) { context = this.contextPath; } if (fraction.exposeTopologyEndpoint()) { WARArchive war = ShrinkWrap.create(WARArchive.class, "topology-webapp.war"); war.addAsWebInfResource(new StringAsset(getWebXml(fraction)), "web.xml"); war.addClass(TopologySSEServlet.class); war.addModule("thorntail.application"); war.addModule("org.wildfly.swarm.topology"); war.addAsWebResource(new ClassLoaderAsset("topology.js", this.getClass().getClassLoader()), "topology.js"); war.setContextRoot(context); war.as(TopologyArchive.class); return war; } return null; }
Example #7
Source File: OpenApiDeploymentProcessor.java From thorntail with Apache License 2.0 | 6 votes |
/** * Process the deployment in order to produce an OpenAPI document. * * @see org.wildfly.swarm.spi.api.DeploymentProcessor#process() */ @Override public void process() throws Exception { // if the deployment is Implicit, we don't want to process it if (deploymentContext != null && deploymentContext.isImplicit()) { return; } try { // First register OpenApiServletContextListener which triggers the final init WARArchive warArchive = archive.as(WARArchive.class); warArchive.findWebXmlAsset().addListener(LISTENER_CLASS); } catch (Exception e) { throw new RuntimeException("Failed to register OpenAPI listener", e); } OpenApiStaticFile staticFile = ArchiveUtil.archiveToStaticFile(archive); // Set models from annotations and static file OpenApiDocument openApiDocument = OpenApiDocument.INSTANCE; openApiDocument.config(config); openApiDocument.modelFromStaticFile(OpenApiProcessor.modelFromStaticFile(staticFile)); openApiDocument.modelFromAnnotations(OpenApiProcessor.modelFromAnnotations(config, index)); }
Example #8
Source File: JolokiaWarDeploymentProducer.java From thorntail with Apache License 2.0 | 6 votes |
@Produces public Archive jolokiaWar() throws Exception { if (this.context == null) { this.context = this.fraction.context(); } Archive deployment = this.lookup.artifact(DEPLOYMENT_GAV, DEPLOYMENT_NAME); deployment.as(WARArchive.class).setContextRoot(this.context); Consumer<Archive> preparer = new ConfigurationValueAccessPreparer(this.jolokiaAccessXML); if (this.fraction.jolokiaWarPreparer() != null) { preparer = preparer.andThen(this.fraction.jolokiaWarPreparer()); } preparer.accept(deployment); return deployment; }
Example #9
Source File: SpringConfiguration.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override public void prepareArchive(Archive<?> archive) { if (JARArchive.class.isAssignableFrom(archive.getClass())) { // Prevent sun.jdk module from being added to JAR, otherwise wildfly-swarm:run // will fail as Spring jars are on system classpath archive.as(JARArchive.class).excludeModule("sun.jdk"); } else if (WARArchive.class.isAssignableFrom(archive.getClass())) { // Prevent sun.jdk module from being added to WAR, otherwise wildfly-swarm:run // will fail as Spring jars are on system classpath archive.as(WARArchive.class).excludeModule("sun.jdk"); } }
Example #10
Source File: HystrixArchivePreparer.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void process() { // Add Hystrix Metrix Stream Servlet archive.as(WARArchive.class) .addServlet("HystrixMetricsStreamServlet", "com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet") .withDisplayName("HystrixMetricsStreamServlet") .withUrlPattern(this.fraction.streamPath()); }
Example #11
Source File: StaticContentDeploymentTest.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Test public void testStaticContentWithContext() throws Exception { Container container = newContainer(); container.start(); try { WARArchive deployment = ShrinkWrap.create(WARArchive.class); deployment.setContextRoot("/static"); deployment.staticContent(); container.deploy(deployment); assertBasicStaticContentWorks("static"); assertFileChangesReflected("static"); } finally { container.stop(); } }
Example #12
Source File: JolokiaConfiguration.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
public JolokiaConfiguration() { super(JolokiaFraction.class); deployment("org.jolokia:jolokia-war:war:*") .as("jolokia.war") .configure((fraction, archive) -> { archive.as(WARArchive.class).setContextRoot(fraction.context()); }); }
Example #13
Source File: DefaultWarDeploymentFactory.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
public static WARArchive archiveFromCurrentApp() throws Exception { final WARArchive archive = ShrinkWrap.create(WARArchive.class, determineName()); final DefaultDeploymentFactory factory = new DefaultWarDeploymentFactory(); factory.setup(archive); archive.addModule("org.wildfly.swarm.undertow", "runtime"); return archive; }
Example #14
Source File: OpenTracingTracerInstaller.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void process() throws Exception { if (archive.getName().endsWith(".war")) { WARArchive webArchive = archive.as(WARArchive.class); WebXmlAsset webXml = webArchive.findWebXmlAsset(); webXml.addListener(CONTEXT_LISTENER); } }
Example #15
Source File: StaticContentWarSubdirTest.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Deployment public static Archive createDeployment() throws Exception { WARArchive deployment = ShrinkWrap.create(WARArchive.class); deployment.staticContent("foo"); // Make sure we're testing from contents inside the jar only deployment.delete("WEB-INF/undertow-external-mounts.conf"); return deployment; }
Example #16
Source File: StaticContentDeploymentTest.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Test public void testStaticContentWithBase() throws Exception { Container container = newContainer(); container.start(); try { WARArchive deployment = ShrinkWrap.create(WARArchive.class); deployment.staticContent("foo"); container.deploy(deployment); assertContains("", "This is foo/index.html."); assertContains("index.html", "This is foo/index.html."); } finally { container.stop(); } }
Example #17
Source File: AbstractJolokiaAccessPreparer.java From thorntail with Apache License 2.0 | 5 votes |
public void accept(Archive archive) { Node node = archive.get("WEB-INF/classes/jolokia-access.xml"); if (node == null) { Asset asset = getJolokiaAccessXmlAsset(); if (asset != null) { archive.as(WARArchive.class).add(asset, "WEB-INF/classes/jolokia-access.xml"); } } }
Example #18
Source File: ManagementConsoleDeploymentProducer.java From thorntail with Apache License 2.0 | 5 votes |
@Produces public Archive managementConsoleWar() throws Exception { // Load the management-ui webjars. WARArchive war = ShrinkWrap.create(WARArchive.class, "management-console-ui.war"); Module module = Module.getBootModuleLoader().loadModule("org.jboss.as.console"); Iterator<Resource> resources = module.globResources("*"); while (resources.hasNext()) { Resource each = resources.next(); war.add(new UrlAsset(each.getURL()), each.getName()); } war.setContextRoot(this.fraction.contextRoot()); return war; }
Example #19
Source File: JaegerInstaller.java From thorntail with Apache License 2.0 | 5 votes |
@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_ENDPOINT, fraction.getRemoteReporterHttpEndpoint()); setContextParamIfNotNull(webXml, JAEGER_REPORTER_FLUSH_INTERVAL, fraction.getReporterFlushInterval()); setContextParamIfNotNull(webXml, JAEGER_REPORTER_MAX_QUEUE_SIZE, fraction.getReporterMaxQueueSize()); setContextParamIfNotNull(webXml, JAEGER_USER, fraction.getUser()); setContextParamIfNotNull(webXml, JAEGER_PASSWORD, fraction.getPassword()); webXml.setContextParam("skipOpenTracingResolver", "true"); if (fraction.isB3HeaderPropagationEnabled()) { webXml.setContextParam("enableB3HeaderPropagation", "true"); } } }
Example #20
Source File: ContextPathArchivePreparerTest.java From thorntail with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testExternalMount() throws Exception { WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp(); assertThat(archive.getContextRoot()).isNull(); URL url = getClass().getClassLoader().getResource("mounts.yml"); ConfigViewFactory factory = new ConfigViewFactory(new Properties()); factory.load("test", url); factory.withProfile("test"); ConfigViewImpl view = factory.get(true); List<String> mounts = view.resolve("thorntail.context.mounts").as(List.class).getValue(); ContextPathArchivePreparer preparer = new ContextPathArchivePreparer(archive); preparer.mounts = mounts; preparer.process(); Node externalMount = archive.get(WARArchive.EXTERNAL_MOUNT_PATH); assertThat(externalMount).isNotNull(); assertThat(externalMount.getAsset()).isInstanceOf(UndertowExternalMountsAsset.class); UndertowExternalMountsAsset externalMountAsset = (UndertowExternalMountsAsset) externalMount.getAsset(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(externalMountAsset.openStream()));) { assertThat(reader.readLine()).endsWith("external1"); assertThat(reader.readLine()).endsWith("external2"); } }
Example #21
Source File: ContextPathArchivePreparerTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test public void testContextPathProperty() throws Exception { WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp(); assertThat(archive.getContextRoot()).isNull(); ContextPathArchivePreparer preparer = new ContextPathArchivePreparer(archive); preparer.contextPath.set("/another-root"); preparer.process(); assertThat(archive.getContextRoot()).isNotNull(); assertThat(archive.getContextRoot()).isEqualTo("/another-root"); }
Example #22
Source File: ContextPathArchivePreparerTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test public void testDefaultContextRootWontOverride() throws Exception { WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp(); assertThat(archive.getContextRoot()).isNull(); archive.setContextRoot("myRoot"); assertThat(archive.getContextRoot()).isNotNull(); assertThat(archive.getContextRoot()).isEqualTo("myRoot"); new ContextPathArchivePreparer(archive).process(); assertThat(archive.getContextRoot()).isNotNull(); assertThat(archive.getContextRoot()).isEqualTo("myRoot"); }
Example #23
Source File: ContextPathArchivePreparerTest.java From thorntail with Apache License 2.0 | 5 votes |
@Test public void testDefaultContextRoot() throws Exception { WARArchive archive = DefaultWarDeploymentFactory.archiveFromCurrentApp(); assertThat(archive.getContextRoot()).isNull(); ContextPathArchivePreparer processor = new ContextPathArchivePreparer(archive); processor.process(); assertThat(archive.getContextRoot()).isNotNull(); assertThat(archive.getContextRoot()).isEqualTo("/"); }
Example #24
Source File: ContextPathArchivePreparer.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void process() { WARArchive warArchive = archive.as(WARArchive.class); if (warArchive.getContextRoot() == null) { warArchive.setContextRoot(contextPath.get()); } UndertowExternalMountsAsset ut = null; if (mounts != null) { for (String mountPath : mounts) { Path staticPath = Paths.get(mountPath); if (!staticPath.isAbsolute()) { staticPath = Paths.get(System.getProperty("user.dir"), staticPath.toString()).normalize(); } if (ut == null) { ut = new UndertowExternalMountsAsset(); } ut.externalMount(staticPath.toString()); } } if (ut != null) { warArchive.add(ut, WARArchive.EXTERNAL_MOUNT_PATH); } }
Example #25
Source File: DefaultWarDeploymentFactory.java From thorntail with Apache License 2.0 | 5 votes |
public static WARArchive archiveFromCurrentApp() throws Exception { final WARArchive archive = ShrinkWrap.create(WARArchive.class, determineName()); final DefaultDeploymentFactory factory = new DefaultWarDeploymentFactory(); factory.setup(archive); //archive.addModule("org.wildfly.swarm.undertow", "runtime"); archive.add(EmptyAsset.INSTANCE, MARKER_PATH); return archive; }
Example #26
Source File: TaskanaProducersTest.java From taskana with Apache License 2.0 | 5 votes |
@Deployment(testable = false) public static Archive<?> createDeployment() throws Exception { WARArchive deployment = ShrinkWrap.create(WARArchive.class); deployment.addPackage("pro.taskana"); deployment.addClass(TaskanaProducers.class); deployment.addAllDependencies(); deployment.addDependency("org.mybatis:mybatis:3.4.2"); deployment.addDependency("org.mybatis:mybatis-cdi:1.0.0"); deployment.addDependency("pro.taskana:taskana-core"); deployment.addAsResource("META-INF/beans.xml"); deployment.addAsResource("taskana.properties"); deployment.addAsResource("project-defaults.yml"); return deployment; }
Example #27
Source File: ArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@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; }
Example #28
Source File: JAXPOverrideTest.java From thorntail with Apache License 2.0 | 5 votes |
@Deployment public static Archive createDeployment() throws Exception { WARArchive deployment = ShrinkWrap.create(WARArchive.class, "services.war"); deployment.addAsLibraries(Maven.resolver().resolve("saxon:saxon:8.7").withTransitivity().asFile()); deployment.addClass(ServicesServlet.class); deployment.addClass(TransformerServlet.class); return deployment; }
Example #29
Source File: SampleTest.java From thorntail with Apache License 2.0 | 5 votes |
@Deployment public static Archive createDeployment() throws Exception { WARArchive archive = ShrinkWrap.create(WARArchive.class, "SampleTest.war"); archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); archive.addPackage("example"); archive.addAllDependencies(); return archive; }
Example #30
Source File: ContentTypesTest.java From thorntail with Apache License 2.0 | 5 votes |
protected static WARArchive initDeployment() { WARArchive deployment = ShrinkWrap.create(WARArchive.class); deployment.addClass(ContentTypesResource.class); deployment.addClass(TestApplication.class); deployment.addAsManifestResource(new ClassLoaderAsset("keys/public-key.pem"), "/MP-JWT-SIGNER"); return deployment; }