[ https://issues.apache.org/jira/browse/MYFACES-3786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13794717#comment-13794717 ]
Gerhard Petracek commented on MYFACES-3786: ------------------------------------------- no - maybe it wasn't clear enough. let's start from the beginning. the whole topic is only about supporting other scopes like request-scoped artifacts (which might be needed in the future) for jsf-artifacts which aren't managed by cdi (because we have to create the instances for proper wrapping). those jsf-artifacts might have dependent-scoped beans injected (injected but not managed by the cdi container, because they are dependent-scoped). what we have right now already works for them, but it would be better (in all cases #1-#4) to store the meta-data in the same scope (to be more solid in case of unexpected issues with our own cleanup logic, support session-replication in case of such session-scoped artifacts (if there will be any we have to support),...) as you said - it's a good idea to keep responsibilities separated -> InjectionProvider is about handling injection and not storing meta-data in the correct scopes/contexts. with using a string (#2/#3) you would have: outside of InjectionProvider: FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(beanName, instance); -> call InjectionProvider#inject(..., "[scope-name]") -> inside of InjectionProvider Map storage = getStorage(scopeName); //which is: FacesContext.getCurrentInstance().getExternalContext().getRequestMap() after checking the scope-name storage.put(uniqueIdForBeanInstance, creationalContext); ... -> call InjectionProvider#preDestroy(..., "[scope-name]") -> inside of InjectionProvider Map storage = getStorage(scopeName); //which is: FacesContext.getCurrentInstance().getExternalContext().getRequestMap() after checking the scope-name storage.get(uniqueIdForBeanInstance); //call #release on the result ... and with #4 it would be: outside of InjectionProvider: Map storage = getStorage(scopeName); //which is: FacesContext.getCurrentInstance().getExternalContext().getRequestMap() storage.put(beanName, instance); -> call InjectionProvider#inject(..., storage) -> inside of InjectionProvider storage.put(uniqueIdForBeanInstance, creationalContext); ... Map storage = getStorage(scopeName); //which is: FacesContext.getCurrentInstance().getExternalContext().getRequestMap() -> call InjectionProvider#preDestroy(..., storage) -> inside of InjectionProvider storage.get(uniqueIdForBeanInstance); //call #release on the result ... #4 is nothing new, there are many libs which do such a separation. as mentioned before - all (#1-#4) have disadvantages and i know what you mean, the string approach also came to my mind initially. however, it just adds an indirection which isn't needed (one method call later it gets mapped back to the same map - in any useful case), mixes responsibilities and forces redundant lookups (you need the same lookup you did directly before). > Web Container injection support should be provided for additional lifecycle > artifacts (not just managed beans) > -------------------------------------------------------------------------------------------------------------- > > Key: MYFACES-3786 > URL: https://issues.apache.org/jira/browse/MYFACES-3786 > Project: MyFaces Core > Issue Type: Task > Components: JSR-344 > Reporter: Leonardo Uribe > Assignee: Leonardo Uribe > Fix For: 2.2.0 > > Attachments: cdiELresolverWeb.zip, cdiELResolver.zip, > cdiPartialViewContext.war, cdiPartialViewContext.zip, cdi.patch, > cdiphaselistener1.patch, cdiphaselistener2.patch, cdirevised.patch, > cdiValidatorSource.zip, cdiValidator.war, MYFACES-3786-1.patch, > MYFACES-3786-2.patch > > > This issue is all about how to inject beans into jsf artifacts. > See JSF 2.2 section 5.4.1 > The problem here is in some point we need to give the control to the > underlying environment to inject beans into the artifacts, but we don't know > much about how to properly do it, so we need to try with examples. -- This message was sent by Atlassian JIRA (v6.1#6144)