Search in sources :

Example 1 with FaviconServletExtension

use of org.wildfly.swarm.undertow.internal.FaviconServletExtension in project wildfly-swarm by wildfly-swarm.

the class WebXmlContainer method addFaviconExceptionHandler.

/**
 * Add the default Thorntail {@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)

Aggregations

ServletExtension (io.undertow.servlet.ServletExtension)1 ByteArrayAsset (org.jboss.shrinkwrap.api.asset.ByteArrayAsset)1 FaviconServletExtension (org.wildfly.swarm.undertow.internal.FaviconServletExtension)1