[jboss-jira] [JBoss JIRA] (WFLY-1322) CDI BeanManager (WeldBeanManagerServiceProcessor) needs to be created during Phase.FIRST_MODULE_USE for applications that have JPA classes that are rewritten/enhanced during deployment
Scott Marlow (JIRA)
jira-events at lists.jboss.org
Tue May 7 20:07:53 EDT 2013
[ https://issues.jboss.org/browse/WFLY-1322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772875#comment-12772875 ]
Scott Marlow commented on WFLY-1322:
------------------------------------
Good point. Does Weld load deployment classes at the time that the deployment bean manager is created?
>From what your saying, it sounds like JPA deployment can either allow entity class rewriting (register JPA transformers during Phase.FIRST_MODULE_USE phase) or pass the CDI bean manager in (for entity listeners).
Background information:
{quote}
JPA 2.1 section 9.1 EE deployment
...
If the containing archive of the persistence unit is a bean archive, a BeanManager instance must be made available by the container. The container is responsible for passing this BeanManager instance via the map that is passed as an argument to the createContainerEntityManagerFactory call. The map key used must be the standard property name javax.persistence.bean.manager.
{quote}
This in turn allows the persistence provider to handle:
{quote}
JPA 2.1 section 3.5.1 Entity Listeners
...
The persistence provider is only required to support CDI injection into entity listeners in Java EE container environments[43]. If the containing archive is not a bean archive, the BeanManager will not be available, and the persistence provider must not invoke entity listeners that depend upon CDI injection.
An entity listener is a noncontextual object. In supporting injection into entity listeners, the persistence provider must behave as if it carries out the following steps involving the use of the CDI SPI. (See [10] and [11]).
* Obtain a BeanManager instance. (See section 9.1.)
* Create an AnnotatedType instance for the entity listener class.
* Create an InjectionTarget instance for the annotated type.
* Create a CreationalContext.
* Instantiate the listener by calling the InjectionTarget produce method.
* Inject the listener instance by calling the InjectionTarget inject method on the instance.
* Invoke the PostConstruct callback, if any, by calling the InjectionTarget postConstruct method on the instance.
...
{quote}
> CDI BeanManager (WeldBeanManagerServiceProcessor) needs to be created during Phase.FIRST_MODULE_USE for applications that have JPA classes that are rewritten/enhanced during deployment
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WFLY-1322
> URL: https://issues.jboss.org/browse/WFLY-1322
> Project: WildFly
> Issue Type: Feature Request
> Components: CDI / Weld
> Affects Versions: 8.0.0.Alpha2
> Reporter: Scott Marlow
> Assignee: Stuart Douglas
>
> The JPA deployment subsystem, needs to pass a (deployment) CDI bean manager instance into the persistence provider, when creating the (container) entity manager factory.
> If JPA detects that classfile enhancing might be needed for the persistence units classes, the entity manager factory is created during the Phase.FIRST_MODULE_USE phase (so that JPA transformers can be registered before any deployer accesses the deployment classloader).
> If JPA classfile rewriting is not needed, the entity manager factory is created during the Phase.INSTALL phase.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list