-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure taglib with spring #2
Comments
Maybe an instance of OptimizedResourcesRootProvider could be configured through spring? |
If wro4j is configured through spring, then the filter is often an instance of the dynamic proxy class org.springframework.web.filter.DelegatingFilterProxy. Additionally, there's no instance of WroServletContextListener. |
WroManagerFactory should be initialized before TaglibContext because TaglibContextFactory decorates WroManagerFactory. i.e. WroServletContextListener might still be required to create WroManagerFactory unless there would be a singleton bean for WroManagerFactory that would be injected/autowired. Unfortunately, DelegatingFilterProxy doesn't provide a way to get a bean class name(s) and so we couldn't be sure that it actually delegates to WroFilter. findWebApplicationContext is protected i.e. it would require some spring-specific code and I believe that there might be a better solution: I'm going to support something like this:
this class should probably also have a setter to allow setter injection. |
Would it be an option to configure the TaglibContextFactory through spring as well? |
Actually, It might be already possible to initialize TaglibContext through spring because TaglibContext.initialize accepts ServletContext. |
Do you have an example setting up a TaglibContext in spring? The crucial constructors in TaglibContext and TaglibContextFactory are package protected, making it a bit hard to initialize outside. |
Unfortunately, I don't have such an example. I may create one though. |
Ok, got it set up now, but unfortunately, in DefaultOptimizedResourcesRootProvider.getFilterRegistrations(), servletContext.getServletRegistrations() is called, and this method cannot be called from outside of a servlet listener (throws an UnsupportedOperationException). So I guess using a different resources root provider that just takes the config from properties as you suggested above is probably the best way forward. I had success with a dummy setup; package com.github.lifus.wro4j_runtime_taglib.model.resource.uri.root; import javax.servlet.FilterRegistration; public final class SpringOptimizedResourcesRootProvider extends AbstractOptimizedResourcesRootProvider { public SpringOptimizedResourcesRootProvider(final ServletContext servletContext) { } @OverRide |
… that it would be possible to configure it from wro.properties Relates to #2
Works well with 0.1.3-SNAPSHOT, thx! |
Closing this one for now as I'm going to include current implementation as is in 0.2.0 release. Feel free to reopen this issue or create a more specific one |
It would be very convenient if the taglib could be configured through Spring. This is especially handy when the wro4j filter and manager is itself configured through Spring.
The text was updated successfully, but these errors were encountered: