[weld-commits] Weld SVN: r5152 - in extensions/trunk: core and 7 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue Nov 24 13:12:22 EST 2009


Author: pete.muir at jboss.org
Date: 2009-11-24 13:12:22 -0500 (Tue, 24 Nov 2009)
New Revision: 5152

Added:
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Constructs.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Exact.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/ExactLiteral.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/NamedLiteral.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java
   extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java
   extensions/trunk/core/src/test/java/org/slf4j/
   extensions/trunk/core/src/test/java/org/slf4j/impl/
   extensions/trunk/core/src/test/java/org/slf4j/impl/StaticLoggerBinder.java
   extensions/trunk/core/src/test/java/org/slf4j/impl/StaticMarkerBinder.java
   extensions/trunk/core/src/test/java/org/slf4j/impl/TestLogger.java
   extensions/trunk/core/src/test/java/org/slf4j/impl/TestLoggerFactory.java
Removed:
   extensions/trunk/core/src/test/java/org/jboss/weld/test/log/TestAppender.java
Modified:
   extensions/trunk/bom/pom.xml
   extensions/trunk/core/pom.xml
   extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Finch.java
   extensions/trunk/core/src/test/java/org/jboss/weld/test/log/LoggerInjectionTest.java
   extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Sparrow.java
Log:
add Gavin's extension code

Modified: extensions/trunk/bom/pom.xml
===================================================================
--- extensions/trunk/bom/pom.xml	2009-11-24 15:04:50 UTC (rev 5151)
+++ extensions/trunk/bom/pom.xml	2009-11-24 18:12:22 UTC (rev 5152)
@@ -115,55 +115,11 @@
             <version>${testng.version}</version>
          </dependency>
          <dependency>
-            <groupId>org.apache.wicket</groupId>
-            <artifactId>wicket</artifactId>
-            <version>${wicket.version}</version>
-         </dependency>
-         <dependency>
             <groupId>org.jboss.weld</groupId>
-            <artifactId>weld-wicket</artifactId>
+            <artifactId>weld-extensions</artifactId>
             <version>${project.version}</version>
          </dependency>
-         <dependency>
-            <groupId>org.jboss.weld</groupId>
-            <artifactId>weld-se</artifactId>
-            <version>${project.version}</version>
-         </dependency>
-         <dependency>
-            <groupId>org.jboss.weld.servlet</groupId>
-            <artifactId>weld-servlet</artifactId>
-            <version>${project.version}</version>
-         </dependency>
-         <dependency>
-            <groupId>org.jboss.weld.servlet</groupId>
-            <artifactId>weld-servlet-int</artifactId>
-            <version>${project.version}</version>
-         </dependency>
 
-         <dependency>
-            <groupId>org.apache.tomcat</groupId>
-            <artifactId>catalina</artifactId>
-            <version>${tomcat.version}</version>
-         </dependency>
-
-         <dependency>
-            <groupId>org.apache.tomcat</groupId>
-            <artifactId>jasper</artifactId>
-            <version>${tomcat.version}</version>
-         </dependency>
-         
-         <dependency>
-            <groupId>org.glassfish.web</groupId>
-            <artifactId>el-impl</artifactId>
-            <version>${uel.glassfish.version}</version>
-         </dependency>
-
-         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-jdk14</artifactId>
-            <version>${slf4j.version}</version>
-         </dependency>
-
       </dependencies>
    </dependencyManagement>
 </project>

Modified: extensions/trunk/core/pom.xml
===================================================================
--- extensions/trunk/core/pom.xml	2009-11-24 15:04:50 UTC (rev 5151)
+++ extensions/trunk/core/pom.xml	2009-11-24 18:12:22 UTC (rev 5152)
@@ -41,11 +41,11 @@
       </dependency>
       
       <dependency>
-      	<groupId>javax.enterprise</groupId>
-      	<artifactId>cdi-api</artifactId>
+      	 <groupId>javax.enterprise</groupId>
+      	 <artifactId>cdi-api</artifactId>
          <scope>provided</scope>
       </dependency>
-      
+
       <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
@@ -58,12 +58,6 @@
       </dependency>
       
       <dependency>
