contributePostProcessors() not invoked against custom WroManager instance

16 views
Skip to first unread message

Ryan Lubke

unread,
Sep 14, 2014, 5:14:01 PM9/14/14
to wr...@googlegroups.com
Hey Folks,

I'm probably missing something simple here, but I've followed the instructions (at least I believe so) on updating the LessCssProcessor with a new version of less.js and registering the new processor with the runtime.

public class FactoryExtension
        extends ExtensionsConfigurableWroManagerFactory {

    public FactoryExtension() {
        System.out.println("Constructing");
    }

    @Override
    protected void contributePostProcessors(Map<String, ResourcePostProcessor> map) {
        map.put("less175Css", Less175Css.INSTANCE);
    }


    // ----------------------------------------------------------- Nested Classes

    @SupportedResourceType(ResourceType.CSS)
    static final class Less175Css extends LessCssProcessor {

        static final Less175Css INSTANCE = new Less175Css();

        private final ServletContextUriLocator locator;


        // -------------------------------------------------------- Constructors


        private Less175Css() {
            locator = new ServletContextUriLocator();
            locator.setLocatorStrategy(SERVLET_CONTEXT_ONLY);
        }


        // --------------------------------------- Methods from LessCssProcessor

        protected LessCss newLessCss() {
            return new LessCss() {
              protected InputStream getScriptAsStream() throws IOException {
                return locator.locate("/WEB-INF/less/less-1.7.5js");
              }
            };
          }

    } // END Less175Css
}



The factory is instantiated fine, but the contributePostProcessors() method is never invoked.  I'm hoping someone can point me in the right direction before I spend cycles debugging the wro4j-core. 

Alex Objelean

unread,
Sep 15, 2014, 2:51:29 AM9/15/14
to wr...@googlegroups.com
Hi,

the easiest way to use a different version of lessCss is to update the lessCss webjar dependency. The only problem with this approach is that the 1.7.5 version is not available on maven central repo (only 1.7.0 and 1.8.0 versions are the closest to the one you need). 

The second easiest approach is to use less4j processor. It is a java implementation of lessCss lang. It has dozen of versions (which do not map directly to lessCss version), but you can give it a try. The advantage of this processor is speed (comparing to lessCss processor).

If you still want to create a custom processor, it is enough to register your custom processor using SPI. There is an example project on github. There is no need to extend ExtensionsConfigurableWroManagerFactory which is deprecated. The existing ConfigurableWroManagerFactory is enough to achieve what you need. 

Let me know if that helps or if you have any other questions.

Cheers,
Alex

--
You received this message because you are subscribed to the Google Groups "wro4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wro4j+un...@googlegroups.com.
To post to this group, send email to wr...@googlegroups.com.
Visit this group at http://groups.google.com/group/wro4j.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages