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;
}
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);
}
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();
}
}
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);
}
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();
}
}
Aggregations