Java Code Examples for org.wildfly.swarm.undertow.WARArchive#setContextRoot()

The following examples show how to use org.wildfly.swarm.undertow.WARArchive#setContextRoot() . 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: TopologyWebAppDeploymentProducer.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: TopologyWebAppConfiguration.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@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: StaticContentContextRootDeploymentTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static Archive getSecond() throws Exception {
    WARArchive deployment = ShrinkWrap.create(WARArchive.class);
    deployment.setContextRoot("/static");
    deployment.staticContent();
    return deployment;
}
 
Example 4
Source File: SwaggerConfiguredArquillianWebAppTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive createDeployment() throws Exception {
    WARArchive archive = ShrinkWrap.create(WARArchive.class, "SampleTest.war");
    archive.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    archive.addClass(Resource.class);
    archive.addClass(CustomApplication.class);
    archive.addAllDependencies();
    archive.setContextRoot("/sample");
    return archive;
}
 
Example 5
Source File: ContextPathArchivePreparer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: ContextPathArchivePreparerTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@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 7
Source File: ManagementConsoleDeploymentProducer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: StaticContentDeploymentTest.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 5 votes vote down vote up
@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();
    }
}