本文整理汇总了Java中org.jboss.shrinkwrap.api.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于org.jboss.shrinkwrap.api包,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
public static void main(String... args) throws Exception {
swarm = new Swarm(args);
swarm.start();
Archive<?> deployment = swarm.createDefaultDeployment();
if (deployment == null) {
throw new Error("Couldn't create default deployment");
}
Node persistenceXml = deployment.get("WEB-INF/classes/META-INF/persistence.xml");
if (persistenceXml == null) {
throw new Error("persistence.xml is not found");
}
if (persistenceXml.getAsset() == null) {
throw new Error("persistence.xml is not found");
}
swarm.deploy(deployment);
}
示例2: process
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
@Override
public void process(Archive<?> appArchive, TestClass testClass) {
if (!(appArchive instanceof WebArchive)) {
return;
}
log.info("Preparing archive: " + appArchive);
// Only augment archives with a publicKey indicating a MP-JWT test
WebArchive war = WebArchive.class.cast(appArchive);
Node publicKeyNode = war.get("/WEB-INF/classes/publicKey.pem");
if (publicKeyNode == null) {
return;
}
// This allows for test specific web.xml files. Generally this should not be needed.
String warName = war.getName();
String webXmlName = "/WEB-INF/" + warName + ".xml";
URL webXml = WFSwarmWarArchiveProcessor.class.getResource(webXmlName);
if (webXml != null) {
war.setWebXML(webXml);
}
war.addAsResource("project-defaults.yml", "/project-defaults.yml")
.addAsWebInfResource("jwt-roles.properties", "classes/jwt-roles.properties")
.addAsManifestResource(publicKeyNode.getAsset(), "/MP-JWT-SIGNER");
log.fine("Augmented war: \n" + war.toString(true));
}
示例3: loadOrCreateConfigurationAsset
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
private void loadOrCreateConfigurationAsset() throws IOException {
Node node = getArchive().get(SWAGGER_CONFIGURATION_PATH);
if (node == null && getArchive().getName().endsWith(".war")) {
node = getArchive().get("WEB-INF/classes/" + SWAGGER_CONFIGURATION_PATH);
}
if (node != null) {
Asset asset = node.getAsset();
if (asset instanceof SwaggerConfigurationAsset) {
this.configurationAsset = (SwaggerConfigurationAsset) asset;
} else {
this.configurationAsset = new SwaggerConfigurationAsset(asset.openStream());
getArchive().add(this.configurationAsset, node.getPath());
}
} else {
this.configurationAsset = new SwaggerConfigurationAsset();
if (getArchive().getName().endsWith(".war")) {
getArchive().add(this.configurationAsset, "WEB-INF/classes/" + SWAGGER_CONFIGURATION_PATH);
} else {
getArchive().add(this.configurationAsset, SWAGGER_CONFIGURATION_PATH);
}
}
}
示例4: findJbossWebAsset
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
/**
* 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;
}
示例5: getKeycloakJson
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
private InputStream getKeycloakJson() {
InputStream keycloakJson = Thread.currentThread().getContextClassLoader().getResourceAsStream("keycloak.json");
if (keycloakJson == null) {
String appArtifact = System.getProperty(BootstrapProperties.APP_ARTIFACT);
if (appArtifact != null) {
try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
Archive tmpArchive = ShrinkWrap.create(JARArchive.class);
tmpArchive.as(ZipImporter.class).importFrom(in);
Node jsonNode = tmpArchive.get("keycloak.json");
if (jsonNode == null) {
jsonNode = tmpArchive.get("WEB-INF/keycloak.json");
}
if (jsonNode != null && jsonNode.getAsset() != null) {
keycloakJson = jsonNode.getAsset().openStream();
}
} catch (IOException e) {
// ignore
}
}
}
return keycloakJson;
}
示例6: testJolokiaAccessViaUrlOnFraction
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
@Test
public void testJolokiaAccessViaUrlOnFraction() throws Exception {
URL resource = getClass().getClassLoader().getResource("my-jolokia-access.xml");
JolokiaWarDeploymentProducer producer = new JolokiaWarDeploymentProducer();
producer.fraction = new JolokiaFraction()
.prepareJolokiaWar(JolokiaFraction.jolokiaAccessXml(resource));
producer.lookup = new MockArtifactLookup();
Archive war = producer.jolokiaWar();
Node xml = war.get("WEB-INF/classes/jolokia-access.xml");
assertThat(xml).isNotNull();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(xml.getAsset().openStream()))) {
List<String> lines = reader.lines().collect(Collectors.toList());
assertThat(lines).isNotEmpty();
assertThat(lines.get(0)).contains("This is my-jolokia-access.xml");
}
}
示例7: getDescriptorAsset
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
/** Retrieve the underlying {@code jboss-deployment-structure.xml} descriptor asset.
*
* <p>This method will effectively round-trip an existing {@code .xml} file into
* the appropriate descriptor object tree.</p>
*
* @return The existing descriptor asset, if present, else a newly-created one.
*/
default JBossDeploymentStructureAsset getDescriptorAsset() {
String path = PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH;
Node jbossDS = this.get(PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
if (jbossDS == null) {
jbossDS = this.get(SECONDARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
if (jbossDS != null) {
path = SECONDARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH;
}
}
Asset asset;
if (jbossDS == null) {
asset = new JBossDeploymentStructureAsset();
} else {
asset = jbossDS.getAsset();
if (!(asset instanceof JBossDeploymentStructureAsset)) {
asset = new JBossDeploymentStructureAsset(asset.openStream());
}
}
this.add(asset, path);
return (JBossDeploymentStructureAsset) asset;
}
示例8: index
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
@Produces
@DeploymentScoped
@Default
IndexView index() {
Indexer indexer = new Indexer();
Map<ArchivePath, Node> c = context.getCurrentArchive().getContent();
try {
for (Map.Entry<ArchivePath, Node> each : c.entrySet()) {
if (each.getKey().get().endsWith(CLASS_SUFFIX)) {
indexer.index(each.getValue().getAsset().openStream());
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return indexer.complete();
}
示例9: getApplicationXml
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
/**
* This method reads the file /META/INF/application.xml from the enterprise
* archive provided.
*
* @param enterpriseArchive
* is the {@link EnterpriseArchive} to be searched for the
* application.xml.
* @return The application.xml is returned as {@link String}.
* @throws FileNotFoundException
* is thrown in case of the application.xml was not found in
* directory /META-INF.
* @throws IOException
* is thrown if the application.xml could not be read.
*/
public static String getApplicationXml(EnterpriseArchive enterpriseArchive)
throws FileNotFoundException, IOException {
Node node = enterpriseArchive.get(APPLICATION_XML_PATH);
if (node == null) {
throw new FileNotFoundException("File '" + APPLICATION_XML_PATH
+ "' was not found in enterprise archive '"
+ enterpriseArchive.getName());
}
InputStream applicationXmlStream = node.getAsset().openStream();
if (applicationXmlStream == null) {
throw new IOException("File '" + APPLICATION_XML_PATH
+ "' seems to be a directory in enterprise archive '"
+ enterpriseArchive.getName());
}
try {
String resultString = IOUtils.toString(applicationXmlStream);
return resultString;
} finally {
applicationXmlStream.close();
}
}
示例10: getOrCreateManifest
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
private static Manifest getOrCreateManifest(Archive<?> archive) {
Manifest manifest;
try {
Node node = archive.get(JarFile.MANIFEST_NAME);
if (node == null) {
manifest = new Manifest();
Attributes attributes = manifest.getMainAttributes();
attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
} else {
manifest = new Manifest(node.getAsset().openStream());
}
return manifest;
} catch (Exception ex) {
throw new IllegalStateException("Cannot obtain manifest", ex);
}
}
示例11: findJbossWebAsset
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
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;
}
示例12: nodeIsInArtifactList
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
protected boolean nodeIsInArtifactList(final Node node,
final Collection<ArtifactSpec> artifactList,
final boolean exact) {
final List<Properties> poms = extractPomProperties(node);
final String jarName = node.getPath().get().substring(WEB_INF_LIB.length());
boolean found = false;
final Iterator<ArtifactSpec> specs = artifactList.iterator();
while (!found && specs.hasNext()) {
final ArtifactSpec spec = specs.next();
if (!poms.isEmpty()) {
found = matchProperty(poms, "groupId", spec.groupId())
&& matchProperty(poms, "artifactId", spec.artifactId())
&& (!exact || matchProperty(poms, "version", spec.version()));
} else {
// no pom, try to match by file name
if (exact) {
found = jarName.equals(String.format("%s-%s.%s", spec.artifactId(), spec.version(), spec.type()));
} else {
found = jarName.matches("^" + spec.artifactId() + "-\\d.*\\." + spec.type());
}
}
}
return found;
}
示例13: populateUberJarMavenRepository
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
@Test
public void populateUberJarMavenRepository() throws Exception {
manager.addDependency(BOOTSTRAP_JAR);
manager.addDependency(BOOTSTRAP_CONF);
manager.addDependency(MODULES_EMPTY_A);
manager.addDependency(MODULES_A);
manager.analyzeDependencies(false);
Archive archive = ShrinkWrap.create(JavaArchive.class);
manager.populateUberJarMavenRepository(archive);
Map<ArchivePath, Node> content = archive.getContent();
List<String> jars = content.keySet().stream().map(ArchivePath::get).filter((e) -> e.endsWith(".jar")).collect(Collectors.toList());
assertThat(jars).hasSize(5);
assertThat(jars).contains("/m2repo/" + MODULES_EMPTY_A.repoPath(true));
assertThat(jars).contains("/m2repo/" + BOOTSTRAP_CONF.repoPath(true));
assertThat(jars).contains("/m2repo/" + MODULES_A.repoPath(true));
assertThat(jars).contains("/m2repo/" + CXF.repoPath(true));
assertThat(jars).contains("/m2repo/" + WS_INTEGRATION.repoPath(true));
}
示例14: getDescriptorAsset
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
default JBossDeploymentStructureAsset getDescriptorAsset() {
String path = PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH;
Node jbossDS = this.get(PRIMARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
if (jbossDS == null) {
jbossDS = this.get(SECONDARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH);
if (jbossDS != null) {
path = SECONDARY_JBOSS_DEPLOYMENT_DESCRIPTOR_PATH;
}
}
Asset asset;
if (jbossDS == null) {
asset = new JBossDeploymentStructureAsset();
} else {
asset = jbossDS.getAsset();
if (!(asset instanceof JBossDeploymentStructureAsset)) {
asset = new JBossDeploymentStructureAsset(asset.openStream());
}
}
this.add(asset, path);
return (JBossDeploymentStructureAsset) asset;
}
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:25,代码来源:JBossDeploymentStructureContainer.java
示例15: getOrCreateManifest
import org.jboss.shrinkwrap.api.Node; //导入依赖的package包/类
private Manifest getOrCreateManifest(Archive<?> archive) {
Manifest manifest;
try {
Node node = archive.get(JarFile.MANIFEST_NAME);
if (node == null) {
manifest = new Manifest();
Attributes attributes = manifest.getMainAttributes();
attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
} else {
manifest = new Manifest(node.getAsset().openStream());
}
return manifest;
} catch (Exception ex) {
throw new IllegalStateException("Cannot obtain manifest", ex);
}
}