-      	<groupId>org.jboss.test-harness</groupId>
-      	<artifactId>jboss-test-harness-jboss-as-50</artifactId>
-      	<scope>test</scope>
-      </dependency>
-      
-      <dependency>
       	<groupId>org.jboss.weld</groupId>
       	<artifactId>weld-core</artifactId>
       	<scope>test</scope>

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Constructs.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Constructs.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Constructs.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,21 @@
+package org.jboss.weld.extensions;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Allows a bean to be defined by annotating a constructor instead
+ * of the bean class. There may be multiple beans defined using
+ * <tt>@Constructs</tt> per bean class.
+ * 
+ * @author Gavin King
+ *
+ */
+ at Retention(RUNTIME)
+ at Target(CONSTRUCTOR)
+ at Documented
+public @interface Constructs {}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Constructs.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,168 @@
+package org.jboss.weld.extensions;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Qualifier;
+
+import org.jboss.weld.extensions.util.AnnotationRedefinition;
+import org.jboss.weld.extensions.util.BeanImpl;
+import org.jboss.weld.extensions.util.Reannotated;
+import org.jboss.weld.extensions.util.ReannotatedMember;
+import org.jboss.weld.extensions.util.ReannotatedType;
+
+public class CoreExtension implements Extension
+{
+
+   Collection<Bean<?>> additionalBeans = new ArrayList<Bean<?>>();
+
+   <X> void processAnnotatedType(@Observes final ProcessAnnotatedType<X> pat, BeanManager bm)
+   {
+      final AnnotatedType<X> at = pat.getAnnotatedType();
+
+      ReannotatedType<X> rt = new ReannotatedType<X>(at);
+
+      // support for @Named packages
+      Package pkg = at.getJavaClass().getPackage();
+      if (pkg.isAnnotationPresent(Named.class))
+      {
+         final String packageName = getPackageName(pkg);
+         if (at.isAnnotationPresent(Named.class))
+         {
+            String className = at.getJavaClass().getSimpleName();
+            String beanName = getName(at, className);
+            rt.define(new NamedLiteral(packageName + '.' + beanName));
+         }
+         rt.redefineMembers(Named.class, new AnnotationRedefinition<Named>()
+         {
+            
+            @SuppressWarnings("unchecked")
+            public Named redefine(Named annotation, Reannotated reannotated)
+            {
+               if (reannotated.isAnnotationPresent(Produces.class))
+               {
+                  String memberName = ((ReannotatedMember<? super X>) reannotated).getJavaMember().getName();
+                  String beanName = getName(reannotated, memberName);
+                  return new NamedLiteral(packageName + '.' + beanName);
+               }
+               else
+               {
+                  return annotation;
+               }
+            }
+
+         });
+      }
+
+      // support for @Exact
+      Set<Annotation> qualfiers = rt.getAnnotationsWithMetatype(Qualifier.class);
+      boolean defaultQualifier = qualfiers.isEmpty() || (qualfiers.size() == 1 && qualfiers.iterator().next().annotationType() == Named.class);
+      if (defaultQualifier)
+      {
+         rt.define(new AnnotationLiteral<Default>()
+         {
+         });
+      }
+      rt.define(new ExactLiteral(at.getJavaClass()));
+      rt.redefineMembersAndParameters(Exact.class, new AnnotationRedefinition<Exact>()
+      {
+         
+         public Exact redefine(Exact annotation, Reannotated reannotated)
+         {
+            if (annotation.value() == void.class)
+            {
+               return new ExactLiteral(reannotated.getJavaClass());
+            }
+            else
+            {
+               return annotation;
+            }
+         }
+      });
+
+      pat.setAnnotatedType(rt);
+
+      // support for @Constructs
+      for (AnnotatedConstructor<X> constructor : at.getConstructors())
+      {
+         if (constructor.isAnnotationPresent(Constructs.class))
+         {
+            ReannotatedType<X> rtc = new ReannotatedType<X>(at);
+            // remove class-level @Named annotation
+            rtc.redefine(Named.class, new AnnotationRedefinition<Named>()
+            {
+               
+               public Named redefine(Named annotation, Reannotated reannotated)
+               {
+                  return null;
+               }
+            });
+            // remove bean constructor annotated @Inject
+            rtc.redefineConstructors(Inject.class, new AnnotationRedefinition<Inject>()
+            {
+               
+               public Inject redefine(Inject annotation, Reannotated reannotated)
+               {
+                  return null;
+               }
+            });
+            // make the constructor annotated @Constructs the bean constructor
+            rtc.getConstructor(constructor.getJavaMember()).define(new AnnotationLiteral<Inject>()
+            {
+            });
+            // add all the annotations of this constructor to the class
+            for (Annotation ann : constructor.getAnnotations())
+            {
+               rtc.define(ann);
+            }
+
+            additionalBeans.add(new BeanImpl<X>(bm.createInjectionTarget(rtc), rtc));
+         }
+      }
+   }
+
+   void afterBeanDiscovery(@Observes AfterBeanDiscovery abd)
+   {
+      for (Bean<?> bean : additionalBeans)
+      {
+         abd.addBean(bean);
+      }
+   }
+
+   private String getPackageName(Package pkg)
+   {
+      String packageName = pkg.getAnnotation(Named.class).value();
+      if (packageName.isEmpty())
+      {
+         packageName = pkg.getName();
+      }
+      return packageName;
+   }
+
+   private <X> String getName(Annotated annotated, String defaultName)
+   {
+      String beanName = annotated.getAnnotation(Named.class).value();
+      if (beanName.isEmpty())
+      {
+         beanName = defaultName.substring(0, 1).toLowerCase() + defaultName.substring(1);
+      }
+      return beanName;
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/CoreExtension.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Exact.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Exact.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Exact.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,29 @@
+package org.jboss.weld.extensions;
+
+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.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * An injection point qualifier that may be used to select
+ * the exact bean to be injected, by specifying its implementation
+ * class.
+ * 
+ * @author Gavin King
+ *
+ */
+ at Retention(RUNTIME)
+ at Target({METHOD, TYPE, FIELD, PARAMETER})
+ at Documented
+ at Qualifier
+public @interface Exact {
+	Class<?> value() default void.class;
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/Exact.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/ExactLiteral.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/ExactLiteral.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/ExactLiteral.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,24 @@
+/**
+ * 
+ */
+package org.jboss.weld.extensions;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+class ExactLiteral extends AnnotationLiteral<Exact> implements Exact
+{
+
+   private static final long serialVersionUID = 4907169607105615674L;
+   
+   final Class<?> clazz;
+
+   ExactLiteral(Class<?> clazz)
+   {
+      this.clazz = clazz;
+   }
+
+   public Class<?> value()
+   {
+      return clazz;
+   }
+}
\ No newline at end of file


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/ExactLiteral.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/NamedLiteral.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/NamedLiteral.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/NamedLiteral.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,23 @@
+/**
+ * 
+ */
+package org.jboss.weld.extensions;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Named;
+
+class NamedLiteral extends AnnotationLiteral<Named> implements Named
+{
+   private static final long serialVersionUID = 2239690880420187044L;
+   final String name;
+
+   NamedLiteral(String name)
+   {
+      this.name = name;
+   }
+
+   public String value()
+   {
+      return name;
+   }
+}
\ No newline at end of file


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/NamedLiteral.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,8 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+
+public interface AnnotationRedefinition<X extends Annotation>
+{
+   public X redefine(X annotation, Reannotated reannotated);
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/AnnotationRedefinition.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,134 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.inject.Named;
+import javax.inject.Qualifier;
+import javax.inject.Scope;
+
+/**
+ * This implementation of Bean is immutable and threadsafe.
+ * 
+ * @author Gavin King
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
+public class BeanImpl<T> implements Bean<T>
+{
+
+   private final InjectionTarget<T> injectionTarget;
+   private final Set<Type> types;
+   private final String name;
+   private final Set<Annotation> qualifiers;
+   private final Class<? extends Annotation> scope;
+   private final boolean alternative;
+   private final Class<?> beanClass;
+
+   public BeanImpl(InjectionTarget<T> it, ReannotatedType<T> rtc)
+   {
+      // create the Bean
+      this.injectionTarget = it;
+      // TODO: this stuff does not handle stereotypes
+      Set<? extends Annotation> scopes = rtc.getAnnotationsWithMetatype(Scope.class);
+      this.scope = scopes.isEmpty() ? Dependent.class : scopes.iterator().next().annotationType();
+      if (rtc.isAnnotationPresent(Named.class))
+      {
+         this.name = rtc.getAnnotation(Named.class).value();
+         // no name defaulting for constructors
+         if (this.name.isEmpty())
+         {
+            throw new RuntimeException();
+         }
+      }
+      else
+      {
+         this.name = null;
+      }
+      alternative = rtc.isAnnotationPresent(Alternative.class);
+      qualifiers = rtc.getAnnotationsWithMetatype(Qualifier.class);
+      types = rtc.getTypeClosure();
+      beanClass = rtc.getJavaClass();
+   }
+
+   public BeanImpl(InjectionTarget<T> injectionTarget, Set<Type> types, Set<Annotation> qualifiers, Class<? extends Annotation> scope, String name, boolean alternative, Class<?> beanClass)
+   {
+      this.injectionTarget = injectionTarget;
+      this.types = types;
+      this.qualifiers = qualifiers;
+      this.scope = scope;
+      this.name = name;
+      this.alternative = alternative;
+      this.beanClass = beanClass;
+      // TODO: stereotypes!!!
+   }
+
+   public Class<?> getBeanClass()
+   {
+      return beanClass;
+   }
+
+   public Set<InjectionPoint> getInjectionPoints()
+   {
+      return injectionTarget.getInjectionPoints();
+   }
+
+   public String getName()
+   {
+      return name;
+   }
+
+   public Set<Annotation> getQualifiers()
+   {
+      return Collections.unmodifiableSet(qualifiers);
+   }
+
+   public Class<? extends Annotation> getScope()
+   {
+      return scope;
+   }
+
+   public Set<Class<? extends Annotation>> getStereotypes()
+   {
+      return Collections.emptySet(); // TODO
+   }
+
+   public Set<Type> getTypes()
+   {
+      return Collections.unmodifiableSet(types);
+   }
+
+   public boolean isAlternative()
+   {
+      return alternative;
+   }
+
+   public boolean isNullable()
+   {
+      return false;
+   }
+
+   public T create(CreationalContext<T> ctx)
+   {
+      T instance = injectionTarget.produce(ctx);
+      injectionTarget.inject(instance, ctx);
+      injectionTarget.postConstruct(instance);
+      return instance;
+   }
+
+   public void destroy(T instance, CreationalContext<T> creationalContext)
+   {
+      injectionTarget.preDestroy(instance);
+      creationalContext.release();
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/BeanImpl.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,158 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+/**
+ * This class is not thread-safe, and the client must provide any synchronization needed
+ * 
+ * @author Gavin King
+ * @author Pete Muir
+ * 
+ *
+ */
+public abstract class Reannotated implements Annotated
+{
+   
+   private static class AnnotationSet extends AbstractSet<Annotation>
+   {
+
+      List<Annotation> list = new ArrayList<Annotation>();
+
+      AnnotationSet(Map<Class<? extends Annotation>, Annotation> annotations, Set<Annotation> delegateAnnotations)
+      {
+         list.addAll(annotations.values());
+         for (Annotation ann : delegateAnnotations)
+         {
+            if (!annotations.containsKey(ann.annotationType()))
+            {
+               list.add(ann);
+            }
+         }
+      }
+
+      @Override
+      public Iterator<Annotation> iterator()
+      {
+         return list.iterator();
+      }
+
+      @Override
+      public int size()
+      {
+         return list.size();
+      }
+
+   }
+
+
+   protected abstract Annotated delegate();
+
+   private final Map<Class<? extends Annotation>, Annotation> annotations;
+   
+   public Reannotated()
+   {
+      this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+   }
+
+   public <X extends Annotation> void redefine(Class<X> annotationType, AnnotationRedefinition<X> visitor)
+   {
+      if (isAnnotationPresent(annotationType))
+      {
+         X redefined = visitor.redefine(getAnnotation(annotationType), this);
+         if (redefined == null)
+         {
+            annotations.remove(annotationType);
+         }
+         else
+         {
+            annotations.put(annotationType, redefined);
+         }
+      }
+   }
+
+   /*
+    * public void undefine(Class<? extends Annotation> annotationType) {
+    * annotations.put(annotationType, null); }
+    */
+
+   public void define(Annotation ann)
+   {
+      annotations.put(ann.annotationType(), ann);
+   }
+
+   public boolean isAnnotationWithMetatypePresent(Class<? extends Annotation> metaannotationType)
+   {
+      for (Annotation ann : getAnnotations())
+      {
+         if (ann.annotationType().isAnnotationPresent(metaannotationType))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
+
+   public Set<Annotation> getAnnotationsWithMetatype(Class<? extends Annotation> metaannotationType)
+   {
+      Set<Annotation> set = new HashSet<Annotation>();
+      for (Annotation ann : getAnnotations())
+      {
+         if (ann.annotationType().isAnnotationPresent(metaannotationType))
+         {
+            set.add(ann);
+         }
+      }
+      return set;
+   }
+
+   public abstract Class<?> getJavaClass();
+
+   public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+   {
+      if (annotationType == null)
+      {
+         throw new IllegalArgumentException("annotationType argument must not be null");
+      }
+      Annotation ann = annotations.get(annotationType);
+      if (ann != null)
+      {
+         return annotationType.cast(ann);
+      }
+      else
+      {
+         return delegate().getAnnotation(annotationType);
+      }
+   }
+
+   public Set<Annotation> getAnnotations()
+   {
+      return new AnnotationSet(annotations, delegate().getAnnotations());
+   }
+
+   public Type getBaseType()
+   {
+      return delegate().getBaseType();
+   }
+
+   public Set<Type> getTypeClosure()
+   {
+      return delegate().getTypeClosure();
+   }
+
+   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+   {
+      return annotations.containsKey(annotationType) || delegate().isAnnotationPresent(annotationType);
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/Reannotated.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,60 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ * This implementation of {@link AnnotatedCallable} is not threadsafe and any synchronization should be performed by the client
+ * 
+ * @author Gavin King
+ * @author Pete Muir
+ *
+ * @param <X>
+ */
+public abstract class ReannotatedCallable<X> extends ReannotatedMember<X> implements AnnotatedCallable<X>
+{
+
+   private final List<ReannotatedParameter<X>> parameters = new ArrayList<ReannotatedParameter<X>>();
+
+   public ReannotatedCallable(ReannotatedType<X> declaringType, List<AnnotatedParameter<X>> params)
+   {
+      super(declaringType);
+      for (AnnotatedParameter<X> param : params)
+      {
+         parameters.add(new ReannotatedParameter<X>(param, this, param.getPosition()));
+      }
+   }
+
+   @Override
+   protected abstract AnnotatedCallable<X> delegate();
+
+   public List<AnnotatedParameter<X>> getParameters()
+   {
+      return new ArrayList<AnnotatedParameter<X>>(parameters);
+   }
+
+   public ReannotatedParameter<X> getParameter(int pos)
+   {
+      return parameters.get(pos);
+   }
+
+   public <Y extends Annotation> void redefineParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      for (ReannotatedParameter<X> param : parameters)
+      {
+         param.redefine(annotationType, visitor);
+      }
+   }
+
+   @Override
+   public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      redefine(annotationType, visitor);
+      redefineParameters(annotationType, visitor);
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedCallable.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,43 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.reflect.Constructor;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+/**
+ * This implementation of {@link AnnotatedConstructor} is not threadsafe and any synchronization must be performed by the client
+ * 
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedConstructor<X> extends ReannotatedCallable<X> implements AnnotatedConstructor<X>
+{
+
+   private final AnnotatedConstructor<X> constructor;
+
+   ReannotatedConstructor(ReannotatedType<X> declaringType, AnnotatedConstructor<X> constructor)
+   {
+      super(declaringType, constructor.getParameters());
+      this.constructor = constructor;
+   }
+
+   @Override
+   protected AnnotatedConstructor<X> delegate()
+   {
+      return constructor;
+   }
+
+   @Override
+   public Constructor<X> getJavaMember()
+   {
+      return constructor.getJavaMember();
+   }
+
+   @Override
+   public boolean isStatic()
+   {
+      return constructor.isStatic();
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedConstructor.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,50 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+
+/**
+ * This implementation of {@link AnnotatedField} is not threadsafe and any synchronization must be performed by the client
+ * 
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedField<X> extends ReannotatedMember<X> implements AnnotatedField<X>
+{
+
+   private final AnnotatedField<X> field;
+
+   ReannotatedField(ReannotatedType<X> declaringType, AnnotatedField<X> field)
+   {
+      super(declaringType);
+      this.field = field;
+   }
+
+   @Override
+   protected AnnotatedField<X> delegate()
+   {
+      return field;
+   }
+
+   @Override
+   public Field getJavaMember()
+   {
+      return field.getJavaMember();
+   }
+
+   @Override
+   public boolean isStatic()
+   {
+      return field.isStatic();
+   }
+
+   @Override
+   public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      redefine(annotationType, visitor);
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedField.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,51 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+
+import javax.enterprise.inject.spi.AnnotatedMember;
+
+/**
+ * This implementation of {@link AnnotatedMember} is not threadsafe and any synchronization must be performed by the client
+ * 
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public abstract class ReannotatedMember<X> extends Reannotated implements AnnotatedMember<X>
+{
+
+   private final ReannotatedType<X> declaringType;
+
+   ReannotatedMember(ReannotatedType<X> declaringType)
+   {
+      this.declaringType = declaringType;
+   }
+
+   public ReannotatedType<X> getDeclaringType()
+   {
+      return declaringType;
+   }
+
+   @Override
+   protected abstract AnnotatedMember<X> delegate();
+
+   public Member getJavaMember()
+   {
+      return delegate().getJavaMember();
+   }
+
+   public boolean isStatic()
+   {
+      return delegate().isStatic();
+   }
+
+   @Override
+   public Class<?> getJavaClass()
+   {
+      return getJavaMember().getDeclaringClass();
+   }
+
+   public abstract <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor);
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMember.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,43 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+
+/**
+ * This implementation of {@link AnnotatedMethod} is not threadsafe and any synchronization must be performed by the client
+ * 
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedMethod<X> extends ReannotatedCallable<X> implements AnnotatedMethod<X>
+{
+
+   private final AnnotatedMethod<X> method;
+
+   ReannotatedMethod(ReannotatedType<X> declaringType, AnnotatedMethod<X> method)
+   {
+      super(declaringType, method.getParameters());
+      this.method = method;
+   }
+
+   @Override
+   protected AnnotatedMethod<X> delegate()
+   {
+      return method;
+   }
+
+   @Override
+   public Method getJavaMember()
+   {
+      return method.getJavaMember();
+   }
+
+   @Override
+   public boolean isStatic()
+   {
+      return method.isStatic();
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedMethod.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,60 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ * This implementation of {@link AnnotatedParameter} is not threadsafe and any synchronization must be performed by the client
+ * 
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedParameter<X> extends Reannotated implements AnnotatedParameter<X>
+{
+
+   private final AnnotatedParameter<X> parameter;
+   private final ReannotatedCallable<X> callable;
+   private final int pos;
+
+   public ReannotatedParameter(AnnotatedParameter<X> parameter, ReannotatedCallable<X> callable, int pos)
+   {
+      this.parameter = parameter;
+      this.callable = callable;
+      this.pos = pos;
+   }
+
+   @Override
+   protected AnnotatedParameter<X> delegate()
+   {
+      return parameter;
+   }
+
+   public ReannotatedCallable<X> getDeclaringCallable()
+   {
+      return callable;
+   }
+
+   public int getPosition()
+   {
+      return pos;
+   }
+
+   @Override
+   public Class<?> getJavaClass()
+   {
+      Member member = callable.getJavaMember();
+      if (member instanceof Method)
+      {
+         return Method.class.cast(member).getParameterTypes()[pos];
+      }
+      else
+      {
+         return Constructor.class.cast(member).getParameterTypes()[pos];
+      }
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedParameter.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java
===================================================================
--- extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java	                        (rev 0)
+++ extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,239 @@
+package org.jboss.weld.extensions.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ * This implementation of {@link AnnotatedType} is not threadsafe and any synchronization must be performed by the client
+ * 
+ * @author Gavin King
+ *
+ * @param <X>
+ */
+public class ReannotatedType<X> extends Reannotated implements AnnotatedType<X>
+{
+
+   private final AnnotatedType<X> type;
+   private final HashMap<Class<?>, ReannotatedType<?>> types;
+
+   private final Map<Member, ReannotatedField<? super X>> fields;
+   private final Map<Member, ReannotatedMethod<? super X>> methods;
+   private final Map<Member, ReannotatedConstructor<X>> constructors;
+
+   public ReannotatedType(AnnotatedType<X> type)
+   {
+      this(type, new HashMap<Class<?>, ReannotatedType<?>>());
+   }
+
+   public ReannotatedType(AnnotatedType<X> type, HashMap<Class<?>, ReannotatedType<?>> types)
+   {
+      this.type = type;
+      this.types = types;
+
+      fields = new HashMap<Member, ReannotatedField<? super X>>();
+      methods = new HashMap<Member, ReannotatedMethod<? super X>>();
+      constructors = new HashMap<Member, ReannotatedConstructor<X>>();
+
+      for (AnnotatedField<? super X> field : type.getFields())
+      {
+         addField(field);
+      }
+      for (AnnotatedMethod<? super X> method : type.getMethods())
+      {
+         addMethod(method);
+      }
+      for (AnnotatedConstructor<X> constructor : type.getConstructors())
+      {
+         addConstructor(constructor);
+      }
+   }
+   
+   private <Y> ReannotatedType<Y> getDeclaringType(AnnotatedMember<Y> member)
+   {
+      return getSupertype(member.getDeclaringType());
+   }
+
+   @SuppressWarnings("unchecked")
+   private <Y> ReannotatedType<Y> getSupertype(AnnotatedType<Y> supertype)
+   {
+      Class<Y> memberJavaClass = supertype.getJavaClass();
+      if (memberJavaClass == type.getJavaClass())
+      {
+         return (ReannotatedType<Y>) this;
+      }
+      else
+      {
+         ReannotatedType<Y> result = (ReannotatedType<Y>) types.get(memberJavaClass);
+         if (result == null)
+         {
+            result = new ReannotatedType<Y>(supertype, types);
+            types.put(memberJavaClass, result);
+         }
+         return result;
+      }
+   }
+
+   private void addConstructor(AnnotatedConstructor<X> constructor)
+   {
+      constructors.put(constructor.getJavaMember(), new ReannotatedConstructor<X>(this, constructor));
+   }
+
+   @SuppressWarnings("unchecked")
+   private void addMethod(AnnotatedMethod<? super X> method)
+   {
+      Class<? super X> methodJavaClass = method.getDeclaringType().getJavaClass();
+      if (methodJavaClass.isAssignableFrom(type.getJavaClass()))
+      {
+         final ReannotatedMethod<? super X> reannotated;
+         if (methodJavaClass == type.getJavaClass())
+         {
+            reannotated = new ReannotatedMethod(getDeclaringType(method), method);
+         }
+         else
+         {
+            reannotated = getInheritedMethod(method);
+         }
+         methods.put(method.getJavaMember(), reannotated);
+      }
+   }
+
+   @SuppressWarnings("unchecked")
+   private void addField(AnnotatedField<? super X> field)
+   {
+      Class<? super X> fieldJavaClass = field.getDeclaringType().getJavaClass();
+      final ReannotatedField<? super X> reannotated;
+      if (fieldJavaClass.isAssignableFrom(type.getJavaClass()))
+      {
+         if (fieldJavaClass == type.getJavaClass())
+         {
+            reannotated = new ReannotatedField(getDeclaringType(field), field);
+         }
+         else
+         {
+            reannotated = getInheritedField(field);
+         }
+         fields.put(field.getJavaMember(), reannotated);
+      }
+   }
+
+   private <Y> ReannotatedField<? super Y> getInheritedField(AnnotatedField<Y> field)
+   {
+      return getDeclaringType(field).getField(field.getJavaMember());
+   }
+
+   private <Y> ReannotatedMethod<? super Y> getInheritedMethod(AnnotatedMethod<Y> method)
+   {
+      return getDeclaringType(method).getMethod(method.getJavaMember());
+   }
+
+   @Override
+   protected AnnotatedType<X> delegate()
+   {
+      return type;
+   }
+
+   public Set<AnnotatedConstructor<X>> getConstructors()
+   {
+      return new HashSet<AnnotatedConstructor<X>>(constructors.values());
+   }
+
+   public Set<AnnotatedMethod<? super X>> getMethods()
+   {
+      return new HashSet<AnnotatedMethod<? super X>>(methods.values());
+   }
+
+   public Set<AnnotatedField<? super X>> getFields()
+   {
+      return new HashSet<AnnotatedField<? super X>>(fields.values());
+   }
+
+   public ReannotatedConstructor<X> getConstructor(Constructor<X> constructor)
+   {
+      return constructors.get(constructor);
+   }
+
+   public ReannotatedMethod<? super X> getMethod(Method constructor)
+   {
+      return methods.get(constructor);
+   }
+
+   public ReannotatedField<? super X> getField(Field field)
+   {
+      return fields.get(field);
+   }
+
+   public <Y extends Annotation> void redefineConstructors(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      for (ReannotatedConstructor<X> constructor : constructors.values())
+      {
+         constructor.redefine(annotationType, visitor);
+      }
+   }
+
+   public <Y extends Annotation> void redefineMethods(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      for (ReannotatedMethod<? super X> method : methods.values())
+      {
+         method.redefine(annotationType, visitor);
+      }
+   }
+
+   public <Y extends Annotation> void redefineFields(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      for (ReannotatedField<? super X> field : fields.values())
+      {
+         field.redefine(annotationType, visitor);
+      }
+   }
+
+   public <Y extends Annotation> void redefineMembers(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      redefineFields(annotationType, visitor);
+      redefineMethods(annotationType, visitor);
+      redefineConstructors(annotationType, visitor);
+   }
+
+   public <Y extends Annotation> void redefineMembersAndParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      redefineMembers(annotationType, visitor);
+      redefineParameters(annotationType, visitor);
+   }
+
+   public <Y extends Annotation> void redefineParameters(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      for (ReannotatedMethod<? super X> method : methods.values())
+      {
+         method.redefineParameters(annotationType, visitor);
+      }
+      for (ReannotatedConstructor<X> constructor : constructors.values())
+      {
+         constructor.redefineParameters(annotationType, visitor);
+      }
+   }
+
+   public <Y extends Annotation> void redefineAll(Class<Y> annotationType, AnnotationRedefinition<Y> visitor)
+   {
+      redefine(annotationType, visitor);
+      redefineMembersAndParameters(annotationType, visitor);
+   }
+
+   @Override
+   public Class<X> getJavaClass()
+   {
+      return type.getJavaClass();
+   }
+
+}


Property changes on: extensions/trunk/core/src/main/java/org/jboss/weld/extensions/util/ReannotatedType.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Finch.java
===================================================================
--- extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Finch.java	2009-11-24 15:04:50 UTC (rev 5151)
+++ extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Finch.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -12,6 +12,6 @@
    
    public void generateLogMessage()
    {
-      log.info("A test message");
+      log.info("Finch");
    }
 }

Modified: extensions/trunk/core/src/test/java/org/jboss/weld/test/log/LoggerInjectionTest.java
===================================================================
--- extensions/trunk/core/src/test/java/org/jboss/weld/test/log/LoggerInjectionTest.java	2009-11-24 15:04:50 UTC (rev 5151)
+++ extensions/trunk/core/src/test/java/org/jboss/weld/test/log/LoggerInjectionTest.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -20,6 +20,7 @@
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.jboss.testharness.impl.packaging.Classes;
 import org.jboss.weld.test.AbstractWeldTest;
+import org.slf4j.impl.TestLoggerFactory;
 import org.testng.annotations.Test;
 
 /**
@@ -35,17 +36,19 @@
    public void testBasicLogInjection()
    {
       Sparrow bird = getCurrentManager().getInstanceByType(Sparrow.class);
+      TestLoggerFactory.INSTANCE.getLogger("").reset();
       bird.generateLogMessage();
-      assert TestAppender.getLastEvent() != null;
-      assert TestAppender.getLastEvent().getLoggerName().equals("org.jboss.weld.test.log.Sparrow");
+      assert TestLoggerFactory.INSTANCE.getLogger("").getLastMessage() != null;
+      assert TestLoggerFactory.INSTANCE.getLogger("").getLastMessage().equals("Sparrow");
    }
    
    @Test
    public void testCategorySpecifiedLogger()
    {
       Finch bird = getCurrentManager().getInstanceByType(Finch.class);
+      TestLoggerFactory.INSTANCE.getLogger("").reset();
       bird.generateLogMessage();
-      assert TestAppender.getLastEvent() != null;
-      assert TestAppender.getLastEvent().getLoggerName().equals("Finch");
+      assert TestLoggerFactory.INSTANCE.getLogger("").getLastMessage() != null;
+      assert TestLoggerFactory.INSTANCE.getLogger("").getLastMessage().equals("Finch");
    }
 }

Modified: extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Sparrow.java
===================================================================
--- extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Sparrow.java	2009-11-24 15:04:50 UTC (rev 5151)
+++ extensions/trunk/core/src/test/java/org/jboss/weld/test/log/Sparrow.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -11,6 +11,6 @@
    
    public void generateLogMessage()
    {
-      log.info("A test message");
+      log.info("Sparrow");
    }
 }

Deleted: extensions/trunk/core/src/test/java/org/jboss/weld/test/log/TestAppender.java
===================================================================
--- extensions/trunk/core/src/test/java/org/jboss/weld/test/log/TestAppender.java	2009-11-24 15:04:50 UTC (rev 5151)
+++ extensions/trunk/core/src/test/java/org/jboss/weld/test/log/TestAppender.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -1,21 +0,0 @@
-package org.jboss.weld.test.log;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.varia.NullAppender;
-
-public class TestAppender extends NullAppender
-{
-   private static LoggingEvent lastEvent;
-   
-   @Override
-   public void doAppend(LoggingEvent event)
-   {
-      lastEvent = event;
-   }
-
-   public static LoggingEvent getLastEvent()
-   {
-      return lastEvent;
-   }
-
-}

Added: extensions/trunk/core/src/test/java/org/slf4j/impl/StaticLoggerBinder.java
===================================================================
--- extensions/trunk/core/src/test/java/org/slf4j/impl/StaticLoggerBinder.java	                        (rev 0)
+++ extensions/trunk/core/src/test/java/org/slf4j/impl/StaticLoggerBinder.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,82 @@
+/* 
+ * Copyright (c) 2004-2007 QOS.ch
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free  of charge, to any person obtaining
+ * a  copy  of this  software  and  associated  documentation files  (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute,  sublicense, and/or sell  copies of  the Software,  and to
+ * permit persons to whom the Software  is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The  above  copyright  notice  and  this permission  notice  shall  be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.LoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ * The binding of {@link LoggerFactory} class with an actual instance of
+ * {@link ILoggerFactory} is performed using information returned by this class.
+ * 
+ * 
+ * @author Pete Muir
+ */
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+
+  /**
+   * The unique instance of this class.
+   * 
+   */
+  private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+  
+  /**
+   * Return the singleton of this class.
+   * 
+   * @return the StaticLoggerBinder singleton
+   */
+  public static final StaticLoggerBinder getSingleton() {
+    return SINGLETON;
+  }
+
+  
+  /**
+   * Declare the version of the SLF4J API this implementation is compiled
+   * against. The value of this field is usually modified with each release.
+   */
+  // to avoid constant folding by the compiler, this field must *not* be final
+  public static String REQUESTED_API_VERSION = "1.5.9.RC1";  // !final
+  
+  private static final String loggerFactoryClassStr = TestLoggerFactory.class.getName();
+
+  /**
+   * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
+   * method should always be the same object
+   */
+  private final ILoggerFactory loggerFactory;
+  
+  private StaticLoggerBinder() {
+    loggerFactory = TestLoggerFactory.INSTANCE;
+  }
+  
+  public ILoggerFactory getLoggerFactory() {
+    return loggerFactory;
+  }
+  
+  public String getLoggerFactoryClassStr() {
+    return loggerFactoryClassStr;
+  }   
+}


Property changes on: extensions/trunk/core/src/test/java/org/slf4j/impl/StaticLoggerBinder.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/test/java/org/slf4j/impl/StaticMarkerBinder.java
===================================================================
--- extensions/trunk/core/src/test/java/org/slf4j/impl/StaticMarkerBinder.java	                        (rev 0)
+++ extensions/trunk/core/src/test/java/org/slf4j/impl/StaticMarkerBinder.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,69 @@
+/* 
+ * Copyright (c) 2004-2007 QOS.ch
+ * All rights reserved.
+ * 
+ * Permission is hereby granted, free  of charge, to any person obtaining
+ * a  copy  of this  software  and  associated  documentation files  (the
+ * "Software"), to  deal in  the Software without  restriction, including
+ * without limitation  the rights to  use, copy, modify,  merge, publish,
+ * distribute,  sublicense, and/or sell  copies of  the Software,  and to
+ * permit persons to whom the Software  is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The  above  copyright  notice  and  this permission  notice  shall  be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
+ * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
+ * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.MarkerFactory;
+import org.slf4j.helpers.BasicMarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+/**
+ * 
+ * The binding of {@link MarkerFactory} class with an actual instance of 
+ * {@link IMarkerFactory} is performed using information returned by this class. 
+ * 
+ * @author Ceki G&uuml;lc&uuml;
+ */
+public class StaticMarkerBinder implements MarkerFactoryBinder {
+
+  /**
+   * The unique instance of this class.
+   */
+  public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+  
+  final IMarkerFactory markerFactory = new BasicMarkerFactory();
+  
+  private StaticMarkerBinder() {
+  }
+  
+  /**
+   * Currently this method always returns an instance of 
+   * {@link BasicMarkerFactory}.
+   */
+  public IMarkerFactory getMarkerFactory() {
+    return markerFactory;
+  }
+  
+  /**
+   * Currently, this method returns the class name of
+   * {@link BasicMarkerFactory}.
+   */
+  public String getMarkerFactoryClassStr() {
+    return BasicMarkerFactory.class.getName();
+  }
+  
+  
+}


Property changes on: extensions/trunk/core/src/test/java/org/slf4j/impl/StaticMarkerBinder.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/test/java/org/slf4j/impl/TestLogger.java
===================================================================
--- extensions/trunk/core/src/test/java/org/slf4j/impl/TestLogger.java	                        (rev 0)
+++ extensions/trunk/core/src/test/java/org/slf4j/impl/TestLogger.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,206 @@
+package org.slf4j.impl;
+
+import org.slf4j.helpers.MarkerIgnoringBase;
+
+/**
+ * A very limited test logger which records the last info message logged
+ */
+public class TestLogger extends MarkerIgnoringBase
+{
+
+   private String lastMessage;
+   
+   private static final long serialVersionUID = 8313525025872406710L;
+   
+   
+   
+   public String getLastMessage()
+   {
+      return lastMessage;
+   }
+   
+   public void reset()
+   {
+      this.lastMessage = null;
+   }
+
+   public void debug(String msg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void debug(String format, Object arg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void debug(String format, Object[] argArray)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void debug(String msg, Throwable t)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void debug(String format, Object arg1, Object arg2)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void error(String msg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void error(String format, Object arg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void error(String format, Object[] argArray)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void error(String msg, Throwable t)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void error(String format, Object arg1, Object arg2)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void info(String msg)
+   {
+      lastMessage = msg;
+   }
+
+   public void info(String format, Object arg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void info(String format, Object[] argArray)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void info(String msg, Throwable t)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void info(String format, Object arg1, Object arg2)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public boolean isDebugEnabled()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public boolean isErrorEnabled()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public boolean isInfoEnabled()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public boolean isTraceEnabled()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public boolean isWarnEnabled()
+   {
+      // TODO Auto-generated method stub
+      return false;
+   }
+
+   public void trace(String msg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void trace(String format, Object arg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void trace(String format, Object[] argArray)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void trace(String msg, Throwable t)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void trace(String format, Object arg1, Object arg2)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void warn(String msg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void warn(String format, Object arg)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void warn(String format, Object[] argArray)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void warn(String msg, Throwable t)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   public void warn(String format, Object arg1, Object arg2)
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+}


Property changes on: extensions/trunk/core/src/test/java/org/slf4j/impl/TestLogger.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: extensions/trunk/core/src/test/java/org/slf4j/impl/TestLoggerFactory.java
===================================================================
--- extensions/trunk/core/src/test/java/org/slf4j/impl/TestLoggerFactory.java	                        (rev 0)
+++ extensions/trunk/core/src/test/java/org/slf4j/impl/TestLoggerFactory.java	2009-11-24 18:12:22 UTC (rev 5152)
@@ -0,0 +1,16 @@
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+
+public class TestLoggerFactory implements ILoggerFactory
+{
+
+   public final static TestLoggerFactory INSTANCE = new TestLoggerFactory();
+
+   private final TestLogger logger = new TestLogger();
+   
+   public TestLogger getLogger(String name)
+   {
+      return logger;
+   }
+}


Property changes on: extensions/trunk/core/src/test/java/org/slf4j/impl/TestLoggerFactory.java
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the weld-commits mailing list