TheMangoFactory / bakehouse

Streamlines web pre-processors for Spring resources
http://themangofactory.github.com/bakehouse
21 stars 4 forks source link

Introduce configuration DSL #5

Closed martypitt closed 11 years ago

martypitt commented 11 years ago

Currently, configuration is a bit naff:

@Component
public class BakehouseConfig implements InitializingBean {

    @Autowired
    private ResourceCache resourceCache;

    @Autowired
    private FileManager fileRepository;

    @Override
    public void afterPropertiesSet() throws Exception {
        resourceCache.addConfiguration("javascript", 
            new ConcatenateResourcesProcessor("AppCode.js",fileRepository)
        );
        resourceCache.addConfiguration("typescript", 
            new TypescriptProcessor("TypescriptCode.js", fileRepository)    
        );
    }

}

I'd rather use a DSL here ... something along the lines of:

    @Configuration
@Profile("Production")
public class ProposedBakehouseConfig {

    @Bean
    public BakehouseConfig build(BakehouseBuilder builder)
    {
        builder
        .process("javascript").concatenate()
        .process("typescript").with(new TypescriptProcessor())
        .serveResourcesFromCdn();
    }
}