com.github.lltyk.wro4j.services.WRO4JModule Maven / Gradle / Ivy
package com.github.lltyk.wro4j.services;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Primary;
import org.apache.tapestry5.services.assets.ContentTypeAnalyzer;
import org.apache.tapestry5.services.assets.ResourceMinimizer;
import org.apache.tapestry5.services.assets.ResourceTransformer;
import ro.isdc.wro.config.Context;
import ro.isdc.wro.config.jmx.WroConfiguration;
import ro.isdc.wro.manager.WroManager;
import ro.isdc.wro.manager.factory.BaseWroManagerFactory;
public class WRO4JModule
{
public static void contributeStreamableResourceSource(MappedConfiguration configuration)
{
configuration.addInstance("coffee", CoffeeScriptJsTransformer.class);
configuration.addInstance("less", LessCssTransformer.class);
configuration.addInstance("sass", SassCssTransformer.class);
}
@Contribute(ContentTypeAnalyzer.class)
public static void setupContentTypeMappings(MappedConfiguration configuration) {
configuration.add("coffee", "text/javascript");
configuration.add("less", "text/css");
configuration.add("sass", "text/css");
}
@Contribute(ResourceMinimizer.class)
@Primary
public static void contributeMinimizers(MappedConfiguration configuration)
{
configuration.addInstance("text/javascript", GoogleClosureJSMinimizer.class);
configuration.addInstance("text/css", YuiCssMinimizer.class);
}
public WroConfiguration buildDefaultConfiguration()
{
return new WroConfiguration();
}
public WroManager buildDefaultWroManager()
{
try {
Context.set(Context.standaloneContext());
return new BaseWroManagerFactory().create();
} finally {
Context.unset();
}
}
}