[JBoss JIRA] Created: (WELD-313) create() method of container Bean implementations should be reproducible with user Bean implementations
by Gavin King (JIRA)
create() method of container Bean implementations should be reproducible with user Bean implementations
-------------------------------------------------------------------------------------------------------
Key: WELD-313
URL: https://jira.jboss.org/jira/browse/WELD-313
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
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.
--
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
14 years, 11 months