Search in sources :

Example 1 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly-swarm by wildfly-swarm.

the class WebXmlContainer method addFaviconExceptionHandler.

/**
 * Add the default WildFly Swarm {@code favicon.ico} handler.
 *
 * @return This archive.
 */
@SuppressWarnings("unchecked")
default T addFaviconExceptionHandler() throws IOException {
    // Add FaviconServletExtension
    String path = "WEB-INF/classes/" + FaviconServletExtension.EXTENSION_NAME.replace('.', '/') + ".class";
    byte[] generatedExtension;
    generatedExtension = FaviconFactory.createFaviconServletExtension(FaviconServletExtension.EXTENSION_NAME);
    add(new ByteArrayAsset(generatedExtension), path);
    // Add FaviconErrorHandler
    path = "WEB-INF/classes/" + FaviconServletExtension.HANDLER_NAME.replace('.', '/') + ".class";
    byte[] generatedHandler;
    generatedHandler = FaviconFactory.createFaviconErrorHandler(FaviconServletExtension.HANDLER_NAME);
    add(new ByteArrayAsset(generatedHandler), path);
    // Add services entry for FaviconServletExtension
    this.addAsServiceProvider(ServletExtension.class.getName(), FaviconServletExtension.EXTENSION_NAME);
    return (T) this;
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) ServletExtension(io.undertow.servlet.ServletExtension) FaviconServletExtension(org.wildfly.swarm.undertow.internal.FaviconServletExtension)

Example 2 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly-swarm by wildfly-swarm.

the class BuildTool method addWildFlySwarmApplicationManifest.

private void addWildFlySwarmApplicationManifest() {
    WildFlySwarmManifest manifest = this.dependencyManager.getWildFlySwarmManifest();
    this.properties.put("swarm.uberjar.build.user", System.getProperty("user.name"));
    if (!this.hollow) {
        this.properties.put(BootstrapProperties.APP_ARTIFACT, this.projectAsset.getSimpleName());
    }
    manifest.setProperties(this.properties);
    manifest.bundleDependencies(this.bundleDependencies);
    manifest.setMainClass(this.mainClass);
    manifest.setHollow(this.hollow);
    this.archive.add(new ByteArrayAsset(manifest.toString().getBytes(StandardCharsets.UTF_8)), WildFlySwarmManifest.CLASSPATH_LOCATION);
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest)

Example 3 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly-swarm by wildfly-swarm.

the class BuildTool method addJarManifest.

private void addJarManifest() {
    Manifest manifest = new Manifest();
    Attributes attrs = manifest.getMainAttributes();
    attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0");
    attrs.put(Attributes.Name.MAIN_CLASS, Main.class.getName());
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        manifest.write(out);
        out.close();
        byte[] bytes = out.toByteArray();
        this.archive.addAsManifestResource(new ByteArrayAsset(bytes), "MANIFEST.MF");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) Attributes(java.util.jar.Attributes) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Manifest(java.util.jar.Manifest) WildFlySwarmManifest(org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest) Main(org.wildfly.swarm.bootstrap.Main)

Example 4 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project core by weld.

the class ListenerInjectionTest method createTestArchive.

@Deployment
public static WebArchive createTestArchive() {
    StringBuilder listeners = new StringBuilder();
    listeners.append(toListener(BatRequestListener.class.getName()));
    listeners.append(toListener(BatSessionListener.class.getName()));
    listeners.append(toListener(BatServletContextListener.class.getName()));
    Asset webXml = new ByteArrayAsset(extendDefaultWebXml(listeners.toString() + "<servlet><servlet-name>Bat Servlet</servlet-name><servlet-class>" + BatServlet.class.getName() + "</servlet-class></servlet> <servlet-mapping><servlet-name>Bat Servlet</servlet-name><url-pattern>/bat</url-pattern></servlet-mapping>").getBytes());
    return baseDeployment(webXml).addClasses(BatRequestListener.class, BatSessionListener.class, BatServletContextListener.class, BatListener.class, BatServlet.class, Sewer.class);
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) Asset(org.jboss.shrinkwrap.api.asset.Asset) ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) Deployments.baseDeployment(org.jboss.weld.environment.servlet.test.util.Deployments.baseDeployment) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 5 with ByteArrayAsset

use of org.jboss.shrinkwrap.api.asset.ByteArrayAsset in project wildfly-swarm by wildfly-swarm.

the class DefaultApplicationDeploymentProcessor method addGeneratedApplication.

private void addGeneratedApplication(JAXRSArchive archive) {
    String name = "org.wildfly.swarm.generated.WildFlySwarmDefaultJAXRSApplication";
    String path = "WEB-INF/classes/" + name.replace('.', '/') + ".class";
    byte[] generatedApp;
    try {
        generatedApp = DefaultApplicationFactory.create(name, applicationPath.get());
        archive.add(new ByteArrayAsset(generatedApp), path);
        archive.addHandlers(new ApplicationHandler(archive, path));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : ByteArrayAsset(org.jboss.shrinkwrap.api.asset.ByteArrayAsset) IOException(java.io.IOException)

Aggregations

ByteArrayAsset (org.jboss.shrinkwrap.api.asset.ByteArrayAsset)24 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 Deployment (org.jboss.arquillian.container.test.api.Deployment)8 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)6 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)5 InputStream (java.io.InputStream)4 Index (org.jboss.jandex.Index)4 IndexWriter (org.jboss.jandex.IndexWriter)4 Indexer (org.jboss.jandex.Indexer)4 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)4 File (java.io.File)3 WildFlySwarmManifest (org.wildfly.swarm.bootstrap.env.WildFlySwarmManifest)3 JAXRSArchive (org.wildfly.swarm.jaxrs.JAXRSArchive)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 URL (java.net.URL)2 Properties (java.util.Properties)2 Attributes (java.util.jar.Attributes)2 Manifest (java.util.jar.Manifest)2