use of org.jboss.shrinkwrap.api.asset.ClassAsset in project camel by apache.
the class ManagedSEDeployableContainer method materializeDirectory.
private void materializeDirectory(Archive<?> archive) throws DeploymentException {
if (archive.getContent().isEmpty()) {
// Do not materialize an empty directory
return;
}
File entryDirectory = new File(TARGET.concat(File.separator).concat(archive.getName()));
try {
if (entryDirectory.exists()) {
// Always delete previous content
FileDeploymentUtils.deleteContent(entryDirectory.toPath());
} else {
if (!entryDirectory.mkdirs()) {
throw new DeploymentException("Could not create class path directory: " + entryDirectory);
}
}
for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) {
Asset asset = child.getAsset();
if (asset instanceof ClassAsset) {
FileDeploymentUtils.materializeClass(entryDirectory, (ClassAsset) asset);
} else if (asset == null) {
FileDeploymentUtils.materializeSubdirectories(entryDirectory, child);
}
}
} catch (IOException e) {
throw new DeploymentException("Could not materialize class path directory: " + archive.getName(), e);
}
materializedFiles.add(entryDirectory);
}
use of org.jboss.shrinkwrap.api.asset.ClassAsset in project wildfly by wildfly.
the class SubDeploymentAvailableInClassPathTestCase method createEarWithExplodedWar.
@Deployment(name = "ear-with-exploded-war", testable = false)
public static EnterpriseArchive createEarWithExplodedWar() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejb.jar");
ejbJar.addClasses(EJBBusinessInterface.class, SimpleSLSB.class);
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "exploded.ear");
ear.addAsModule(ejbJar);
ear.add(new StringAsset("OK!"), "exploded.war/index.jsp");
ear.add(new ClassAsset(EjbInvokingServlet.class), "exploded.war/WEB-INF/classes/" + EjbInvokingServlet.class.getName().replace('.', '/') + ".class");
final JavaArchive servletJar = ShrinkWrap.create(JavaArchive.class, "servlet.jar");
servletJar.addClass(HelloWorldServlet.class);
ear.add(servletJar, "exploded.war/WEB-INF/lib", ZipExporter.class);
return ear;
}
Aggregations