Search in sources :

Example 1 with PersistenceUnitName

use of org.apache.deltaspike.jpa.api.entitymanager.PersistenceUnitName in project deltaspike by apache.

the class EntityManagerFactoryProducer method createEntityManagerFactoryForUnit.

@Produces
@Dependent
// the value is nonbinding, thus 'any' is just a dummy parameter here
@PersistenceUnitName("any")
public EntityManagerFactory createEntityManagerFactoryForUnit(InjectionPoint injectionPoint) {
    PersistenceUnitName unitNameAnnotation = injectionPoint.getAnnotated().getAnnotation(PersistenceUnitName.class);
    if (unitNameAnnotation == null) {
        LOG.warning("@PersisteneUnitName annotation could not be found at EntityManagerFactory injection point!");
        return null;
    }
    String unitName = unitNameAnnotation.value();
    Properties properties = persistenceConfigurationProvider.getEntityManagerFactoryConfiguration(unitName);
    EntityManagerFactory emf = Persistence.createEntityManagerFactory(unitName, properties);
    return emf;
}
Also used : PersistenceUnitName(org.apache.deltaspike.jpa.api.entitymanager.PersistenceUnitName) EntityManagerFactory(javax.persistence.EntityManagerFactory) Properties(java.util.Properties) PersistenceUnitName(org.apache.deltaspike.jpa.api.entitymanager.PersistenceUnitName) Produces(javax.enterprise.inject.Produces) Dependent(javax.enterprise.context.Dependent)

Aggregations

Properties (java.util.Properties)1 Dependent (javax.enterprise.context.Dependent)1 Produces (javax.enterprise.inject.Produces)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 PersistenceUnitName (org.apache.deltaspike.jpa.api.entitymanager.PersistenceUnitName)1