alexo / wro4j

New project location is:https://github.com/wro4j/wro4j
442 stars 110 forks source link

Unexpected behavior when extending ConfigurableWroManagerFactory #203

Closed g0dkar closed 10 years ago

g0dkar commented 10 years ago

Hi! I made a Processor to easily implement i18n processing within JS files (by replacing ${stuff} with the corresponding i18n value) and, so I can use it, I've created this class:

public class WroConfig extends ConfigurableWroManagerFactory {
    private static final JsI18NProcessor PROCESSOR = new JsI18NProcessor();

    protected void contributePreProcessors(final Map<String, ResourcePreProcessor> map) {
        map.put("jsi18n", PROCESSOR);
    }

    protected void contributePostProcessors(final Map<String, ResourcePostProcessor> map) {
        map.put("jsi18n", PROCESSOR);
    }
}

And then changed my wro.properties files to point to it:

managerFactoryClassName=my.wonderful.javaPackage.WroConfig
...
# Pre-processors
preProcessors=semicolonAppender,googleClosureSimple,yuiCssMin,jsi18n
postProcessors=

Now I'm running in some unexpected behavior/problem.

Apparently some URLs are not being rewritten within external CSS files (this one http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css - with minimize="false" - is the most noticeable).

My JsI18NProcessor class is annotated with @SupportedResourceType(ResourceType.JS) so (I hope) it's not my Processor.

If I remove the managerFactoryClassName property from the properties file all goes back to normal and works as expected.

I couldn't trace it myself so I'm opening this issue here...

Another unexpected thing is when I remove the property it seems that the googleClosureSimple is ignored (or it doesn't change variable names). I take it that this behaviour is probably a config error I made...

g0dkar commented 10 years ago

After messing around with a lot of stuff, I found out the problem was with my configuration. It should have that managerFactoryClassName set to ro.isdc.wro.manager.factory.ConfigurableWroManagerFactory for those pre and post processors mean something.

I was mislead by WRO's docs to do this =/ Is it possible to fix them to make them clearer?

alexo commented 10 years ago

Sure, just be more specific about which javadoc you find confusing.

Btw, there is already a processor which replace placeholders. It looks very similar to yours.

g0dkar commented 10 years ago

The docs were the ones at the Google Code project Wiki: https://code.google.com/p/wro4j/wiki/Installation

And I know about that processor, but the one I've implemented uses a ResourceBundle instead of a single properties file so it's better suited for i18n :)