You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by GitBox <gi...@apache.org> on 2022/06/25 21:21:43 UTC

[GitHub] [struts] JCgH4164838Gh792C124B5 commented on pull request #573: [WW-5173] - Attempt to fix DI behaviour for custom cache factories

JCgH4164838Gh792C124B5 commented on PR #573:
URL: https://github.com/apache/struts/pull/573#issuecomment-1166363454

   Hello @yasserzamani .  Thanks for taking a look and providing feedback.  😄 
   
   I will attempt to respond to your question for more detail on the container construction still using the default implementations.  The information is based on stepping through breakpoints using a sample application with a custom expression cache factory configured.
   
   The `Dispatcher` `init()` method container/configuration loading seems to happen in two phases.  Both phases invoke `DefaultConfiguration` methods, the first pass-through calling `createBootstrapContainer()`, and then a second pass-through calling `reloadConatiner()`. 
   For the "bootstrap" container, the `OgnlUtil` instance created has the default cache factory instances injected, but those factories do not have any configuration parameters set (just the default state, without injection) at that point.  Next, for the "reloaded" container, the `OgnlUtil` instance created has the default factory instances injected, but this time with the parameters that were set in configuration (size, LRU mode).
   
   In neither case is the custom cache factory dependency recognized as being present to be injected.  In the test application, when `container.getInstance(ExpressionCacheFactory.class, container.getInstance(String.class, StrutsConstants.STRUTS_OGNL_EXPRESSION_CACHE_FACTORY))` is called within an action, it then returns the custom cache factory ... but the container has to construct the instance at that point (being the first call generating the custom factory instance).
   
   So, the custom factory instance appears to be wired-up correctly, but something is still missing.  Maybe a `ContainerProvider` of some sort is needed to allow for "early-binding" of something like this, or maybe something else, but so far nothing I have tried has allowed for a custom cache factory (expression, beaninfo) to be injected into the `OgnlUtil` singleton instance.
   
   I am not sure what else to try at this point, something in my understanding of the mechanism seems to be missing ... 😞 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org