Package io.dropwizard.assets
Class AssetsBundle
- java.lang.Object
-
- io.dropwizard.assets.AssetsBundle
-
- All Implemented Interfaces:
ConfiguredBundle<Configuration>
public class AssetsBundle extends Object implements ConfiguredBundle<Configuration>
A bundle for serving static asset files from the classpath.
-
-
Constructor Summary
Constructors Constructor Description AssetsBundle()
Creates a new AssetsBundle which serves up static assets fromsrc/main/resources/assets/*
as/assets/*
.AssetsBundle(String path)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${path}
as/${path}
.AssetsBundle(String resourcePath, String uriPath)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
.AssetsBundle(String resourcePath, String uriPath, String indexFile)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
.AssetsBundle(String resourcePath, String uriPath, String indexFile, String assetsName)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
.AssetsBundle(String resourcePath, String uriPath, String indexFile, String assetsName, String defaultMediaType)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AssetServlet
createServlet()
String
getDefaultMediaType()
String
getIndexFile()
String
getResourcePath()
String
getUriPath()
void
run(Configuration configuration, Environment environment)
Initializes the environment.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.dropwizard.core.ConfiguredBundle
initialize
-
-
-
-
Constructor Detail
-
AssetsBundle
public AssetsBundle()
Creates a new AssetsBundle which serves up static assets fromsrc/main/resources/assets/*
as/assets/*
.- See Also:
AssetsBundle(String, String, String)
-
AssetsBundle
public AssetsBundle(String path)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${path}
as/${path}
. For example, given apath
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(String, String, String)
-
AssetsBundle
public AssetsBundle(String resourcePath, String uriPath)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
. For example, given aresourcePath
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 filesuriPath
- the uri path for the static asset files- See Also:
AssetsBundle(String, String, String)
-
AssetsBundle
public AssetsBundle(String resourcePath, String uriPath, String indexFile)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
. If no file name is in ${uriPath}, ${indexFile} is appended before serving. For example, given aresourcePath
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 filesuriPath
- the uri path for the static asset filesindexFile
- the name of the index file to use
-
AssetsBundle
public AssetsBundle(String resourcePath, String uriPath, String indexFile, String assetsName)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
. If no file name is in ${uriPath}, ${indexFile} is appended before serving. For example, given aresourcePath
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 filesuriPath
- the uri path for the static asset filesindexFile
- the name of the index file to useassetsName
- the name of servlet mapping used for this assets bundle
-
AssetsBundle
public AssetsBundle(String resourcePath, String uriPath, String indexFile, String assetsName, String defaultMediaType)
Creates a new AssetsBundle which will configure the application to serve the static files located insrc/main/resources/${resourcePath}
as/${uriPath}
. If no file name is in ${uriPath}, ${indexFile} is appended before serving. For example, given aresourcePath
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 filesuriPath
- the uri path for the static asset filesindexFile
- the name of the index file to useassetsName
- the name of servlet mapping used for this assets bundledefaultMediaType
- the default media type for unknown file extensions- Since:
- 2.0
-
-
Method Detail
-
run
public void run(Configuration configuration, Environment environment)
Description copied from interface:ConfiguredBundle
Initializes the environment.- Specified by:
run
in interfaceConfiguredBundle<Configuration>
- Parameters:
configuration
- the configuration objectenvironment
- the application'sEnvironment
-
getResourcePath
public String getResourcePath()
-
getUriPath
public String getUriPath()
-
getIndexFile
public String getIndexFile()
-
getDefaultMediaType
public String getDefaultMediaType()
- Since:
- 2.0
-
createServlet
protected AssetServlet createServlet()
-
-