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

The following examples show how to use org.wildfly.swarm.undertow.WARArchive#addAsWebInfResource() . 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: Main.java    From hola with Apache License 2.0 5 votes vote down vote up
/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    // Instantiate the container
    Swarm swarm = new Swarm(args);

    // Create one or more deployments
    WARArchive deployment = ShrinkWrap.create(WARArchive.class);

    // Add resource to deployment
    deployment.addPackage(Main.class.getPackage());
    deployment.addAllDependencies();

    // Add Web resources
    deployment.addAsWebResource(
        new ClassLoaderAsset("index.html", Main.class.getClassLoader()), "index.html");
    deployment.addAsWebInfResource(
        new ClassLoaderAsset("WEB-INF/web.xml", Main.class.getClassLoader()), "web.xml");
    deployment.addAsWebInfResource(
        new ClassLoaderAsset("WEB-INF/beans.xml", Main.class.getClassLoader()), "beans.xml");

    // If There's a KEYCLOAK_SERVER_URL env var, then read the file
    if (System.getenv("KEYCLOAK_AUTH_SERVER_URL") != null) {
        deployment.addAsWebInfResource(
            new ClassLoaderAsset("keycloak.json", Main.class.getClassLoader()), "keycloak.json");
    }

    swarm.start().deploy(deployment);

}
 
Example 4
Source File: EESecurityTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive createDeployment() throws Exception {
    WARArchive deployment = ShrinkWrap.create(WARArchive.class);
    deployment.addClass(MyApplication.class);
    deployment.addClass(MyResource.class); 
    deployment.addClass(SimpleAuthenticationMechanism.class);
    deployment.addClass(SimpleIdentityStore.class);
    deployment.addAsWebInfResource("jboss-web.xml");
    return deployment;
}
 
Example 5
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 6
Source File: JaegerAndMicroprofileOpenTracingTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive createDeployment() {
  WARArchive deployment = ShrinkWrap.create(WARArchive.class);
  deployment.addClass(JaxrsResource.class);
  deployment.addClass(JaxrsApplication.class);
  deployment.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
  return deployment;
}
 
Example 7
Source File: EESecurityTest.java    From thorntail with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive createDeployment() throws Exception {
    WARArchive deployment = ShrinkWrap.create(WARArchive.class);
    deployment.addClass(EESecurityServlet.class);
    deployment.addClass(SimpleAuthenticationMechanism.class);
    deployment.addClass(SimpleIdentityStore.class);
    deployment.addAsWebInfResource("jboss-web.xml");
    return deployment;
}
 
Example 8
Source File: SampleTest.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.addPackage("example");
    archive.addAllDependencies();
    return archive;
}
 
Example 9
Source File: SecuredTest.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Test
public void testExistingWebXml() {
    WARArchive archive = ShrinkWrap.create( WARArchive.class );

    ClassLoaderAsset asset = new ClassLoaderAsset("test-web.xml");
    archive.addAsWebInfResource( asset, "web.xml" );

    archive.as(Secured.class)
            .protect( "/cheddar" );

    Node webXml = archive.get("WEB-INF/web.xml");

    Asset newAsset = webXml.getAsset();

    InputStream in = newAsset.openStream();
    BufferedReader reader = new BufferedReader( new InputStreamReader( in ) );

    List<String> lines = reader.lines().map(String::trim).collect(Collectors.toList());

    assertThat( lines ).contains( "<servlet-name>comingsoon</servlet-name>" );
    assertThat( lines ).contains( "<url-pattern>/cheddar</url-pattern>" );
}