Weld SVN: r6145 - extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-04-21 22:13:38 -0400 (Wed, 21 Apr 2010)
New Revision: 6145
Removed:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
Log:
revert previous changes, as the IdentityWrappers would be gc'ed to early
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-22 02:02:14 UTC (rev 6144)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-22 02:13:38 UTC (rev 6145)
@@ -20,7 +20,7 @@
*/
public class IdentifiableBeanExtension implements Extension
{
- Map<IdentityWrapper, AnnotatedType<?>> types = Collections.synchronizedMap(new WeakHashMap<IdentityWrapper, AnnotatedType<?>>(1000));
+ Map<Object, AnnotatedType<?>> types = Collections.synchronizedMap(new WeakHashMap<Object, AnnotatedType<?>>(1000));
public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
{
@@ -55,7 +55,7 @@
public AnnotatedType<?> getAnnotatedType(Object instance)
{
- return types.get(new IdentityWrapper(instance));
+ return types.get(instance);
}
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-22 02:02:14 UTC (rev 6144)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-22 02:13:38 UTC (rev 6145)
@@ -20,9 +20,9 @@
AnnotatedType<?> type;
- Map<IdentityWrapper, AnnotatedType<?>> typeMap;
+ Map<Object, AnnotatedType<?>> typeMap;
- IdentifiableInjectionTarget(InjectionTarget<T> delegate, AnnotatedType<?> type, Map<IdentityWrapper, AnnotatedType<?>> typeMap)
+ IdentifiableInjectionTarget(InjectionTarget<T> delegate, AnnotatedType<?> type, Map<Object, AnnotatedType<?>> typeMap)
{
this.delegate = delegate;
this.type=type;
@@ -32,7 +32,7 @@
public void inject(T instance, CreationalContext<T> ctx)
{
- typeMap.put(new IdentityWrapper(instance), type);
+ typeMap.put(instance, type);
delegate.inject(instance, ctx);
}
@@ -48,7 +48,7 @@
public void dispose(T instance)
{
- typeMap.remove(new IdentityWrapper(instance));
+ typeMap.remove(instance);
delegate.dispose(instance);
}
Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java 2010-04-22 02:02:14 UTC (rev 6144)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java 2010-04-22 02:13:38 UTC (rev 6145)
@@ -1,40 +0,0 @@
-package org.jboss.weld.extensions.beanid;
-
-/**
- * wrapper that overrides equals and hashCode to work on object identity
- *
- *
- * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
- *
- */
-public class IdentityWrapper
-{
- final Object object;
-
- public IdentityWrapper(Object object)
- {
- this.object = object;
- }
-
- public Object getObject()
- {
- return object;
- }
-
- @Override
- public boolean equals(Object arg0)
- {
- if (arg0 instanceof IdentityWrapper)
- {
- IdentityWrapper w = (IdentityWrapper) arg0;
- return w.getObject() == object;
- }
- return object == arg0;
- }
-
- @Override
- public int hashCode()
- {
- return System.identityHashCode(object);
- }
-}
14 years, 8 months
Weld SVN: r6144 - extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-04-21 22:02:14 -0400 (Wed, 21 Apr 2010)
New Revision: 6144
Added:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
Log:
updated bean id to work on object identity, so beans that implement equals/hashCode will not break it
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-22 00:18:01 UTC (rev 6143)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-22 02:02:14 UTC (rev 6144)
@@ -20,7 +20,7 @@
*/
public class IdentifiableBeanExtension implements Extension
{
- Map<Object, AnnotatedType<?>> types = Collections.synchronizedMap(new WeakHashMap<Object, AnnotatedType<?>>(1000));
+ Map<IdentityWrapper, AnnotatedType<?>> types = Collections.synchronizedMap(new WeakHashMap<IdentityWrapper, AnnotatedType<?>>(1000));
public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
{
@@ -55,7 +55,7 @@
public AnnotatedType<?> getAnnotatedType(Object instance)
{
- return types.get(instance);
+ return types.get(new IdentityWrapper(instance));
}
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-22 00:18:01 UTC (rev 6143)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-22 02:02:14 UTC (rev 6144)
@@ -8,7 +8,8 @@
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
/**
- * wrapper around InjectionTarget that sets a bean id
+ * wrapper around InjectionTarget that maps the instance to it's annotated type
+ *
* @author Stuart Douglas <stuart(a)baileyroberts.com.au>
*
* @param <T>
@@ -19,9 +20,9 @@
AnnotatedType<?> type;
- Map<Object, AnnotatedType<?>> typeMap;
+ Map<IdentityWrapper, AnnotatedType<?>> typeMap;
- IdentifiableInjectionTarget(InjectionTarget<T> delegate, AnnotatedType<?> type,Map<Object, AnnotatedType<?>> typeMap)
+ IdentifiableInjectionTarget(InjectionTarget<T> delegate, AnnotatedType<?> type, Map<IdentityWrapper, AnnotatedType<?>> typeMap)
{
this.delegate = delegate;
this.type=type;
@@ -31,7 +32,7 @@
public void inject(T instance, CreationalContext<T> ctx)
{
- typeMap.put(instance, type);
+ typeMap.put(new IdentityWrapper(instance), type);
delegate.inject(instance, ctx);
}
@@ -47,7 +48,7 @@
public void dispose(T instance)
{
- typeMap.remove(instance);
+ typeMap.remove(new IdentityWrapper(instance));
delegate.dispose(instance);
}
Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentityWrapper.java 2010-04-22 02:02:14 UTC (rev 6144)
@@ -0,0 +1,40 @@
+package org.jboss.weld.extensions.beanid;
+
+/**
+ * wrapper that overrides equals and hashCode to work on object identity
+ *
+ *
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ */
+public class IdentityWrapper
+{
+ final Object object;
+
+ public IdentityWrapper(Object object)
+ {
+ this.object = object;
+ }
+
+ public Object getObject()
+ {
+ return object;
+ }
+
+ @Override
+ public boolean equals(Object arg0)
+ {
+ if (arg0 instanceof IdentityWrapper)
+ {
+ IdentityWrapper w = (IdentityWrapper) arg0;
+ return w.getObject() == object;
+ }
+ return object == arg0;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return System.identityHashCode(object);
+ }
+}
14 years, 8 months
Weld SVN: r6143 - extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-04-21 20:18:01 -0400 (Wed, 21 Apr 2010)
New Revision: 6143
Modified:
extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java
extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java
Log:
minor
Modified: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java 2010-04-22 00:13:06 UTC (rev 6142)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java 2010-04-22 00:18:01 UTC (rev 6143)
@@ -2,11 +2,5 @@
@IdentifiableInterceptorBinding
public class IdentifiableBean
{
- Class atClass;
- boolean bindingFound = false;
-
- public void someMethod()
- {
-
- }
+
}
Modified: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java 2010-04-22 00:13:06 UTC (rev 6142)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java 2010-04-22 00:18:01 UTC (rev 6143)
@@ -16,7 +16,6 @@
@Test
public void testBeanIdentifiers()
{
- //TODO: This needs to be split up into lots of little tests
IdentifiableBean bean = getReference(IdentifiableBean.class);
AnnotatedTypeIdentifier identifier = getReference(AnnotatedTypeIdentifier.class,new AnnotationLiteral<Default>()
{
14 years, 8 months
Weld SVN: r6142 - in extensions/trunk/src: test/java/org/jboss/weld/test/extensions and 1 other directories.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-04-21 20:13:06 -0400 (Wed, 21 Apr 2010)
New Revision: 6142
Added:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/RequiresIdentification.java
extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/
extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java
extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java
extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableInterceptorBinding.java
Removed:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
Log:
Update to identifiable beans
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java 2010-04-21 23:10:58 UTC (rev 6141)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -12,9 +12,8 @@
{
@Inject IdentifiableBeanExtension beans;
- public AnnotatedType<?> getAnnotatedType(IdentifiableBean instance)
+ public AnnotatedType<?> getAnnotatedType(Object instance)
{
- long id = instance.getBeanId();
- return beans.getAnnotatedType(id);
+ return beans.getAnnotatedType(instance);
}
}
Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java 2010-04-21 23:10:58 UTC (rev 6141)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -1,9 +0,0 @@
-package org.jboss.weld.extensions.beanid;
-
-public interface IdentifiableBean
-{
- public long getBeanId();
-
- public void setBeanId(long id);
-}
-
\ No newline at end of file
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-21 23:10:58 UTC (rev 6141)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -1,37 +1,61 @@
package org.jboss.weld.extensions.beanid;
+import java.lang.annotation.Annotation;
+import java.util.Collections;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.WeakHashMap;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessInjectionTarget;
/**
* extension that allows the AnnotatedType to be retrieved for a given bean
+ *
+ * This is hopefully a temporary workaround until a spec limitation is removed
+ *
* @author Stuart Douglas <stuart(a)baileyroberts.com.au>
*
*/
public class IdentifiableBeanExtension implements Extension
{
- private AtomicLong currentId = new AtomicLong();
-
- private Map<Long,AnnotatedType<?>> types = new ConcurrentHashMap<Long, AnnotatedType<?>>();
-
+ Map<Object, AnnotatedType<?>> types = Collections.synchronizedMap(new WeakHashMap<Object, AnnotatedType<?>>(1000));
+
public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
{
- if(event.getAnnotatedType().getBaseType() instanceof IdentifiableBean)
+ boolean requiresId = false;
+ for(Annotation a : event.getAnnotatedType().getAnnotations())
{
- long id = currentId.incrementAndGet();
- types.put(id, event.getAnnotatedType());
- event.setInjectionTarget(new IdentifiableInjectionTarget(event.getInjectionTarget(), id));
+ if(a.annotationType().isAnnotationPresent(RequiresIdentification.class))
+ {
+ requiresId = true;
+ break;
+ }
}
+ if(!requiresId)
+ {
+ for(AnnotatedMethod<?> m : event.getAnnotatedType().getMethods())
+ {
+ for(Annotation a : m.getAnnotations())
+ {
+ if(a.annotationType().isAnnotationPresent(RequiresIdentification.class))
+ {
+ requiresId = true;
+ break;
+ }
+ }
+ }
+ }
+ if(requiresId)
+ {
+ event.setInjectionTarget(new IdentifiableInjectionTarget(event.getInjectionTarget(), event.getAnnotatedType(),types));
+ }
}
- public AnnotatedType<?> getAnnotatedType(long id)
+ public AnnotatedType<?> getAnnotatedType(Object instance)
{
- return types.get(id);
+ return types.get(instance);
}
}
Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-21 23:10:58 UTC (rev 6141)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -1,8 +1,10 @@
package org.jboss.weld.extensions.beanid;
+import java.util.Map;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
/**
@@ -15,19 +17,21 @@
{
InjectionTarget<T> delegate;
- long id;
+ AnnotatedType<?> type;
- IdentifiableInjectionTarget(InjectionTarget<T> delegate, long id)
+ Map<Object, AnnotatedType<?>> typeMap;
+
+ IdentifiableInjectionTarget(InjectionTarget<T> delegate, AnnotatedType<?> type,Map<Object, AnnotatedType<?>> typeMap)
{
this.delegate = delegate;
- this.id=id;
+ this.type=type;
+ this.typeMap=typeMap;
}
public void inject(T instance, CreationalContext<T> ctx)
{
- IdentifiableBean bean =(IdentifiableBean)instance;
- bean.setBeanId(id);
+ typeMap.put(instance, type);
delegate.inject(instance, ctx);
}
@@ -43,6 +47,7 @@
public void dispose(T instance)
{
+ typeMap.remove(instance);
delegate.dispose(instance);
}
Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/RequiresIdentification.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/RequiresIdentification.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/RequiresIdentification.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -0,0 +1,17 @@
+package org.jboss.weld.extensions.beanid;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+/**
+ * annotation that should be applied to an interceptor binding to signify that it requires access to AnnotatedType information
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.ANNOTATION_TYPE)
+public @interface RequiresIdentification
+{
+
+}
Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBean.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -0,0 +1,12 @@
+package org.jboss.weld.test.extensions.beanid;
+@IdentifiableInterceptorBinding
+public class IdentifiableBean
+{
+ Class atClass;
+ boolean bindingFound = false;
+
+ public void someMethod()
+ {
+
+ }
+}
Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableBeansTest.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -0,0 +1,28 @@
+package org.jboss.weld.test.extensions.beanid;
+
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.weld.extensions.beanid.AnnotatedTypeIdentifier;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+@Artifact
+@Classes(packages = { "org.jboss.weld.extensions.beanid" })
+public class IdentifiableBeansTest extends AbstractWeldTest
+{
+ @Test
+ public void testBeanIdentifiers()
+ {
+ //TODO: This needs to be split up into lots of little tests
+ IdentifiableBean bean = getReference(IdentifiableBean.class);
+ AnnotatedTypeIdentifier identifier = getReference(AnnotatedTypeIdentifier.class,new AnnotationLiteral<Default>()
+ {
+ });
+ AnnotatedType<?> type = identifier.getAnnotatedType(bean);
+ assert type.getJavaClass() == IdentifiableBean.class;
+ assert type.isAnnotationPresent(IdentifiableInterceptorBinding.class);
+ }
+}
Added: extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableInterceptorBinding.java
===================================================================
--- extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableInterceptorBinding.java (rev 0)
+++ extensions/trunk/src/test/java/org/jboss/weld/test/extensions/beanid/IdentifiableInterceptorBinding.java 2010-04-22 00:13:06 UTC (rev 6142)
@@ -0,0 +1,19 @@
+package org.jboss.weld.test.extensions.beanid;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+import org.jboss.weld.extensions.beanid.RequiresIdentification;
+
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD,ElementType.TYPE})
+@InterceptorBinding
+@RequiresIdentification
+public @interface IdentifiableInterceptorBinding
+{
+
+}
14 years, 8 months
Weld SVN: r6141 - in extensions/trunk/src/main: java/org/jboss/weld/extensions/beanid and 1 other directories.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-04-21 19:10:58 -0400 (Wed, 21 Apr 2010)
New Revision: 6141
Added:
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
Modified:
extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
Log:
added portable extension to allow retreiving the annotated type in an interceptor
Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/AnnotatedTypeIdentifier.java 2010-04-21 23:10:58 UTC (rev 6141)
@@ -0,0 +1,20 @@
+package org.jboss.weld.extensions.beanid;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.inject.Inject;
+
+/**
+ * Class that can lookup an AnnotatedType from an instance of a bean
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ */
+public class AnnotatedTypeIdentifier
+{
+ @Inject IdentifiableBeanExtension beans;
+
+ public AnnotatedType<?> getAnnotatedType(IdentifiableBean instance)
+ {
+ long id = instance.getBeanId();
+ return beans.getAnnotatedType(id);
+ }
+}
Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBean.java 2010-04-21 23:10:58 UTC (rev 6141)
@@ -0,0 +1,9 @@
+package org.jboss.weld.extensions.beanid;
+
+public interface IdentifiableBean
+{
+ public long getBeanId();
+
+ public void setBeanId(long id);
+}
+
\ No newline at end of file
Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableBeanExtension.java 2010-04-21 23:10:58 UTC (rev 6141)
@@ -0,0 +1,37 @@
+package org.jboss.weld.extensions.beanid;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+/**
+ * extension that allows the AnnotatedType to be retrieved for a given bean
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ */
+public class IdentifiableBeanExtension implements Extension
+{
+ private AtomicLong currentId = new AtomicLong();
+
+ private Map<Long,AnnotatedType<?>> types = new ConcurrentHashMap<Long, AnnotatedType<?>>();
+
+ public void processInjectionTarget(@Observes ProcessInjectionTarget<?> event)
+ {
+ if(event.getAnnotatedType().getBaseType() instanceof IdentifiableBean)
+ {
+ long id = currentId.incrementAndGet();
+ types.put(id, event.getAnnotatedType());
+ event.setInjectionTarget(new IdentifiableInjectionTarget(event.getInjectionTarget(), id));
+ }
+ }
+
+ public AnnotatedType<?> getAnnotatedType(long id)
+ {
+ return types.get(id);
+ }
+
+}
Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanid/IdentifiableInjectionTarget.java 2010-04-21 23:10:58 UTC (rev 6141)
@@ -0,0 +1,59 @@
+package org.jboss.weld.extensions.beanid;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+/**
+ * wrapper around InjectionTarget that sets a bean id
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ * @param <T>
+ */
+public class IdentifiableInjectionTarget<T> implements InjectionTarget<T>
+{
+ InjectionTarget<T> delegate;
+
+ long id;
+
+ IdentifiableInjectionTarget(InjectionTarget<T> delegate, long id)
+ {
+ this.delegate = delegate;
+ this.id=id;
+ }
+
+
+ public void inject(T instance, CreationalContext<T> ctx)
+ {
+ IdentifiableBean bean =(IdentifiableBean)instance;
+ bean.setBeanId(id);
+ delegate.inject(instance, ctx);
+ }
+
+ public void postConstruct(T instance)
+ {
+ delegate.postConstruct(instance);
+ }
+
+ public void preDestroy(T instance)
+ {
+ delegate.preDestroy(instance);
+ }
+
+ public void dispose(T instance)
+ {
+ delegate.dispose(instance);
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return delegate.getInjectionPoints();
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ return delegate.produce(ctx);
+ }
+
+}
Modified: extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-04-21 15:47:29 UTC (rev 6140)
+++ extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2010-04-21 23:10:58 UTC (rev 6141)
@@ -1,2 +1,3 @@
org.jboss.weld.extensions.genericbeans.GenericExtension
-org.jboss.weld.extensions.resources.servlet.ServletResourceExtension
\ No newline at end of file
+org.jboss.weld.extensions.resources.servlet.ServletResourceExtension
+org.jboss.weld.extensions.beanid.IdentifiableBeanExtension
\ No newline at end of file
14 years, 8 months
Weld SVN: r6140 - core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-04-21 11:47:29 -0400 (Wed, 21 Apr 2010)
New Revision: 6140
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
Log:
clean up ctor
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-04-21 13:29:32 UTC (rev 6139)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-04-21 15:47:29 UTC (rev 6140)
@@ -60,9 +60,9 @@
protected final Class<?> beanType;
protected final ArrayList<Class<?>> additionalInterfaces = new ArrayList<Class<?>>();
- protected ClassLoader classLoader;
- protected ProtectionDomain protectionDomain;
- protected ClassPool classPool;
+ protected final ClassLoader classLoader;
+ protected final ProtectionDomain protectionDomain;
+ protected final ClassPool classPool;
/**
* Creates a new proxy factory from any type of BeanInstance. This bean
@@ -73,8 +73,7 @@
*/
public ProxyFactory(BeanInstance beanInstance)
{
- this.beanType = beanInstance.getInstanceType();
- init();
+ this(beanInstance.getInstanceType());
}
/**
@@ -82,26 +81,21 @@
*
* @param proxiedBeanType the super-class for this proxy class
*/
- public ProxyFactory(Class<T> proxiedBeanType)
+ public ProxyFactory(Class<?> proxiedBeanType)
{
this.beanType = proxiedBeanType;
- init();
- }
-
- /**
- * Initializes the proxy factory.
- */
- private void init()
- {
- classLoader = beanType.getClassLoader();
- protectionDomain = beanType.getProtectionDomain();
if (beanType.getName().startsWith("java."))
{
- classLoader = this.getClass().getClassLoader();
- protectionDomain = this.getClass().getProtectionDomain();
+ this.classLoader = this.getClass().getClassLoader();
+ this.protectionDomain = this.getClass().getProtectionDomain();
}
- classPool = new ClassPool();
- classPool.appendClassPath(new ClassloaderClassPath(classLoader));
+ else
+ {
+ this.classLoader = beanType.getClassLoader();
+ this.protectionDomain = beanType.getProtectionDomain();
+ }
+ this.classPool = new ClassPool();
+ this.classPool.appendClassPath(new ClassloaderClassPath(classLoader));
addDefaultAdditionalInterfaces();
}
14 years, 8 months
Weld SVN: r6139 - in cdi-tck/branches/1.0: impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent and 7 other directories.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2010-04-21 09:29:32 -0400 (Wed, 21 Apr 2010)
New Revision: 6139
Modified:
cdi-tck/branches/1.0/doc/reference/en-US/Book_Preface.xml
cdi-tck/branches/1.0/doc/reference/en-US/appeals-process.xml
cdi-tck/branches/1.0/doc/reference/en-US/introduction.xml
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/CityDecorator.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/session/IntrospectSession.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cow.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/CircularDependencyTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Food.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Pig.java
Log:
CDITCK-120 CDITCK-143 CDITCK-134 CDITCK-121 CDITCK-119
Modified: cdi-tck/branches/1.0/doc/reference/en-US/Book_Preface.xml
===================================================================
--- cdi-tck/branches/1.0/doc/reference/en-US/Book_Preface.xml 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/doc/reference/en-US/Book_Preface.xml 2010-04-21 13:29:32 UTC (rev 6139)
@@ -12,8 +12,8 @@
<para>
The CDI TCK is built atop the JBoss Test Harness, a portable and
configurable automated test suite for authoring unit and integration tests
- in a Java EE environment. The CDI TCK 1.0.0 uses the JBoss Test Harness
- version 1.0.0 to execute the test suite.
+ in a Java EE environment. The CDI TCK 1.0.2CR1 uses the JBoss Test Harness
+ version 1.1.0CR6 to execute the test suite.
</para>
<para>
Modified: cdi-tck/branches/1.0/doc/reference/en-US/appeals-process.xml
===================================================================
--- cdi-tck/branches/1.0/doc/reference/en-US/appeals-process.xml 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/doc/reference/en-US/appeals-process.xml 2010-04-21 13:29:32 UTC (rev 6139)
@@ -80,7 +80,7 @@
Project Lead, as designated by Specification Lead, Red Hat Middleware
LLC. or his/her designate. The appellant can also monitor the process
by following the issue report filed in the <ulink
- url="https://jira.jboss.org/jira/browse/WBTCK">WBTCK project</ulink>
+ url="https://jira.jboss.org/jira/browse/CDITCK">CDITCK project</ulink>
of the JBoss JIRA.
</para>
<para>
Modified: cdi-tck/branches/1.0/doc/reference/en-US/introduction.xml
===================================================================
--- cdi-tck/branches/1.0/doc/reference/en-US/introduction.xml 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/doc/reference/en-US/introduction.xml 2010-04-21 13:29:32 UTC (rev 6139)
@@ -173,7 +173,7 @@
<listitem>
<para>
<emphasis role="bold">JBoss Test Harness</emphasis>
- - The CDI TCK requires version 1.1.0-CR3 of the JBoss Test
+ - The CDI TCK requires version 1.0.0 of the JBoss Test
Harness. The Harness is based on TestNG 5.x
(<ulink url="http://testng.org">http://testng.org</ulink>).
You can read more about the harness in
@@ -235,7 +235,7 @@
</listitem>
<listitem>
<para>
- <emphasis role="bold">TestNG 5.9</emphasis>, the testing
+ <emphasis role="bold">TestNG 5.10</emphasis>, the testing
framework on which the JBoss Test Harness is based and which
provides the extension points for selecting an executing the
tests in the test suite.
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -411,16 +411,14 @@
Bean<Interior> roomBean = getBeans(Interior.class, new RoomBinding()).iterator().next();
CreationalContext<Interior> roomCreationalContext = getCurrentManager().createCreationalContext(roomBean);
+ Interior room = (Interior) getCurrentManager().getReference(roomBean, Interior.class, roomCreationalContext);
- Interior room = roomBean.create(roomCreationalContext);
-
InteriorDecorator.reset();
room.foo();
assert InteriorDecorator.getInstances().size() == 1;
-
- roomBean.destroy(room, roomCreationalContext);
+ roomCreationalContext.release();
assert InteriorDecorator.isDestroyed();
}
@@ -434,12 +432,12 @@
Bean<AccountTransaction> bean = getBeans(AccountTransaction.class).iterator().next();
CreationalContext<AccountTransaction> ctx = getCurrentManager().createCreationalContext(bean);
- AccountTransaction trans = bean.create(ctx);
+ AccountTransaction trans = (AccountTransaction) getCurrentManager().getReference(bean, AccountTransaction.class, ctx);
trans.execute();
assert TransactionalInterceptor.intercepted;
- bean.destroy(trans, ctx);
+ ctx.release();
assert TransactionalInterceptor.destroyed;
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/CityDecorator.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/CityDecorator.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/CityDecorator.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -23,10 +23,10 @@
import javax.enterprise.inject.Any;
import javax.inject.Inject;
-@SuppressWarnings("serial")
@Decorator
public class CityDecorator implements CityInterface, Serializable
{
+ private static final long serialVersionUID = 7666849923138796340L;
@Inject @Delegate @Any CityInterface city;
@Inject
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingBeanConstructor/UnderwaterCity.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -18,9 +18,14 @@
import java.io.Serializable;
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
class UnderwaterCity implements CityInterface, Serializable
{
+ private static final long serialVersionUID = 3226222322140685248L;
+
public void foo()
{
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInitializerMethod/UnderwaterCity.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -24,6 +24,8 @@
class UnderwaterCity implements CityInterface, Serializable
{
+ private static final long serialVersionUID = 7753204334538945451L;
+
public void foo()
{
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/passivating/broken/decoratorWithNonPassivatingInjectedField/UnderwaterCity.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -18,9 +18,14 @@
import java.io.Serializable;
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
class UnderwaterCity implements CityInterface, Serializable
{
+ private static final long serialVersionUID = 1877770475170392128L;
+
public void foo()
{
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/session/IntrospectSession.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/session/IntrospectSession.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/session/IntrospectSession.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -19,7 +19,6 @@
import java.io.IOException;
-import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -36,14 +35,12 @@
{
private static final long serialVersionUID = 1L;
- @Inject
- private BeanManager jsr299Manager;
+ @Inject private SimpleSessionBean aBean;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
resp.setContentType("text/text");
- SimpleSessionBean aBean = org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(jsr299Manager,SimpleSessionBean.class);
resp.getWriter().print(aBean.hashCode());
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -41,7 +41,6 @@
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.PassivationCapable;
import javax.enterprise.util.AnnotationLiteral;
import javax.interceptor.InterceptorBinding;
@@ -49,9 +48,9 @@
import org.jboss.jsr299.tck.literals.RetentionLiteral;
import org.jboss.jsr299.tck.literals.TargetLiteral;
import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.Extension;
import org.testng.annotations.Test;
/**
@@ -62,21 +61,11 @@
*
*/
@Artifact
+@Extension("javax.enterprise.inject.spi.Extension")
@SpecVersion(spec="cdi", version="20091101")
public class BeanManagerTest extends AbstractJSR299Test
{
@Test
- @SpecAssertion(section = "11.3.6", id = "a")
- public void testGetPassivationCapableBeanById()
- {
- Bean<?> bean = getCurrentManager().getBeans(Cow.class).iterator().next();
- assert PassivationCapable.class.isAssignableFrom(bean.getClass());
- PassivationCapable passivationCapable = (PassivationCapable) bean;
- Bean<?> passivatingBean = getCurrentManager().getPassivationCapableBean(passivationCapable.getId());
- assert bean == passivatingBean;
- }
-
- @Test
@SpecAssertion(section = "11.3.7", id = "a")
public void testAmbiguousDependencyResolved()
{
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cow.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cow.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cow.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -18,5 +18,8 @@
public class Cow
{
-
+ public Cow(String name)
+ {
+
+ }
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -134,8 +134,10 @@
final Contextual<ShoeFactory> bean = getBeans(ShoeFactory.class).iterator().next();
MockCreationalContext.reset();
ShoeFactory instance = getCurrentManager().getContext(Dependent.class).get(bean, creationalContext);
- assert MockCreationalContext.isPushCalled();
- assert instance == MockCreationalContext.getLastBeanPushed();
+ if (MockCreationalContext.isPushCalled())
+ {
+ assert instance == MockCreationalContext.getLastBeanPushed();
+ }
}
@Test(groups = "beanLifecycle")
@@ -149,8 +151,6 @@
final Contextual<FishPond> bean = getBeans(FishPond.class).iterator().next();
FishPond fishPond = bean.create(creationalContext);
assert fishPond != null;
- assert MockCreationalContext.isPushCalled();
- assert MockCreationalContext.getBeansPushed().contains(fishPond);
assert fishPond.goldfish != null;
assert fishPond.goldfish instanceof Goldfish;
assert fishPond.goose != null;
@@ -179,8 +179,7 @@
@SpecAssertion(section = "7.3.1", id = "aa"),
@SpecAssertion(section = "3.8.1", id = "aa"),
@SpecAssertion(section="2.3.4", id="a"),
- @SpecAssertion(section="3.8", id="aa"),
- @SpecAssertion(section="3.8", id="ab"),
+ @SpecAssertion(section="3.8", id="a"),
@SpecAssertion(section="12.1", id="bca")
})
public void testCreateInjectsFieldsDeclaredInJava()
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/CircularDependencyTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/CircularDependencyTest.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/CircularDependencyTest.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,7 +9,7 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
@@ -31,9 +31,10 @@
@SpecAssertion(section="5", id="b")
public void testCircularInjectionOnTwoNormalBeans() throws Exception
{
- getInstanceByType(Pig.class).getName();
- assert Pig.success;
- assert Food.success;
+ Pig pig = getInstanceByType(Pig.class);
+ Food food = getInstanceByType(Food.class);
+ assert pig.getNameOfFood().equals(food.getName());
+ assert food.getNameOfPig().equals(pig.getName());
}
@Test
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Food.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Food.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Food.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,14 +9,13 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.jsr299.tck.tests.lookup.circular;
-import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
@@ -24,27 +23,15 @@
class Food
{
- public static boolean success;
-
@Inject Pig pig;
- public Food()
- {
- success = false;
- }
-
- @PostConstruct
- public void postConstruct()
- {
- if (pig.getName().equals("john"))
- {
- success = true;
- }
- }
-
public String getName()
{
return "food";
}
+ public String getNameOfPig()
+ {
+ return pig.getName();
+ }
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Pig.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Pig.java 2010-04-21 13:14:29 UTC (rev 6138)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/circular/Pig.java 2010-04-21 13:29:32 UTC (rev 6139)
@@ -9,42 +9,33 @@
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.jsr299.tck.tests.lookup.circular;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
-@ApplicationScoped
-class Pig
+@SessionScoped
+class Pig implements Serializable
{
- public static boolean success;
-
+ private static final long serialVersionUID = 2445308247858178311L;
+
@Inject Food food;
- public Pig()
- {
- success = false;
- }
-
- @PostConstruct
- public void postConstruct()
- {
- if (food.getName().equals("food"))
- {
- success = true;
- }
- }
-
public String getName()
{
return "john";
}
+ public String getNameOfFood()
+ {
+ return food.getName();
+ }
}
14 years, 8 months
Weld SVN: r6138 - build/trunk/dist-tck.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2010-04-21 09:14:29 -0400 (Wed, 21 Apr 2010)
New Revision: 6138
Modified:
build/trunk/dist-tck/generate-custom-dd-report.sh
Log:
CDITCK-116
Modified: build/trunk/dist-tck/generate-custom-dd-report.sh
===================================================================
--- build/trunk/dist-tck/generate-custom-dd-report.sh 2010-04-21 12:20:56 UTC (rev 6137)
+++ build/trunk/dist-tck/generate-custom-dd-report.sh 2010-04-21 13:14:29 UTC (rev 6138)
@@ -3,7 +3,7 @@
ANNOTATIONS="@PersistenceXml @WebXml @EjbJarXml"
report=`pwd`/dd-override-report.txt
-echo "Deployment Descripters overriden by the TCK\n\n" > dd-override-report.txt
+echo "Deployment Descriptors overriden by the TCK\n\n" > dd-override-report.txt
if [[ -z $TCK_HOME ]]
then
14 years, 8 months
Weld SVN: r6137 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi.
by weld-commits@lists.jboss.org
Author: jharting
Date: 2010-04-21 08:20:56 -0400 (Wed, 21 Apr 2010)
New Revision: 6137
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTestEar.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTest.java
Log:
Added testcase for BeanManager JNDI lookup in an EAR archive
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTest.java 2010-04-21 11:27:33 UTC (rev 6136)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTest.java 2010-04-21 12:20:56 UTC (rev 6137)
@@ -22,15 +22,20 @@
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
import org.testng.annotations.Test;
@Artifact
+(a)Classes(JndiBeanManagerInjected.class)
@IntegrationTest
@SpecVersion(spec = "cdi", version = "20091101")
+(a)Packaging(PackagingType.WAR)
public class ManagerTest extends AbstractJSR299Test
{
- @Test(groups = { "manager", "ejb3", "integration"})
+ @Test(groups = { "manager", "ejb3", "integration" })
@SpecAssertion(section = "11.3", id = "da")
public void testManagerLookupInJndi() throws Exception
{
Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTestEar.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTestEar.java (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/manager/jndi/ManagerTestEar.java 2010-04-21 12:20:56 UTC (rev 6137)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.lookup.manager.jndi;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.testng.annotations.Test;
+
+@Artifact
+(a)Classes(JndiBeanManagerInjected.class)
+@IntegrationTest
+@SpecVersion(spec = "cdi", version = "20091101")
+(a)Packaging(PackagingType.EAR)
+public class ManagerTestEar extends AbstractJSR299Test
+{
+ @Test(groups = { "manager", "ejb3", "integration" })
+ @SpecAssertion(section = "11.3", id = "da")
+ public void testManagerLookupInJndi() throws Exception
+ {
+ BeanManager beanManager = getInstanceByType(JndiBeanManagerInjected.class).getManagerFromJndi();
+ assert beanManager != null;
+ assert beanManager.equals(getCurrentManager());
+ }
+}
\ No newline at end of file
14 years, 8 months
Weld SVN: r6136 - core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2010-04-21 07:27:33 -0400 (Wed, 21 Apr 2010)
New Revision: 6136
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/ClassloaderClassPath.java
Log:
Fixed class file paths to work on all platforms
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/ClassloaderClassPath.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/ClassloaderClassPath.java 2010-04-21 10:29:59 UTC (rev 6135)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/ClassloaderClassPath.java 2010-04-21 11:27:33 UTC (rev 6136)
@@ -17,6 +17,7 @@
package org.jboss.weld.bean.proxy.util;
+import java.io.File;
import java.io.InputStream;
import java.net.URL;
@@ -46,13 +47,13 @@
public URL find(String classname)
{
- String resourceName = classname.replace('.', '/') + ".class";
+ String resourceName = classname.replace('.', File.separatorChar) + ".class";
return classLoader.getResource(resourceName);
}
public InputStream openClassfile(String classname) throws NotFoundException
{
- String resourceName = classname.replace('.', '/') + ".class";
+ String resourceName = classname.replace('.', File.separatorChar) + ".class";
return classLoader.getResourceAsStream(resourceName);
}
14 years, 8 months