[jboss-dev-forums] [JBoss AS7 Development] - EJB3/JPA 2.0 support for AS-7

Scott Marlow do-not-reply at jboss.com
Wed Jan 5 23:12:17 EST 2011


Scott Marlow [http://community.jboss.org/people/smarlow%40redhat.com] created the document:

"EJB3/JPA 2.0 support for AS-7"

To view the document, visit: http://community.jboss.org/docs/DOC-16271

--------------------------------------------------------------
This is about how the AS-7 JPA layer and related concerns. 

1. Container-managed persistence      context
1. Transaction scope (JPA 7.6.1)
1. Transaction active invocation
1. Persistence context is created                     if none already associated with transaction
2. Created persistence context                     ends when transaction ends
3. An extended persistence context                     can also be used, which survives when transaction ends.
 
2. No transaction invocation
1. Loaded entities are detached at                     end of method call.
 
 
2. Extended scope (JPA 7.6.2)
1. Only supported for stateful                session beans.
2. Entity modifications can be made                outside of a transaction and are applied on the next joined                transaction (anywhere on the cluster).
3. Extended persistence context                (XPC) is created when stateful bean that depends on a XPC is                created.
4. XPC is closed when dependent                session bean(s) are closed (via @remove method).
5. Inheritance
1. Stateful beans that create                     other (local) stateful beans, share the same XPC.
 
 
3. Persistence context propagation           (JPA 7.6.3)
1. A persistence context will be                propagated to multiple entity managers (instances) within the same                local transaction.
2. Remote invocations do not                propagate the persistence context.
 
4. Persistence context propagation           requirements for component invocations (JPA 7.6.3.1)
1. no propagation if component is                invoked without a JTA transaction or without the JTA transaction                propagating:
1. Transaction scoped entity                     manager used within the invoked component, will create a new                     persistence context.
2. Extended scoped entity manager                     used within the invoked component, will use the XPC already bound                     to the (invoked stateful) bean.
3. If the entity manager is                     invoked within a JTA transaction, the persistence context is                     bound to the JTA transaction.
 
2. If a component is invoked and                the JTA transaction is propagated into the component:
1. If (SFSB) component has a XPC                     and the transaction already has a different persistence context                     associated with it, an EJBException is thrown by the container.
2. If a persistence context is                     bound to the JTA transaction, it is propagated into any entity                     managers used in the invocation.
 
 
 
2. Container requirements review
1. Application-managed persistence           context (JPA 7.8.1)
1. Container needs to inject entity                manager factory into jndi for application use.
2. Must use                PersistenceProvider.createContainerEntityManagerFactory method for                3^rd^ party support.  Internal APIs are fine for our                persistence provider.
3. Must use                EntityManagerFactory.close method to close the entity manager                factory prior to shutdown (again for 3^rd^ party                support).
 
2. Container-managed persistence           context (JPA 7.9.1)
1. For 3^rd^ party                support, use EntityManagerFactory.createEntityManager .  Consider                using  for our persistence provider as well.
2. May pass (PersistenceProperty (http://download.oracle.com/javaee/6/api/javax/persistence/PersistenceProperty.html)[])                PersistenceContext.properties to                EntityManagerFactory.createEntityManager(Map map) .
3. Container EM wrapper could                implement some EntityManager.unwrap(Class<T> cls) calls but                should default to underlying EM for unhandled classes.
 
 
3. Deployment
1. Extract persistence metadata from           persistence.xml
2. Determine the           PersistenceProvider  classname for each persistence unit (PU).  The           default class is currently org.hibernate.ejb.HibernatePersistence.
3. Invoke the           PersistenceProvider.createContainerEntityManagerFactory(PersistenceUnitInfo,           Map) to create the EMF that will be used to create all           EntityManager's for the PU.  The properties read from the PU are           passed as the second parameter.
4. Also pass the           “javax.persistence.validation.factory ” property if validation           mode is not set to NONE.  The validator factory value appears to be           org.hibernate.validator.engine.ValidatorFactoryImpl.  Consult           ValidatorFactoryProvider which is currently used to bootstrap the           validator factory in AS6.
5. The PU classes shouldn't be           loaded until after the EMF is created.
6. The EntityManagerFactory is           closed at undeploy time, which also closes all EntityManager's           opened by each factory.
7. Switchboard changes for PU +           PC???
 
4. Clustering
1. Determine impact on            http://community.jboss.org/docs/DOC-13822 http://community.jboss.org/wiki/OptimizingentityandXPCreplication which may need to be tweaked for clustering other persistence           providers.  Judging by the jira status, this optimization is not in           place yet (although the Hibernate persistence provider jira           HHH-2762 is done).
2. Determine impact on            http://community.jboss.org/docs/DOC-9565 http://community.jboss.org/wiki/DevEJB3NewSFSBCache (consider support for other persistence providers).
 
5. Weld integration      (JpaInjectionServices implementation is wired in at boot time)
--------------------------------------------------------------

Comment by going to Community
[http://community.jboss.org/docs/DOC-16271]

Create a new document in JBoss AS7 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110105/3b1e3f9b/attachment.html 


More information about the jboss-dev-forums mailing list