Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.assets;
 
 
 import static com.google.common.base.Preconditions.checkArgument;

A bundle for serving static asset files from the classpath.
public class AssetsBundle implements Bundle {
    private static final String DEFAULT_INDEX_FILE = "index.htm";
    private static final String DEFAULT_PATH = "/assets";
    private final String resourcePath;
    private final String uriPath;
    private final String indexFile;

    
Creates a new AssetsBundle which serves up static assets from src/main/resources/assets/* as /assets/*.

    public AssetsBundle() {
    }

    
Creates a new AssetsBundle which will configure the service to serve the static files located in src/main/resources/${path} as /${path}. For example, given a path of "/assets", src/main/resources/assets/example.js would be served up from /assets/example.js.

Parameters:
path the classpath and URI root of the static asset files
See also:
AssetsBundle.AssetsBundle(java.lang.String,java.lang.String,java.lang.String)
    public AssetsBundle(String path) {
        this(pathpath);
    }

    
Creates a new AssetsBundle which will configure the service to serve the static files located in src/main/resources/${resourcePath} as /${uriPath}. For example, given a resourcePath of "/assets" and a uriPath of "/js", src/main/resources/assets/example.js would be served up from /js/example.js.

Parameters:
resourcePath the resource path (in the classpath) of the static asset files
uriPath the uri path for the static asset files
See also:
AssetsBundle.AssetsBundle(java.lang.String,java.lang.String,java.lang.String)
    public AssetsBundle(String resourcePathString uriPath) {
        this(resourcePathuriPath);
    }

    
Creates a new AssetsBundle which will configure the service to serve the static files located in src/main/resources/${resourcePath} as /${uriPath}. If no file name is in ${uriPath}, ${indexFile} is appended before serving. For example, given a resourcePath of "/assets" and a uriPath of "/js", src/main/resources/assets/example.js would be served up from /js/example.js.

Parameters:
resourcePath the resource path (in the classpath) of the static asset files
uriPath the uri path for the static asset files
indexFile the name of the index file to use
    public AssetsBundle(String resourcePathString uriPathString indexFile) {
        checkArgument(resourcePath.startsWith("/"), "%s is not an absolute path"resourcePath);
        checkArgument(!"/".equals(resourcePath), "%s is the classpath root"resourcePath);
        this. = resourcePath.endsWith("/") ? resourcePath : (resourcePath + '/');
        this. = uriPath.endsWith("/") ? uriPath : (uriPath + '/');
        this. = indexFile;
    }
    @Override
    public void initialize(Bootstrap<?> bootstrap) {
        // nothing doing
    }
    @Override
    public void run(Environment environment) {
        environment.addServlet(createServlet(),  + '*');
    }
    private AssetServlet createServlet() {
        return new AssetServlet();
    }
New to GrepCode? Check out our FAQ X