[jboss-as7-dev] [EE7/JPA 2.1] Question about accessing the CDI BeanManager for a component on AS7 or later...

Steve Ebersole steve at hibernate.org
Wed Aug 22 10:01:26 EDT 2012


Do you at least know if a BeanManager needs to be passed?  If so, I do 
not actually use the BeanManager instance until much later (second 
phase in our new vernacular); so an option if you do actually know 
whether you need to pass the BeanManager or not  would be to pass a 
BeanManager proxy that does the lookup on demand.

On Wed 22 Aug 2012 08:49:23 AM CDT, Scott Marlow wrote:
> I would like to give feedback to the JPA 2.1 EG, on the entity
> listener enhancement to support CDI.  If the deployment archive that
> contains the persistence unit, is a bean archive, the BeanManager
> needs to be passed in as a property when creating the persistence unit
> service.  The persistence provider will use the BeanManager to create
> instances of the entity listener classes, do injection and trigger
> lifecycle methods.
>
> Currently, the only way to get the CDI BeanManager in AS7, is doing a
> "java:comp/BeanManager" lookup (not helpful during deployment) or via
> the BeanManagerService.  I tried to have the PersistenceUnitService
> depend on the BeanManagerService, but couldn't start the
> PersistenceUnitService  service (got a
> "org.jboss.msc.service.CircularDependencyException: Service jboss-as
> has a circular dependency" http://pastie.org/4565684).
>
> I'll also need to get access to the BeanManager earlier than the
> install phase.  I need to pass the BeanManager as a property to the
> PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo,
> Map) invocation which might occur early (if class transformers will
> rewrite application classes before they are loaded).
>
> I could avoid having the PU service depend on the BeanManagerService
> if I instead arrange for the PU service to get the BeanManager from
> the deployment unit (if available).  However, if the
> BeanManagerService is stopped, the pu service wouldn't be stopped if
> we have a direct reference to the BeanManager.  So, this (deployment
> unit) hack sounds less than ideal.
>
> Git branch
> https://github.com/scottmarlow/jboss-as/tree/seven_jpa2_1_BeanManager
> integrates with the latest Hibernate master branch (Hibernate needs to
> be built locally) and has the currently broken BeanManager access code
> (gets the CircularDependencyException during deployment).
>
> Scott

--
steve at hibernate.org
http://hibernate.org


More information about the jboss-as7-dev mailing list