You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2013/02/26 12:45:59 UTC

[1/3] git commit: DELTASPIKE-315 add more JavaDoc

DELTASPIKE-315 add more JavaDoc


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/4f8fa5ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/4f8fa5ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/4f8fa5ff

Branch: refs/heads/master
Commit: 4f8fa5ff72b1ae2ef4a5c2e4be4f9c8f749da9bb
Parents: e4e85d3
Author: Mark Struberg <st...@apache.org>
Authored: Tue Feb 26 09:23:41 2013 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Tue Feb 26 09:36:17 2013 +0100

----------------------------------------------------------------------
 .../jpa/api/entitymanager/PersistenceUnitName.java |    2 +-
 .../EntityManagerFactoryProducer.java              |   29 ++++++++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/4f8fa5ff/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java b/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
index 45e9458..5d16153 100644
--- a/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
+++ b/deltaspike/modules/jpa/api/src/main/java/org/apache/deltaspike/test/jpa/api/entitymanager/PersistenceUnitName.java
@@ -35,7 +35,7 @@ import static java.lang.annotation.ElementType.TYPE;
  * EntityManagerFactoryProducer.
  */
 @Target( { TYPE, METHOD, PARAMETER, FIELD })
-@Retention(value= RetentionPolicy.RUNTIME)
+@Retention(value = RetentionPolicy.RUNTIME)
 @Documented
 @Qualifier
 public @interface PersistenceUnitName

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/4f8fa5ff/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
index 05129f3..002e28c 100644
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/entitymanager/EntityManagerFactoryProducer.java
@@ -32,7 +32,32 @@ import org.apache.deltaspike.test.jpa.api.entitymanager.PersistenceUnitName;
 
 
 /**
- *  TODO
+ * <p>Built in support for injecting EntityManagerFactories into own beans.
+ * The injection point must use the Qualifier {@link PersistenceUnitName}
+ * to express the desired persistence unit name.</p>
+ *
+ * <p>The EntityManagerFactory for the given persistence unit will be produced
+ * as &#064;Dependent scoped. It can be used to easily implement own
+ * EntityManagerProviders as shown in the following example which provides
+ * a producer according to the entitymanager-per-request design pattern:</p>
+ * <pre>
+ * &#064;ApplicationScoped
+ * public class SampleEntityManagerProducer {
+ *   &#064;Inject
+ *   &#064;PersistenceUnitName("testPersistenceUnit")
+ *   private EntityManagerFactory emf;
+ *
+ *   &#064;Produces
+ *   &#064;RequestScoped
+ *   public EntityManager createEntityManager() {
+ *     return emf.createEntityManager();
+ *   }
+ *
+ *   public void closeEm(&#064;Disposes EntityManager em) {
+ *     em.close();
+ *   }
+ * }
+ *  </pre>
  */
 public class EntityManagerFactoryProducer
 {
@@ -44,7 +69,7 @@ public class EntityManagerFactoryProducer
 
     @Produces
     @Dependent
-    @PersistenceUnitName("any") // the value is nonbinding, thus this is just a dummy parameter here
+    @PersistenceUnitName("any") // the value is nonbinding, thus 'any' is just a dummy parameter here
     public EntityManagerFactory createEntityManagerFactoryForUnit(InjectionPoint injectionPoint)
     {
         PersistenceUnitName unitNameAnnotation = injectionPoint.getAnnotated().getAnnotation(PersistenceUnitName.class);