public abstract class AssetProcessor extends AssetOptions
Checks, validate and/or modify asset contents. An AssetProcessor is usually provided as a
separated dependency.
First thing to do is to add the dependency:
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-assets-my-processor</artifactId>
<scope>provided</scope>
</dependency>
Did you see the provided scope? We just need the processor for development,
because assets are processed on the fly. For prod, assets are processed at
built-time via Maven/Gradle plugin, at runtime we don't need this. This also, helps to keep our
dependencies and the jar size small.
Now we have the dependency all we have to do is to add it to our pipeline:
assets {
pipeline: {
dev: [my-processor]
}
}
It is possible to configure or set options too:
assets {
pipeline: {
dev: [my-processor]
dist: [my-processor]
}
my-processor {
foo: bar
}
}
Previous example, set a foo property to bar! Options can be set
per environment too:
assets {
pipeline: {
dev: [my-processor]
dist: [my-processor]
}
my-processor {
dev {
bar: bar
}
dist {
foo: bar
}
foo: foo
}
}
Here, in dev processor has two properties: foo:foo and
bar:bar, while in dist the processor only has foo:bar
The my-processor will be resolved it to: org.jooby.assets.MyProcessor
class. The processor name is converted to MyProcessor, it converts the hyphenated
name to upper camel and by default processors are defined in the org.jooby.assets
package.
A custom binding is provided via the class property:
assets {
pipeline: {
dev: [my-processor]
dist: [my-processor]
}
my-processor {
class: whatever.i.Want
}
}
| Constructor and Description |
|---|
AssetProcessor() |
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
matches(MediaType type) |
String |
name() |
abstract String |
process(String filename,
String source,
com.typesafe.config.Config conf) |
AssetProcessor |
set(com.typesafe.config.Config options) |
AssetProcessor |
set(String name,
Object value) |
String |
toString() |
get, optionspublic String name()
public AssetProcessor set(String name, Object value)
set in class AssetOptionspublic AssetProcessor set(com.typesafe.config.Config options)
set in class AssetOptionspublic abstract boolean matches(MediaType type)
public abstract String process(String filename, String source, com.typesafe.config.Config conf) throws Exception
ExceptionCopyright © 2016. All rights reserved.