Author: swd847
Date: 2010-02-02 04:54:45 -0500 (Tue, 02 Feb 2010)
New Revision: 5707
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/managed/newBean/NewSimpleBeanTest.java
Log:
WELD-409
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployerEnvironment.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -53,12 +53,13 @@
import org.jboss.weld.resolution.ResolvableFactory;
import org.jboss.weld.resolution.TypeSafeDisposerResolver;
import org.jboss.weld.resources.ClassTransformer;
+import org.jboss.weld.util.AnnotatedTypes;
public class BeanDeployerEnvironment
{
private final Map<WeldClass<?>, AbstractClassBean<?>> classBeanMap;
- private final Map<WeldMethod<?, ?>, ProducerMethod<?, ?>>
producerMethodBeanMap;
+ private final Map<WeldMethodKey<?, ?>, ProducerMethod<?, ?>>
producerMethodBeanMap;
private final Set<RIBean<?>> beans;
private final Set<ObserverMethodImpl<?, ?>> observers;
private final List<DisposalMethod<?, ?>> allDisposalBeans;
@@ -74,7 +75,7 @@
public BeanDeployerEnvironment(EjbDescriptors ejbDescriptors, BeanManagerImpl
manager)
{
this.classBeanMap = new HashMap<WeldClass<?>,
AbstractClassBean<?>>();
- this.producerMethodBeanMap = new HashMap<WeldMethod<?, ?>,
ProducerMethod<?, ?>>();
+ this.producerMethodBeanMap = new HashMap<WeldMethodKey<?, ?>,
ProducerMethod<?, ?>>();
this.allDisposalBeans = new ArrayList<DisposalMethod<?, ?>>();
this.resolvedDisposalBeans = new HashSet<DisposalMethod<?, ?>>();
this.beans = new HashSet<RIBean<?>>();
@@ -100,13 +101,14 @@
public <X, T> ProducerMethod<X, T> getProducerMethod(WeldMethod<X,
T> method)
{
- if (!producerMethodBeanMap.containsKey(method))
+ WeldMethodKey<X, T> key = new WeldMethodKey<X, T>(method);
+ if (!producerMethodBeanMap.containsKey(key))
{
return null;
}
else
{
- ProducerMethod<?, ?> bean = producerMethodBeanMap.get(method);
+ ProducerMethod<?, ?> bean = producerMethodBeanMap.get(key);
bean.initialize(this);
return (ProducerMethod<X, T>) bean;
}
@@ -128,7 +130,7 @@
public void addProducerMethod(ProducerMethod<?, ?> bean)
{
- producerMethodBeanMap.put(bean.getWeldAnnotated(), bean);
+ producerMethodBeanMap.put(new WeldMethodKey(bean.getWeldAnnotated()), bean);
addAbstractBean(bean);
}
@@ -290,4 +292,31 @@
return Collections.unmodifiableSet(beans);
}
+ private static class WeldMethodKey<T, X>
+ {
+ final WeldMethod meth;
+
+ WeldMethodKey(WeldMethod<T, X> meth)
+ {
+ this.meth = meth;
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof WeldMethodKey<?, ?>)
+ {
+ WeldMethodKey<?, ?> o = (WeldMethodKey<?, ?>) other;
+ return AnnotatedTypes.compareAnnotatedCallable(meth, o.meth);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return meth.getJavaMember().hashCode();
+ }
+ }
+
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -46,6 +46,7 @@
import org.jboss.weld.introspector.WeldParameter;
import org.jboss.weld.logging.messages.ReflectionMessage;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.AnnotatedTypes;
public class ConstructorInjectionPoint<T> extends
ForwardingWeldConstructor<T> implements WeldInjectionPoint<T,
Constructor<T>>, Serializable
{
@@ -86,6 +87,20 @@
}
@Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ConstructorInjectionPoint<?>)
+ {
+ ConstructorInjectionPoint<?> ip = (ConstructorInjectionPoint<?>)
obj;
+ if (AnnotatedTypes.compareAnnotatedCallable(constructor, ip.constructor))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
protected WeldConstructor<T> delegate()
{
return constructor;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -42,6 +42,7 @@
import org.jboss.weld.introspector.WeldField;
import org.jboss.weld.logging.messages.ReflectionMessage;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.AnnotatedTypes;
public class FieldInjectionPoint<T, X> extends ForwardingWeldField<T, X>
implements WeldInjectionPoint<T, Field>, Serializable
{
@@ -64,6 +65,20 @@
}
@Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof FieldInjectionPoint<?, ?>)
+ {
+ FieldInjectionPoint<?, ?> ip = (FieldInjectionPoint<?, ?>) obj;
+ if (AnnotatedTypes.compareAnnotatedField(field, ip.field))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
protected WeldField<T, X> delegate()
{
return field;
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -43,6 +43,7 @@
import org.jboss.weld.introspector.WeldParameter;
import org.jboss.weld.logging.messages.ReflectionMessage;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.AnnotatedTypes;
public class MethodInjectionPoint<T, X> extends ForwardingWeldMethod<T, X>
implements WeldInjectionPoint<T, Method>
{
@@ -83,6 +84,20 @@
}
@Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof MethodInjectionPoint<?, ?>)
+ {
+ MethodInjectionPoint<?, ?> ip = (MethodInjectionPoint<?, ?>) obj;
+ if (AnnotatedTypes.compareAnnotatedCallable(method, ip.method))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
protected WeldMethod<T, X> delegate()
{
return method;
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -67,6 +67,20 @@
}
@Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ParameterInjectionPoint<?, ?>)
+ {
+ ParameterInjectionPoint<?, ?> ip = (ParameterInjectionPoint<?, ?>)
obj;
+ if
(parameter.getDeclaringWeldCallable().getJavaMember().equals(ip.parameter.getDeclaringWeldCallable().getJavaMember())
&& parameter.getAnnotations().equals(ip.parameter.getAnnotations()) &&
parameter.getPosition() == ip.parameter.getPosition())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
protected WeldParameter<T, X> delegate()
{
return parameter;
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -23,7 +23,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -207,34 +206,6 @@
}
/**
- * Compares two AbstractAnnotatedItems
- *
- * @param other The other item
- * @return True if equals, false otherwise
- */
- @Override
- public boolean equals(Object other)
- {
- if (other instanceof WeldAnnotated<?, ?>)
- {
- WeldAnnotated<?, ?> that = (WeldAnnotated<?, ?>) other;
- return this.getAnnotations().equals(that.getAnnotations()) &&
this.getJavaClass().equals(that.getJavaClass()) &&
this.getActualTypeArguments().length == that.getActualTypeArguments().length &&
Arrays.equals(this.getActualTypeArguments(), that.getActualTypeArguments());
- }
- return false;
- }
-
- /**
- * Gets the hash code of the actual type
- *
- * @return The hash code
- */
- @Override
- public int hashCode()
- {
- return getJavaClass().hashCode();
- }
-
- /**
* Indicates if the type is proxyable to a set of pre-defined rules
*
* @return True if proxyable, false otherwise.
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -47,7 +47,6 @@
import org.jboss.weld.introspector.WeldField;
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.util.AnnotatedTypes;
import org.jboss.weld.util.Names;
import org.jboss.weld.util.collections.HashSetSupplier;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
@@ -366,17 +365,6 @@
}
}
- @Override
- public boolean equals(Object other)
- {
- if (other instanceof WeldClassImpl<?>)
- {
- WeldClassImpl<?> that = (WeldClassImpl<?>) other;
- return AnnotatedTypes.compareAnnotatedTypes(this, that) &&
this.getActualTypeArguments().length == that.getActualTypeArguments().length &&
Arrays.equals(this.getActualTypeArguments(), that.getActualTypeArguments());
- }
- return false;
- }
-
/**
* Gets the implementing class
*
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -276,19 +276,6 @@
}
/**
- * The overridden hashcode
- *
- * Gets the hash code from the delegate
- *
- * @return The hash code
- */
- @Override
- public int hashCode()
- {
- return getDelegate().hashCode();
- }
-
- /**
* Gets a string representation of the constructor
*
* @return A string representation
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -135,24 +135,4 @@
return new StringBuilder().append("field
").append(getDeclaringType().getName()).append(".").append(field.getName()).toString();
}
- @Override
- public boolean equals(Object other)
- {
- if (super.equals(other) && other instanceof WeldField<?, ?>)
- {
- WeldField<?, ?> that = (WeldField<?, ?>) other;
- return this.getJavaMember().equals(that.getJavaMember());
- }
- else
- {
- return false;
- }
- }
-
- @Override
- public int hashCode()
- {
- return getDelegate().hashCode();
- }
-
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -187,30 +187,11 @@
return Collections.unmodifiableList(annotatedParameters.get(annotationType));
}
- @Override
- public boolean equals(Object other)
- {
- if (super.equals(other) && other instanceof WeldMethod)
- {
- WeldMethod<?, ?> that = (WeldMethod<?, ?>) other;
- return this.getJavaMember().equals(that.getJavaMember()) &&
this.getWeldParameters().equals(that.getWeldParameters());
- }
- else
- {
- return false;
- }
- }
-
public boolean isEquivalent(Method method)
{
return this.getDeclaringType().isEquivalent(method.getDeclaringClass()) &&
this.getName().equals(method.getName()) &&
Arrays.equals(this.getParameterTypesAsArray(), method.getParameterTypes());
}
- @Override
- public int hashCode()
- {
- return getDelegate().hashCode();
- }
public T invokeOnInstance(Object instance, Object... parameters) throws
IllegalArgumentException, SecurityException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException
{
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/managed/newBean/NewSimpleBeanTest.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/managed/newBean/NewSimpleBeanTest.java 2010-02-02
09:00:53 UTC (rev 5706)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/managed/newBean/NewSimpleBeanTest.java 2010-02-02
09:54:45 UTC (rev 5707)
@@ -26,6 +26,7 @@
import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.literal.NewLiteral;
import org.jboss.weld.test.AbstractWeldTest;
+import org.jboss.weld.util.AnnotatedTypes;
import org.testng.annotations.Test;
@Artifact
@@ -65,7 +66,7 @@
public void testNewBeanHasSameConstructorAsWrappedBean()
{
initNewBean();
- assert wrappedSimpleBean.getConstructor().equals(newSimpleBean.getConstructor());
+ assert AnnotatedTypes.compareAnnotatedCallable(wrappedSimpleBean.getConstructor(),
newSimpleBean.getConstructor());
}
@Test(groups = { "new" })