-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start EMF eagerly to get early feedback
- Loading branch information
1 parent
ddc2a09
commit a70061f
Showing
3 changed files
with
89 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package org.jboss.shamrock.jpa.runtime; | ||
|
||
import org.hibernate.protean.Hibernate; | ||
import org.jboss.shamrock.jpa.runtime.cdi.SystemEntityManager; | ||
import org.jboss.shamrock.runtime.BeanContainer; | ||
import org.jboss.shamrock.runtime.ContextObject; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.enterprise.util.AnnotationLiteral; | ||
import javax.persistence.EntityManagerFactory; | ||
|
||
/** | ||
* @author Emmanuel Bernard [email protected] | ||
*/ | ||
|
@@ -22,4 +29,20 @@ public void enlistPersistenceUnit() { | |
public void callHibernateFeatureInit() { | ||
Hibernate.featureInit(); | ||
} | ||
|
||
public void boostrapPu(@ContextObject("bean.container") BeanContainer beanContainer, boolean synthetic) { | ||
//TODO: we need to take qualifiers into account, at the moment we can only have one EM, but this is probably fine for the PoC | ||
if(synthetic) { | ||
beanContainer.instance(EntityManagerFactory.class, new AnnotationLiteral<SystemEntityManager>() { | ||
|
||
@Override | ||
public Class<? extends Annotation> annotationType() { | ||
return SystemEntityManager.class; | ||
} | ||
}).getProperties(); | ||
} else { | ||
beanContainer.instance(EntityManagerFactory.class).getProperties(); | ||
} | ||
} | ||
|
||
} |