Search in sources :

Example 1 with NamedAsset

use of org.jboss.shrinkwrap.api.asset.NamedAsset in project wildfly-swarm by wildfly-swarm.

the class WebXmlContainer method findWebXmlAsset.

/**
 * Locate or create a {@code web.xml} asset.
 *
 * @return The existing or new {@code web.xml}.
 */
default WebXmlAsset findWebXmlAsset() {
    final Node webXml = this.get(WebXmlAsset.NAME);
    NamedAsset asset;
    if (webXml == null) {
        asset = new WebXmlAsset();
        this.add(asset);
    } else {
        Asset tempAsset = webXml.getAsset();
        if (!(tempAsset instanceof WebXmlAsset)) {
            asset = new WebXmlAsset(tempAsset.openStream());
            this.add(asset);
        } else {
            asset = (NamedAsset) tempAsset;
        }
    }
    return (WebXmlAsset) asset;
}
Also used : NamedAsset(org.jboss.shrinkwrap.api.asset.NamedAsset) Node(org.jboss.shrinkwrap.api.Node) ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) NamedAsset(org.jboss.shrinkwrap.api.asset.NamedAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset)

Aggregations

Node (org.jboss.shrinkwrap.api.Node)1 Asset (org.jboss.shrinkwrap.api.asset.Asset)1 ByteArrayAsset (org.jboss.shrinkwrap.api.asset.ByteArrayAsset)1 NamedAsset (org.jboss.shrinkwrap.api.asset.NamedAsset)1