[weld-issues] [JBoss JIRA] Updated: (WELD-329) Implementation of SessionBean's InjectionTarget is incorrect, it's produce() method should return a constructor injected object, not the proxy

Pete Muir (JIRA) jira-events at lists.jboss.org
Thu Dec 3 11:40:29 EST 2009


     [ https://jira.jboss.org/jira/browse/WELD-329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pete Muir updated WELD-329:
---------------------------

    Description: InjectionTarget.produce() seems to be doing something completely wrong and broken. It is supposed to return a non-container-managed object. EJB should be the thing calling it, not Weld directly.  (was: ManagedBean.create() looks like this:

   public T create(CreationalContext<T> creationalContext)
   {
      T instance = getInjectionTarget().produce(creationalContext);
      getInjectionTarget().inject(instance, creationalContext);
      if (isInterceptionCandidate() && (hasCdiBoundInterceptors() || hasDirectlyDefinedInterceptors()))
      {
         InterceptionUtils.executePostConstruct(instance);
      }
      else
      {
         getInjectionTarget().postConstruct(instance);
      }
      return instance;
   }

The code that is aware of interceptors needs to be sucked into InjectionTarget.postConstruct(), since a portable extension can't easily reproduce that logic. create() should look like:

   public T create(CreationalContext<T> creationalContext)
   {
      T instance = getInjectionTarget().produce(creationalContext);
      getInjectionTarget().inject(instance, creationalContext);
      getInjectionTarget().postConstruct(instance);
      return instance;
   }

Same goes for destroy().

The implementations of create() and destroy() in SessionBean are even worse. In this case, InjectionTarget.produce() seems to be doing something completely wrong and broken. It is supposed to return a non-container-managed object. EJB should be the thing calling it, not Weld directly.)


> Implementation of SessionBean's InjectionTarget is incorrect, it's produce() method should return a constructor injected object, not the proxy
> ----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WELD-329
>                 URL: https://jira.jboss.org/jira/browse/WELD-329
>             Project: Weld
>          Issue Type: Bug
>          Components: Class Beans (Managed and Session)
>    Affects Versions: 1.0.0.GA
>            Reporter: Gavin King
>            Priority: Critical
>             Fix For: 1.0.1.CR1
>
>
> InjectionTarget.produce() seems to be doing something completely wrong and broken. It is supposed to return a non-container-managed object. EJB should be the thing calling it, not Weld directly.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list