Search in sources :

Example 1 with ClassAsset

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);
}
Also used : ClassAsset(org.jboss.shrinkwrap.api.asset.ClassAsset) Node(org.jboss.shrinkwrap.api.Node) ClassAsset(org.jboss.shrinkwrap.api.asset.ClassAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset) ArchiveAsset(org.jboss.shrinkwrap.api.asset.ArchiveAsset) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) IOException(java.io.IOException) File(java.io.File)

Example 2 with ClassAsset

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;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) ClassAsset(org.jboss.shrinkwrap.api.asset.ClassAsset) EjbInvokingServlet(org.jboss.as.test.integration.deployment.classloading.ear.subdeployments.servlet.EjbInvokingServlet) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

ClassAsset (org.jboss.shrinkwrap.api.asset.ClassAsset)2 File (java.io.File)1 IOException (java.io.IOException)1 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)1 EjbInvokingServlet (org.jboss.as.test.integration.deployment.classloading.ear.subdeployments.servlet.EjbInvokingServlet)1 Node (org.jboss.shrinkwrap.api.Node)1 ArchiveAsset (org.jboss.shrinkwrap.api.asset.ArchiveAsset)1 Asset (org.jboss.shrinkwrap.api.asset.Asset)1 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)1 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)1 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)1