[jboss-cvs] JBossAS SVN: r95118 - projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 19 11:14:50 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-10-19 11:14:50 -0400 (Mon, 19 Oct 2009)
New Revision: 95118

Added:
   projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/AnnotatedTypeWrapper.java
   projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java
Log:
[JBKERNEL-51] Get the stuff working again using the supported API in Weld

Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/AnnotatedTypeWrapper.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/AnnotatedTypeWrapper.java	                        (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/AnnotatedTypeWrapper.java	2009-10-19 15:14:50 UTC (rev 95118)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.kernel.weld.plugins.weld;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ * The annotated type implementations in Weld do not i
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnotatedTypeWrapper
+{
+   private final AnnotatedType<?> annotatedType;
+   
+   private volatile int hashCode;
+   
+   public AnnotatedTypeWrapper(AnnotatedType<?> annotatedType)
+   {
+      if (annotatedType == null)
+         throw new IllegalArgumentException("Null type");
+      this.annotatedType = annotatedType;
+   }
+   
+   AnnotatedType<?> getAnnotatedType()
+   {
+      return annotatedType;
+   }
+   
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof AnnotatedTypeWrapper == false)
+         return false;
+
+      AnnotatedTypeWrapper other = (AnnotatedTypeWrapper)obj;
+      
+      if (this.annotatedType.getJavaClass() != other.annotatedType.getJavaClass())
+         return false;
+      
+      if (this.annotatedType.getAnnotations() == null && other.annotatedType.getAnnotations() != null)
+         return false;
+      if (this.annotatedType.getAnnotations() != null && other.annotatedType.getAnnotations() == null)
+         return false;
+      if (this.annotatedType.getAnnotations() == null && other.annotatedType.getAnnotations() == null)
+         return true;
+
+      return this.annotatedType.getAnnotations().equals(this.annotatedType.getAnnotations());
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = hashCode;
+      if (result == 0)
+      {
+         result = 17;
+         result = 31 * result + annotatedType.hashCode();
+         if (annotatedType.getAnnotations() != null)
+            result = 31 * result + annotatedType.hashCode();
+         
+         hashCode = result;
+      }
+      return 17;
+   }
+}

Added: projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java
===================================================================
--- projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java	                        (rev 0)
+++ projects/kernel/trunk/weld-int/src/main/java/org/jboss/kernel/weld/plugins/weld/ExistingInstanceInjectionTarget.java	2009-10-19 15:14:50 UTC (rev 95118)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.kernel.weld.plugins.weld;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExistingInstanceInjectionTarget<T> implements InjectionTarget<T>
+{
+   InjectionTarget<T> injectionTarget;
+   T instance;
+   
+   public ExistingInstanceInjectionTarget(InjectionTarget<T> injectionTarget, T instance)
+   {
+      this.injectionTarget = injectionTarget;
+      this.instance = instance;
+   }
+   
+   public void inject(T instance, CreationalContext<T> ctx)
+   {
+      injectionTarget.inject(instance, ctx);
+   }
+
+   public void postConstruct(T instance)
+   {
+      injectionTarget.postConstruct(instance);
+   }
+
+   public void preDestroy(T instance)
+   {
+      injectionTarget.preDestroy(instance);
+   }
+
+   public void dispose(T instance)
+   {
+      //No op
+   }
+
+   public Set<InjectionPoint> getInjectionPoints()
+   {
+      return injectionTarget.getInjectionPoints();
+   }
+
+   public T produce(CreationalContext<T> ctx)
+   {
+      return instance;
+   }
+
+}




More information about the jboss-cvs-commits mailing list