Java Code Examples for org.jboss.shrinkwrap.api.spec.WebArchive#delete()

The following examples show how to use org.jboss.shrinkwrap.api.spec.WebArchive#delete() . 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: ConfigPropertiesAdder.java    From piranha with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void process(WebArchive webArchive) {
    Node metaInfConfig = webArchive.get("/META-INF/microprofile-config.properties");
    
    if (metaInfConfig == null) {
        if (webArchive.get("/WEB-INF/classes/publicKey.pem") != null) {
            webArchive.addAsResource("META-INF/public-key.properties", "META-INF/microprofile-config.properties");
        } else {
            webArchive.addAsResource("META-INF/microprofile-config.properties");
        }
    } else {
        webArchive.addAsResource(metaInfConfig.getAsset(), "META-INF/microprofile-config.properties");
        webArchive.delete("/META-INF/microprofile-config.properties");
    }
    
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
}
 
Example 2
Source File: UserLoginApplicationArchiveProcessor.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleWebArchive(WebArchive war) {
    Node node = war.get(WEB_XML_PATH);
    if (node == null) {
        throw new IllegalStateException("No web.xml in .war: " + war.toString(true));
    }

    war.addClass(GetLoginUrlServlet.class);

    WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(node.getAsset().openStream());
    war.delete(WEB_XML_PATH); // delete first, so we can re-add
    webXml.servlet(UserLogin.USER_LOGIN_SERVLET_PATH + "-servlet", GetLoginUrlServlet.class.getName(), new String[]{"/" + UserLogin.USER_LOGIN_SERVLET_PATH});
    war.setWebXML(new StringAsset(webXml.exportAsString()));
}
 
Example 3
Source File: PersistenceUnitsTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> deployment()
{
    WebArchive war = TestDeployments.initDeployment();

    war.delete("WEB-INF/classes/META-INF/persistence.xml");

    return war.addPackages(true, Parent.class.getPackage())
            .addClasses(MappedOneRepository.class)
            .addAsWebInfResource("test-mapped-persistence.xml",
                    "classes/META-INF/persistence.xml")
            .addAsWebInfResource("test-default-orm.xml", "classes/META-INF/orm.xml")
            .addAsWebInfResource("test-custom-orm.xml", "classes/META-INF/custom-orm.xml");
}
 
Example 4
Source File: DisabledRepositoryTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Deployment
public static Archive<?> deployment()
{
    WebArchive archive = initDeployment()
            .addClasses(SimpleRepository.class,
                    RepositoryDeactivator.class,
                    DisabledRepository.class
            );

    archive.delete("WEB-INF/classes/META-INF/apache-deltaspike.properties");
    archive.addAsWebInfResource("disabled/META-INF/apache-deltaspike.properties",
            "classes/META-INF/apache-deltaspike.properties");
    return archive;
}