use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class JBossWebContainer method findJbossWebAsset.
/**
* Locate and load, or create a {@code jboss-web.xml} asset for this archive.
*
* @return The existing or new {@code jboss-web.xml} asset.
*/
default JBossWebAsset findJbossWebAsset() {
final Node jbossWeb = this.get(JBOSS_WEB_PATH);
Asset asset;
if (jbossWeb == null) {
asset = new JBossWebAsset();
this.add(asset, JBOSS_WEB_PATH);
} else {
asset = jbossWeb.getAsset();
if (!(asset instanceof JBossWebAsset)) {
asset = new JBossWebAsset(asset.openStream());
this.add(asset, JBOSS_WEB_PATH);
}
}
return (JBossWebAsset) asset;
}
use of org.jboss.shrinkwrap.api.Node 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;
}
use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class StaticContentContainer method staticContent.
/**
* Enable static content to be served from a given base in the classpath.
*
* @param base The path prefix to use for static content.
* @return
*/
@SuppressWarnings("unchecked")
default T staticContent(String base) {
try {
// Add all the static content from the current app to the archive
Archive allResources = DefaultWarDeploymentFactory.archiveFromCurrentApp();
// Here we define static as basically anything that's not a
// Java class file or under WEB-INF or META-INF
mergeIgnoringDuplicates(allResources, base, Filters.exclude(".*\\.class$"));
} catch (Exception ex) {
log.log(Level.WARNING, "Error setting up static resources", ex);
}
Node node = get(EXTERNAL_MOUNT_PATH);
UndertowExternalMountsAsset asset;
if (node == null) {
asset = new UndertowExternalMountsAsset();
add(asset, EXTERNAL_MOUNT_PATH);
} else {
Asset tempAsset = node.getAsset();
if (!(tempAsset instanceof UndertowExternalMountsAsset)) {
asset = new UndertowExternalMountsAsset(tempAsset.openStream());
add(asset, EXTERNAL_MOUNT_PATH);
} else {
asset = (UndertowExternalMountsAsset) node.getAsset();
}
}
// Add external mounts for static content so changes are picked up
// immediately during development
Path webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "webapp");
if (base != null) {
webResources = webResources.resolve(base);
}
if (Files.exists(webResources)) {
asset.externalMount(webResources.toString());
}
webResources = Paths.get(System.getProperty("user.dir"), "src", "main", "resources");
if (base != null) {
webResources = webResources.resolve(base);
}
if (Files.exists(webResources)) {
asset.externalMount(webResources.toString());
}
return (T) this;
}
use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class AdvertisingMetadataProcessorTest method createIndex.
Index createIndex(Archive<?> archive) throws IOException {
Indexer indexer = new Indexer();
Map<ArchivePath, Node> c = archive.getContent();
for (Map.Entry<ArchivePath, Node> each : c.entrySet()) {
if (each.getKey().get().endsWith(".class")) {
indexer.index(each.getValue().getAsset().openStream());
}
}
return indexer.complete();
}
use of org.jboss.shrinkwrap.api.Node in project wildfly-swarm by wildfly-swarm.
the class ServiceActivatorArchiveImpl method prepareAsset.
protected void prepareAsset() {
Node node = getArchive().get(path());
if (node != null) {
Asset maybeCorrect = node.getAsset();
if (maybeCorrect instanceof ServiceActivatorAsset) {
setAsset((ServiceActivatorAsset) maybeCorrect);
} else {
ServiceActivatorAsset read = new ServiceActivatorAsset(maybeCorrect.openStream());
setAsset(read);
}
} else {
setAsset(new ServiceActivatorAsset());
}
}
Aggregations