diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Name.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Name.java index 9f903ce..babbf2f 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Name.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/Name.java @@ -66,14 +66,14 @@ import javax.inject.Qualifier; *
  * public class NameConfig {
  * 
- * 	@Name("other.name.attrib")
+ * 	@AmbiguousQualifier("other.name.attrib")
  *   private int nameOfAttribute;
  *   ...
  * }
  * 
  * public class NameResourceBundle {
  * 
- * 	@Name("other.name.bundle")
+ * 	@AmbiguousQualifier("other.name.bundle")
  *   @Inject
  *   private ResourceBundle bundle;
  *   ...
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationParameter.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationParameter.java
index b35e6c8..b5b1330 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationParameter.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationParameter.java
@@ -60,7 +60,7 @@ import javax.enterprise.util.Nonbinding;
 public @interface OperationParameter {
 
 	/**
-	 * Name that will be used to publish this operation's parameter to clients.
+	 * AmbiguousQualifier that will be used to publish this operation's parameter to clients.
 	 */
 	@Nonbinding
 	String name();
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java
index 1d0ffd2..ec55a5a 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java
@@ -121,7 +121,7 @@ public class Management implements Serializable {
 	 *            A type annotated with {@link ManagementController}. This method will create an (or obtain an already
 	 *            created) instance of this type and invoke the operation over it.
 	 * @param actionName
-	 *            Name of method to be invoked, the type must have this operation on it's list
+	 *            AmbiguousQualifier of method to be invoked, the type must have this operation on it's list
 	 * @param params
 	 *            List of values for the operation parameters. Can be null if the operation require no
 	 *            parameters.
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java
index 09654f2..1196ab5 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java
@@ -89,7 +89,7 @@ public class LoggerProducer implements Serializable {
 			type = Reflections.forName(canonicalName);
 
 		} catch (ClassCastException cause) {
-			// TODO Colocar a mensgaem apropriada mostrando como utilizar a anotação @Name corretamente com a injeção de
+			// TODO Colocar a mensgaem apropriada mostrando como utilizar a anotação @AmbiguousQualifier corretamente com a injeção de
 			// Logger.
 			throw new DemoiselleException(null, cause);
 		}
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredPermissionInterceptor.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredPermissionInterceptor.java
index a2a788a..2ba6e76 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredPermissionInterceptor.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredPermissionInterceptor.java
@@ -99,12 +99,12 @@ public class RequiredPermissionInterceptor implements Serializable {
 	}
 
 	/**
-	 * Returns the resource defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
+	 * Returns the resource defined in {@code @RequiredPermission} annotation, the name defined in {@code @AmbiguousQualifier}
 	 * annotation or the class name itself
 	 * 
 	 * @param ic
 	 *            the {@code InvocationContext} in which the method is being called
-	 * @return the resource defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
+	 * @return the resource defined in {@code @RequiredPermission} annotation, the name defined in {@code @AmbiguousQualifier}
 	 *         annotation or the class name itself
 	 */
 	private String getResource(InvocationContext ic) {
@@ -127,12 +127,12 @@ public class RequiredPermissionInterceptor implements Serializable {
 	}
 
 	/**
-	 * Returns the operation defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
+	 * Returns the operation defined in {@code @RequiredPermission} annotation, the name defined in {@code @AmbiguousQualifier}
 	 * annotation or the method's name itself
 	 * 
 	 * @param ic
 	 *            the {@code InvocationContext} in which the method is being called
-	 * @return the operation defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
+	 * @return the operation defined in {@code @RequiredPermission} annotation, the name defined in {@code @AmbiguousQualifier}
 	 *         annotation or the method's name itself
 	 */
 	private String getOperation(InvocationContext ic) {
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
index c1175a8..da5bdd6 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
@@ -45,6 +45,7 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.AmbiguousResolutionException;
 import javax.enterprise.inject.spi.Annotated;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -64,7 +65,7 @@ import br.gov.frameworkdemoiselle.DemoiselleException;
 public final class Beans {
 
 	private static BeanManager beanManager = null;
-	
+
 	private Beans() {
 	}
 
@@ -75,7 +76,7 @@ public final class Beans {
 	public static BeanManager getBeanManager() {
 		return beanManager;
 	}
-	
+
 	/**
 	 * Obtains a injectble instance of a bean, which have the given required type and qualifiers, and are available for
 	 * injection in the point where this method was call.
@@ -161,11 +162,12 @@ public final class Beans {
 
 	@SuppressWarnings("unchecked")
 	private static  T getReference(Set> beans, Class beanClass, Annotation... qualifiers) {
-		Bean bean = beans.iterator().next();
-
-		// TODO Esta mudança só deve ser submetida com os testes passando. Esta mudança quebra os testes.
-		// Bean bean = getBeanManager().resolve( beans );
+		if (beans.size() > 1) {
+			String message = getBundle().getString("ambiguous-bean-resolution", beanClass.getName(), beans.toString());
+			throw new DemoiselleException(message, new AmbiguousResolutionException());
+		}
 
+		Bean bean = beans.iterator().next();
 		CreationalContext context = getBeanManager().createCreationalContext(bean);
 		Type beanType = beanClass == null ? bean.getBeanClass() : beanClass;
 		InjectionPoint injectionPoint = new CustomInjectionPoint(bean, beanType, qualifiers);
diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/NameQualifier.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/NameQualifier.java
index a0f1db2..5c36de4 100644
--- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/NameQualifier.java
+++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/util/NameQualifier.java
@@ -41,11 +41,11 @@ import javax.enterprise.util.AnnotationLiteral;
 import br.gov.frameworkdemoiselle.annotation.Name;
 
 /**
- * Creates a instance of an java annotation, specifically for qualification @Name. 
+ * Creates a instance of an java annotation, specifically for qualification @AmbiguousQualifier. 
  * This is required to get some classes by calling Beans.getReference method.
  * 
  * @see Beans
- * @see Name
+ * @see AmbiguousQualifier
  * 
  * @author SERPRO
  */
diff --git a/impl/core/src/main/resources/demoiselle-core-bundle.properties b/impl/core/src/main/resources/demoiselle-core-bundle.properties
index d06d244..7b01c11 100644
--- a/impl/core/src/main/resources/demoiselle-core-bundle.properties
+++ b/impl/core/src/main/resources/demoiselle-core-bundle.properties
@@ -37,6 +37,7 @@ engine-on=Ligando os motores do Demoiselle ${project.version}
 resource-not-found=Arquivo {0} n\u00E3o foi encontrado
 key-not-found=A chave {0} n\u00E3o foi encontrada
 ambiguous-strategy-resolution=Foi detectada ambiguidade da interface {0} com as seguintes implementa\u00E7\u00F5es\: {1}. Para resolver o conflito, defina explicitamente a implementa\u00E7\u00E3o no demoiselle.properties.
+ambiguous-bean-resolution=Falha ao obter {0} pois foi detectada ambiguidade nas seguintes implementa\u00E7\u00F5es\: {1}
 bean-not-found=Voc\u00EA est\u00E1 tentando obter um objeto n\u00E3o reconhecido pelo CDI via Beans.getReference({0})
 more-than-one-exceptionhandler-defined-for-same-class=Foi definido mais de um m\u00E9todo na classe {0} para tratar a exce\u00E7\u00E3o {1}
 handling-exception=Tratando a exce\u00E7\u00E3o {0}
diff --git a/impl/core/src/test/java/management/basic/ManagementTest.java b/impl/core/src/test/java/management/basic/ManagementTest.java
index e0719d6..f5907a6 100644
--- a/impl/core/src/test/java/management/basic/ManagementTest.java
+++ b/impl/core/src/test/java/management/basic/ManagementTest.java
@@ -72,13 +72,13 @@ public class ManagementTest {
 	@Test
 	public void readProperty() {
 		DummyManagedClass managedClass = Beans.getReference(DummyManagedClass.class);
-		managedClass.setName("Test Name");
+		managedClass.setName("Test AmbiguousQualifier");
 
 		// store é nossa extensão de gerenciamento falsa, então estamos testando um "cliente" acessando
 		// nosso tipo gerenciado DummyManagedClass remotamente.
 		ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
 		Object name = store.getProperty(DummyManagedClass.class, "name");
-		Assert.assertEquals("Test Name", name);
+		Assert.assertEquals("Test AmbiguousQualifier", name);
 	}
 
 	@Test
@@ -86,10 +86,10 @@ public class ManagementTest {
 		// store é nossa extensão de gerenciamento falsa, então estamos testando um "cliente" definindo
 		// um novo valor em uma propriedade de nosso tipo gerenciado DummyManagedClass remotamente.
 		ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
-		store.setProperty(DummyManagedClass.class, "name", "Test Name");
+		store.setProperty(DummyManagedClass.class, "name", "Test AmbiguousQualifier");
 
 		DummyManagedClass managedClass = Beans.getReference(DummyManagedClass.class);
-		Assert.assertEquals("Test Name", managedClass.getName());
+		Assert.assertEquals("Test AmbiguousQualifier", managedClass.getName());
 	}
 
 	@Test
diff --git a/impl/core/src/test/java/util/beans/ambiguous/AmbiguousBeansTest.java b/impl/core/src/test/java/util/beans/ambiguous/AmbiguousBeansTest.java
new file mode 100644
index 0000000..7caa6f4
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/AmbiguousBeansTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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 util.beans.ambiguous;
+
+import static junit.framework.Assert.assertEquals;
+
+import javax.enterprise.inject.AmbiguousResolutionException;
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import test.Tests;
+import br.gov.frameworkdemoiselle.DemoiselleException;
+import br.gov.frameworkdemoiselle.util.Beans;
+
+@RunWith(Arquillian.class)
+public class AmbiguousBeansTest {
+
+	@Deployment
+	public static JavaArchive createDeployment() {
+		JavaArchive deployment = Tests.createDeployment(AmbiguousBeansTest.class);
+		return deployment;
+	}
+
+	@Test
+	public void failOnAmbiguousBeansImplementationsTest() {
+		try {
+			Beans.getReference(Bean.class);
+		} catch (DemoiselleException cause) {
+			assertEquals(AmbiguousResolutionException.class, cause.getCause().getClass());
+		}
+	}
+
+	@Test
+	public void failOnAmbiguousQualifiedBeansImplementationsTest() {
+		try {
+			Beans.getReference(Bean.class, new AnnotationLiteral() {
+
+				private static final long serialVersionUID = 1L;
+			});
+		} catch (DemoiselleException cause) {
+			assertEquals(AmbiguousResolutionException.class, cause.getCause().getClass());
+		}
+	}
+
+	@Test
+	public void ambiguityResolvedByQualifiersTest() {
+		Bean bean;
+
+		bean = Beans.getReference(Bean.class, new AnnotationLiteral() {
+
+			private static final long serialVersionUID = 1L;
+		});
+		assertEquals(FirstValidQualifiedBean.class, bean.getClass());
+
+		bean = Beans.getReference(Bean.class, new AnnotationLiteral() {
+
+			private static final long serialVersionUID = 1L;
+		});
+		assertEquals(SecondValidQualifiedBean.class, bean.getClass());
+	}
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/AmbiguousQualifier.java b/impl/core/src/test/java/util/beans/ambiguous/AmbiguousQualifier.java
new file mode 100644
index 0000000..581f86a
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/AmbiguousQualifier.java
@@ -0,0 +1,57 @@
+/*
+ * 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 util.beans.ambiguous;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Inherited
+@Retention(RUNTIME)
+@Target({ TYPE, FIELD, METHOD, PARAMETER })
+public @interface AmbiguousQualifier {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/Bean.java b/impl/core/src/test/java/util/beans/ambiguous/Bean.java
new file mode 100644
index 0000000..0a591f6
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/Bean.java
@@ -0,0 +1,41 @@
+/*
+ * 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 util.beans.ambiguous;
+
+public interface Bean {
+	
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/FirstAmbiguousBean.java b/impl/core/src/test/java/util/beans/ambiguous/FirstAmbiguousBean.java
new file mode 100644
index 0000000..9ef6736
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/FirstAmbiguousBean.java
@@ -0,0 +1,41 @@
+/*
+ * 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 util.beans.ambiguous;
+
+public class FirstAmbiguousBean implements Bean {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/FirstAmbiguousQualifiedBean.java b/impl/core/src/test/java/util/beans/ambiguous/FirstAmbiguousQualifiedBean.java
new file mode 100644
index 0000000..a921daf
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/FirstAmbiguousQualifiedBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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 util.beans.ambiguous;
+
+@AmbiguousQualifier
+public class FirstAmbiguousQualifiedBean implements Bean {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/FirstValidQualifiedBean.java b/impl/core/src/test/java/util/beans/ambiguous/FirstValidQualifiedBean.java
new file mode 100644
index 0000000..64663e1
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/FirstValidQualifiedBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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 util.beans.ambiguous;
+
+@FirstValidQualifier
+public class FirstValidQualifiedBean implements Bean {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/FirstValidQualifier.java b/impl/core/src/test/java/util/beans/ambiguous/FirstValidQualifier.java
new file mode 100644
index 0000000..2bbf7bc
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/FirstValidQualifier.java
@@ -0,0 +1,57 @@
+/*
+ * 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 util.beans.ambiguous;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Inherited
+@Retention(RUNTIME)
+@Target({ TYPE, FIELD, METHOD, PARAMETER })
+public @interface FirstValidQualifier {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/SecondAmbiguousBean.java b/impl/core/src/test/java/util/beans/ambiguous/SecondAmbiguousBean.java
new file mode 100644
index 0000000..d9ffd10
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/SecondAmbiguousBean.java
@@ -0,0 +1,41 @@
+/*
+ * 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 util.beans.ambiguous;
+
+public class SecondAmbiguousBean implements Bean {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/SecondAmbiguousQualifiedBean.java b/impl/core/src/test/java/util/beans/ambiguous/SecondAmbiguousQualifiedBean.java
new file mode 100644
index 0000000..c451c23
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/SecondAmbiguousQualifiedBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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 util.beans.ambiguous;
+
+@AmbiguousQualifier
+public class SecondAmbiguousQualifiedBean implements Bean {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/SecondValidQualifiedBean.java b/impl/core/src/test/java/util/beans/ambiguous/SecondValidQualifiedBean.java
new file mode 100644
index 0000000..1d67d7a
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/SecondValidQualifiedBean.java
@@ -0,0 +1,42 @@
+/*
+ * 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 util.beans.ambiguous;
+
+@SecondValidQualifier
+public class SecondValidQualifiedBean implements Bean {
+
+}
diff --git a/impl/core/src/test/java/util/beans/ambiguous/SecondValidQualifier.java b/impl/core/src/test/java/util/beans/ambiguous/SecondValidQualifier.java
new file mode 100644
index 0000000..19ed40b
--- /dev/null
+++ b/impl/core/src/test/java/util/beans/ambiguous/SecondValidQualifier.java
@@ -0,0 +1,57 @@
+/*
+ * 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 util.beans.ambiguous;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Inherited
+@Retention(RUNTIME)
+@Target({ TYPE, FIELD, METHOD, PARAMETER })
+public @interface SecondValidQualifier {
+
+}
diff --git a/impl/core/src/test/java/util/beans/simple/Bean.java b/impl/core/src/test/java/util/beans/simple/Bean.java
index d3e207a..befc94a 100644
--- a/impl/core/src/test/java/util/beans/simple/Bean.java
+++ b/impl/core/src/test/java/util/beans/simple/Bean.java
@@ -37,6 +37,5 @@
 package util.beans.simple;
 
 public interface Bean {
-	
-	public void dummyMethod();
+
 }
diff --git a/impl/core/src/test/java/util/beans/simple/BeanImpl.java b/impl/core/src/test/java/util/beans/simple/BeanImpl.java
index 540f078..4bd0de4 100644
--- a/impl/core/src/test/java/util/beans/simple/BeanImpl.java
+++ b/impl/core/src/test/java/util/beans/simple/BeanImpl.java
@@ -36,12 +36,6 @@
  */
 package util.beans.simple;
 
-import br.gov.frameworkdemoiselle.annotation.Priority;
-
-@Priority(value = 1)
 public class BeanImpl implements Bean {
 
-	@Override
-	public void dummyMethod() {
-	}
 }
diff --git a/impl/core/src/test/java/util/beans/simple/NamedBean.java b/impl/core/src/test/java/util/beans/simple/NamedBean.java
index 744d729..7eb5b3f 100644
--- a/impl/core/src/test/java/util/beans/simple/NamedBean.java
+++ b/impl/core/src/test/java/util/beans/simple/NamedBean.java
@@ -38,6 +38,6 @@ package util.beans.simple;
 
 import javax.inject.Named;
 
-@Named("DummyClass")
+@Named
 public class NamedBean {
 }
diff --git a/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java b/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java
index e3763f3..41f9fd5 100644
--- a/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java
+++ b/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java
@@ -61,12 +61,12 @@ public class SimpleBeansTest {
 	}
 
 	@Test
-	public void beanClassTest() {
+	public void defaultBeanImplementationTest() {
 		assertEquals(BeanImpl.class, Beans.getReference(Bean.class).getClass());
 	}
 
 	@Test
-	public void beanClassExceptionTest() {
+	public void failOnGetBeanInterfaceWithoutImplementationTest() {
 		try {
 			Beans.getReference(AloneBean.class);
 			fail();
@@ -76,14 +76,14 @@ public class SimpleBeansTest {
 	}
 
 	@Test
-	public void beanNameTest() {
-		assertEquals(NamedBean.class, Beans.getReference("DummyClass").getClass());
+	public void validBeanNameTest() {
+		assertEquals(NamedBean.class, Beans.getReference("namedBean").getClass());
 	}
 
 	@Test
-	public void beanNameExceptionTest() {
+	public void invalidBeanNameTest() {
 		try {
-			Beans.getReference("NamedBean");
+			Beans.getReference("wrongNamedBean");
 			fail();
 		} catch (DemoiselleException cause) {
 			assertEquals(NoSuchElementException.class, cause.getCause().getClass());
diff --git a/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerProducer.java b/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerProducer.java
index fa05d7a..9e6cd51 100644
--- a/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerProducer.java
+++ b/impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/internal/producer/EntityManagerProducer.java
@@ -111,7 +111,7 @@ public class EntityManagerProducer implements Serializable{
 	/**
 	 * 
 	 * 

- * Factory that reads the {@link Name} qualifier and creates an entity manager with + * Factory that reads the {@link AmbiguousQualifier} qualifier and creates an entity manager with * a matching persistence unit name. *

* @@ -149,7 +149,7 @@ public class EntityManagerProducer implements Serializable{ * Uses persistence.xml to get informations about which persistence unit to use. Throws DemoiselleException if more * than one Persistence Unit is defined. * - * @return Persistence Unit Name + * @return Persistence Unit AmbiguousQualifier */ private String getFromXML() { Set persistenceUnits = factory.getCache().keySet(); -- libgit2 0.21.2