本文整理了Java中org.jboss.shrinkwrap.api.asset.ArchiveAsset.getArchive()
方法的一些代码示例,展示了ArchiveAsset.getArchive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArchiveAsset.getArchive()
方法的具体详情如下:
包路径:org.jboss.shrinkwrap.api.asset.ArchiveAsset
类名称:ArchiveAsset
方法名:getArchive
[英]Returns the archive this asset represents
[中]返回此资产所代表的存档
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-api
/**
* {@inheritDoc}
*
* @see org.jboss.shrinkwrap.api.asset.Asset#openStream()
*/
@Override
public InputStream openStream() {
// Export via the specified exporter
return this.getArchive().as(this.exporter).exportAsInputStream();
}
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base
/**
* Processes a nested archive by delegating to the ExplodedArchiveExporter
*
* @param parentDirectory
* @param nestedArchiveAsset
*/
private void processArchiveAsset(File parentDirectory, ArchiveAsset nestedArchiveAsset) {
// Get the nested archive
Archive<?> nestedArchive = nestedArchiveAsset.getArchive();
nestedArchive.as(ExplodedExporter.class).exportExploded(parentDirectory);
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* {@inheritDoc}
*
* @see org.jboss.shrinkwrap.api.asset.Asset#openStream()
*/
@Override
public InputStream openStream() {
// Export via the specified exporter
return this.getArchive().as(this.exporter).exportAsInputStream();
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* Processes a nested archive by delegating to the ExplodedArchiveExporter
*
* @param parentDirectory
* @param nestedArchiveAsset
*/
private void processArchiveAsset(File parentDirectory, ArchiveAsset nestedArchiveAsset) {
// Get the nested archive
Archive<?> nestedArchive = nestedArchiveAsset.getArchive();
nestedArchive.as(ExplodedExporter.class).exportExploded(parentDirectory);
}
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base
/**
* Check to see if a path is found in a nested archive
*/
private boolean nestedContains(ArchivePath path) {
// Iterate through nested archives
for (Entry<ArchivePath, ArchiveAsset> nestedArchiveEntry : nestedArchives.entrySet()) {
ArchivePath archivePath = nestedArchiveEntry.getKey();
ArchiveAsset archiveAsset = nestedArchiveEntry.getValue();
// Check to see if the requested path starts with the nested archive path
if (startsWith(path, archivePath)) {
Archive<?> nestedArchive = archiveAsset.getArchive();
// Get the asset path from within the nested archive
ArchivePath nestedAssetPath = getNestedPath(path, archivePath);
// Recurse the call to the nested archive
return nestedArchive.contains(nestedAssetPath);
}
}
return false;
}
代码示例来源:origin: arquillian/arquillian-extension-persistence
/**
* Recursively scans archive content (including sub archives) for persistence.xml descriptors.
*/
private Collection<Node> collectPersistenceXml(final Archive<?> archive) {
final Collection<Node> nodes = new LinkedList<Node>(getPersistenceDescriptors(archive));
for (Node node : collectSubArchives(archive)) {
if (node.getAsset() instanceof ArchiveAsset) {
final ArchiveAsset archiveAsset = (ArchiveAsset) node.getAsset();
nodes.addAll(collectPersistenceXml(archiveAsset.getArchive()));
}
}
return nodes;
}
代码示例来源:origin: io.thorntail/jaxrs
private static boolean isJAXRS(ArchivePath path, Asset asset) {
if (asset == null) {
return false;
}
if (asset instanceof ArchiveAsset) {
return isJAXRS(((ArchiveAsset) asset).getArchive());
}
if (!path.get().endsWith(".class")) {
return false;
}
try (InputStream in = asset.openStream()) {
ClassReader reader = new ClassReader(in);
JAXRSAnnotationSeekingClassVisitor visitor = new JAXRSAnnotationSeekingClassVisitor();
reader.accept(visitor, 0);
return visitor.isFound();
} catch (IOException ignored) {
}
return false;
}
代码示例来源:origin: io.thorntail/jaxrs
static boolean hasApplicationPathAnnotation(ArchivePath path, Asset asset) {
if (asset == null) {
return false;
}
if (asset instanceof ArchiveAsset) {
return hasApplicationPathAnnotation(((ArchiveAsset) asset).getArchive());
}
if (!path.get().endsWith(".class")) {
return false;
}
try (InputStream in = asset.openStream()) {
ClassReader reader = new ClassReader(in);
ApplicationPathAnnotationSeekingClassVisitor visitor = new ApplicationPathAnnotationSeekingClassVisitor();
reader.accept(visitor, 0);
return visitor.isFound();
} catch (IOException ignored) {
}
return false;
}
代码示例来源:origin: org.jboss.arquillian.extension/arquillian-persistence-core
/**
* Recursively scans archive content (including sub archives) for persistence.xml descriptors.
*
* @param archive
* @return
*/
private Collection<Node> collectPersistenceXml(final Archive<?> archive)
{
final Collection<Node> nodes = new LinkedList<Node>(getPersistenceDescriptors(archive));
for (Node node : collectSubArchives(archive))
{
if (node.getAsset() instanceof ArchiveAsset)
{
final ArchiveAsset archiveAsset = (ArchiveAsset) node.getAsset();
nodes.addAll(collectPersistenceXml(archiveAsset.getArchive()));
}
}
return nodes;
}
代码示例来源:origin: cukespace/cukespace
private void enrichWithCDI(Archive<?> applicationArchive) {
Map<ArchivePath, Node> contentMap = applicationArchive.getContent(Filters.include(".*/cukespace-core.jar"));
for (Node node : contentMap.values()) {
if (node.getAsset() instanceof ArchiveAsset) {
JavaArchive archive = (JavaArchive) ((ArchiveAsset) node.getAsset()).getArchive();
archive.addClass(CukeSpaceCDIObjectFactory.class);
archive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
}
}
}
代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container
/**
* Explodes kumuluzee-loader library to root of the archive.
*
* @param javaArchive Archive with all jars in /WEB-INF/lib (war)
*/
private static void explodeLoaderArchiveToRoot(JavaArchive javaArchive) {
for (Node n : javaArchive.get("/WEB-INF/lib").getChildren()) {
if (n.getAsset() instanceof ArchiveAsset &&
((ArchiveAsset) n.getAsset()).getArchive().getName().startsWith("kumuluzee-loader-")) {
Archive<?> dependencyJar = ((ArchiveAsset) n.getAsset()).getArchive();
LOG.fine("Found kumuluzee-loader archive: " + dependencyJar.getName());
javaArchive.merge(dependencyJar);
javaArchive.delete(n.getPath());
break;
}
}
}
代码示例来源:origin: cukespace/cukespace
protected final Archive<? extends Archive<?>> findArchiveByTestClass(Archive<?> topArchive, Class testClass) {
Archive<?> testArchive = topArchive;
if (!archiveContains(testArchive, testClass)) {
for (Node node : testArchive.getContent(Filters.include(".*\\.(jar|war)")).values()) {
if (node.getAsset() instanceof ArchiveAsset) {
Archive archive = ((ArchiveAsset) node.getAsset()).getArchive();
if (archiveContains(archive, testClass) && archive instanceof LibraryContainer) {
testArchive = archive;
}
}
}
}
return testArchive;
}
代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container
/**
* Explodes archive marked with {@link ApplicationArchiveMarker} to root of the archive.
*
* @param javaArchive Archive with all jars in /WEB-INF/lib (war)
*/
private static void explodeAppArchiveToRoot(JavaArchive javaArchive) {
for (Node n : javaArchive.get("/WEB-INF/lib").getChildren()) {
if (n.getAsset() instanceof ArchiveAsset) {
Archive<?> dependencyJar = ((ArchiveAsset) n.getAsset()).getArchive();
if (dependencyJar.contains(ApplicationArchiveMarker.MARKER_FILENAME)) {
LOG.fine("Found application archive: " + dependencyJar.getName());
dependencyJar.delete(ApplicationArchiveMarker.MARKER_FILENAME);
javaArchive.merge(dependencyJar);
javaArchive.delete(n.getPath());
break;
}
}
}
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
public void testImportArchiveAsTypeFromFilterUsingDefaultFormat() throws Exception {
String resourcePath = "/test/cl-test.jar";
GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(
new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath);
Collection<JavaArchive> jars = archive.getAsType(JavaArchive.class, Filters.include(".*jar"));
Assert.assertEquals("Unexpected result found", 1, jars.size());
JavaArchive jar = jars.iterator().next().add(new StringAsset("test file content"), "test.txt");
Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName());
Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class"));
Assert.assertNotNull("Inner Class in JAR not imported",
jar.get("test/classloader/DummyClass$DummyInnerClass.class"));
Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset())
.getArchive().get("test.txt"));
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
public void testImportArchiveAsTypeFromFilter() throws Exception {
String resourcePath = "/test/cl-test.jar";
GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(
new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath);
Collection<JavaArchive> jars = archive
.getAsType(JavaArchive.class, Filters.include(".*jar"), ArchiveFormat.ZIP);
Assert.assertEquals("Unexpected result found", 1, jars.size());
JavaArchive jar = jars.iterator().next().add(new StringAsset("test file content"), "test.txt");
Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName());
Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class"));
Assert.assertNotNull("Inner Class in JAR not imported",
jar.get("test/classloader/DummyClass$DummyInnerClass.class"));
Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset())
.getArchive().get("test.txt"));
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
public void testImportArchiveAsTypeFromStringUsingDefaultFormat() throws Exception {
String resourcePath = "/test/cl-test.jar";
GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(
new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath);
JavaArchive jar = archive.getAsType(JavaArchive.class, resourcePath).add(new StringAsset("test file content"),
"test.txt");
Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName());
Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class"));
Assert.assertNotNull("Inner Class in JAR not imported",
jar.get("test/classloader/DummyClass$DummyInnerClass.class"));
Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset())
.getArchive().get("test.txt"));
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* Ensure adding an archive to a path successfully stores all assets to specific path including the archive name
*
* @throws Exception
*/
@Test
public void testAddArchiveToPath() throws Exception {
Archive<T> archive = getArchive();
Archive<T> sourceArchive = createNewArchive();
ArchivePath baseLocation = new BasicPath("somewhere");
archive.add(sourceArchive, baseLocation, ZipExporter.class);
ArchivePath expectedPath = new BasicPath(baseLocation, sourceArchive.getName());
Node node = archive.get(expectedPath);
Assert.assertNotNull("Asset should have been added to path: " + expectedPath.get(), node);
Assert.assertTrue("An instance of ArchiveAsset should have been added to path: " + expectedPath.get(),
node.getAsset() instanceof ArchiveAsset);
ArchiveAsset archiveAsset = ArchiveAsset.class.cast(node.getAsset());
Archive<?> nestedArchive = archiveAsset.getArchive();
Assert.assertEquals("Nested Archive should be same archive that was added", sourceArchive, nestedArchive);
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
public void testImportArchiveAsTypeFromString() throws Exception {
String resourcePath = "/test/cl-test.jar";
GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(
new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath);
JavaArchive jar = archive.getAsType(JavaArchive.class, resourcePath, ArchiveFormat.ZIP).add(
new StringAsset("test file content"), "test.txt");
Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName());
Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class"));
Assert.assertNotNull("Inner Class in JAR not imported",
jar.get("test/classloader/DummyClass$DummyInnerClass.class"));
Assert.assertNotNull("Should contain a new asset", ((ArchiveAsset) archive.get(resourcePath).getAsset())
.getArchive().get("test.txt"));
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
public void testImportArchiveAsTypeFromArchivePathUsingDefaultFormat() throws Exception {
String resourcePath = "/test/cl-test.jar";
GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(
new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath);
JavaArchive jar = archive.getAsType(JavaArchive.class, ArchivePaths.create(resourcePath)).add(
new StringAsset("test file content"), "test.txt");
Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName());
Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class"));
Assert.assertNotNull("Inner Class in JAR not imported",
jar.get("test/classloader/DummyClass$DummyInnerClass.class"));
Assert.assertNotNull("Should contain an archive asset", ((ArchiveAsset) archive.get(resourcePath).getAsset())
.getArchive().get("test.txt"));
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Test
public void testImportArchiveAsTypeFromArchivePath() throws Exception {
String resourcePath = "/test/cl-test.jar";
GenericArchive archive = ShrinkWrap.create(GenericArchive.class).add(
new FileAsset(TestIOUtil.createFileFromResourceName("cl-test.jar")), resourcePath);
JavaArchive jar = archive.getAsType(JavaArchive.class, ArchivePaths.create(resourcePath), ArchiveFormat.ZIP)
.add(new StringAsset("test file content"), "test.txt");
Assert.assertEquals("JAR imported with wrong name", resourcePath, jar.getName());
Assert.assertNotNull("Class in JAR not imported", jar.get("test/classloader/DummyClass.class"));
Assert.assertNotNull("Inner Class in JAR not imported",
jar.get("test/classloader/DummyClass$DummyInnerClass.class"));
Assert.assertNotNull("Should contain an archive asset", ((ArchiveAsset) archive.get(resourcePath).getAsset())
.getArchive().get("test.txt"));
}
内容来源于网络,如有侵权,请联系作者删除!