diff --git a/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerFactoryProducer.java b/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerFactoryProducer.java
index a905b68..dc2848a 100644
--- a/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerFactoryProducer.java
+++ b/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerFactoryProducer.java
@@ -1,3 +1,39 @@
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
package br.gov.frameworkdemoiselle.internal.producer;
import java.io.Serializable;
@@ -9,6 +45,9 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
@@ -23,6 +62,7 @@ import org.w3c.dom.NodeList;
import br.gov.frameworkdemoiselle.DemoiselleException;
import br.gov.frameworkdemoiselle.annotation.Name;
+import br.gov.frameworkdemoiselle.internal.configuration.EntityManagerConfig;
import br.gov.frameworkdemoiselle.util.ResourceBundle;
@ApplicationScoped
@@ -32,17 +72,39 @@ public class EntityManagerFactoryProducer implements Serializable {
private static final long serialVersionUID = 1L;
private static final String ENTITY_MANAGER_RESOURCE = "META-INF/persistence.xml";
-
+
@Inject
- private Logger logger;
+ protected Logger logger;
@Inject
@Name("demoiselle-jpa-bundle")
- private ResourceBundle bundle;
+ protected ResourceBundle bundle;
+
+ @Inject
+ private Persistences persistenceUnitReader;
private final Map> factoryCache = Collections
.synchronizedMap(new HashMap>());
+
+ @Default
+ @Produces
+ protected EntityManagerFactory createDefault(EntityManagerConfig config) {
+ String persistenceUnit = persistenceUnitReader.getFromProperties(config);
+
+ if (persistenceUnit == null) {
+ persistenceUnit = persistenceUnitReader.getFromXML();
+ }
+ return create(persistenceUnit);
+ }
+
+ @Name("")
+ @Produces
+ protected EntityManagerFactory createNamed(InjectionPoint ip) {
+ String persistenceUnit = ip.getAnnotated().getAnnotation(Name.class).value();
+ return create(persistenceUnit);
+ }
+
public EntityManagerFactory create(String persistenceUnit) {
EntityManagerFactory factory;
--
libgit2 0.21.2