Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 38A8D10A21 for ; Tue, 1 Jul 2014 10:59:07 +0000 (UTC) Received: (qmail 489 invoked by uid 500); 1 Jul 2014 10:59:07 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 465 invoked by uid 500); 1 Jul 2014 10:59:07 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 453 invoked by uid 99); 1 Jul 2014 10:59:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jul 2014 10:59:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jul 2014 10:59:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 606DB2388994; Tue, 1 Jul 2014 10:58:45 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1607040 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionPointProducer.java webbeans-tck/testng-dev.xml Date: Tue, 01 Jul 2014 10:58:45 -0000 To: commits@openwebbeans.apache.org From: rmannibucau@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140701105845.606DB2388994@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rmannibucau Date: Tue Jul 1 10:58:44 2014 New Revision: 1607040 URL: http://svn.apache.org/r1607040 Log: InjectionPoint injection references the real type even if that's from an Instance Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionPointProducer.java openwebbeans/trunk/webbeans-tck/testng-dev.xml Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=1607040&r1=1607039&r2=1607040&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java Tue Jul 1 10:58:44 2014 @@ -19,10 +19,8 @@ package org.apache.webbeans.inject.impl; import java.io.IOException; -import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.ObjectStreamClass; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; @@ -51,6 +49,7 @@ import org.apache.webbeans.config.WebBea import org.apache.webbeans.event.EventUtil; import org.apache.webbeans.portable.AnnotatedElementFactory; import org.apache.webbeans.util.Asserts; +import org.apache.webbeans.util.OwbCustomObjectInputStream; import org.apache.webbeans.util.WebBeansUtil; class InjectionPointImpl implements InjectionPoint, Serializable @@ -215,28 +214,11 @@ class InjectionPointImpl implements Inje } - public class CustomObjectInputStream extends ObjectInputStream - { - private ClassLoader classLoader; - - public CustomObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException - { - super(in); - this.classLoader = classLoader; - } - - @Override - protected Class resolveClass(ObjectStreamClass desc) throws ClassNotFoundException - { - return Class.forName(desc.getName(), false, classLoader); - } - } - @SuppressWarnings("unchecked") private void readObject(java.io.ObjectInputStream inp) throws IOException, ClassNotFoundException { - ObjectInputStream in = new CustomObjectInputStream(inp, WebBeansUtil.getCurrentClassLoader()); + ObjectInputStream in = new OwbCustomObjectInputStream(inp, WebBeansUtil.getCurrentClassLoader()); Class beanClass = (Class)in.readObject(); Set anns = new HashSet(); Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionPointProducer.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionPointProducer.java?rev=1607040&r1=1607039&r2=1607040&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionPointProducer.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionPointProducer.java Tue Jul 1 10:58:44 2014 @@ -18,13 +18,27 @@ */ package org.apache.webbeans.portable; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.annotation.Annotation; +import java.lang.reflect.Member; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.Map; +import java.util.Set; +import javax.enterprise.inject.Instance; +import javax.enterprise.inject.spi.Annotated; +import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.InjectionPoint; import javax.enterprise.inject.spi.Interceptor; import org.apache.webbeans.context.creational.CreationalContextImpl; import org.apache.webbeans.util.ClassUtil; +import org.apache.webbeans.util.OwbCustomObjectInputStream; +import org.apache.webbeans.util.WebBeansUtil; public class InjectionPointProducer extends AbstractProducer { @@ -48,7 +62,25 @@ public class InjectionPointProducer exte } try { - return creationalContextImpl.getInjectionPoint(); + final InjectionPoint injectionPoint = creationalContextImpl.getInjectionPoint(); + if (injectionPoint == null) + { + return null; + } + + final Type type = injectionPoint.getType(); + if (ParameterizedType.class.isInstance(type)) + { + final ParameterizedType parameterizedType = ParameterizedType.class.cast(type); + if (parameterizedType.getRawType() == Instance.class) + { + final Bean bean = creationalContextImpl.getBean(); + return new InjectionPointDelegate( + injectionPoint, + bean.getBeanClass() != null ? bean.getBeanClass() : parameterizedType.getActualTypeArguments()[0]); + } + } + return injectionPoint; } finally { @@ -61,4 +93,72 @@ public class InjectionPointProducer exte { // nothing to do } + + private class InjectionPointDelegate implements InjectionPoint, Serializable + { + private InjectionPoint ip; + private Type type; + + public InjectionPointDelegate(final InjectionPoint injectionPoint, final Type type) + { + this.ip = injectionPoint; + this.type = type; + } + + @Override + public Type getType() + { + return type; + } + + @Override + public Set getQualifiers() + { + return ip.getQualifiers(); + } + + @Override + public Bean getBean() + { + return ip.getBean(); + } + + @Override + public Member getMember() + { + return ip.getMember(); + } + + @Override + public Annotated getAnnotated() + { + return ip.getAnnotated(); + } + + @Override + public boolean isDelegate() + { + return ip.isDelegate(); + } + + @Override + public boolean isTransient() + { + return ip.isTransient(); + } + + private void readObject(final ObjectInputStream inp) throws IOException, ClassNotFoundException + { + final OwbCustomObjectInputStream owbCustomObjectInputStream = new OwbCustomObjectInputStream(inp, WebBeansUtil.getCurrentClassLoader()); + type = Type.class.cast(owbCustomObjectInputStream.readObject()); + ip = InjectionPoint.class.cast(owbCustomObjectInputStream.readObject()); + } + + private void writeObject(final ObjectOutputStream op) throws IOException + { + final ObjectOutputStream out = new ObjectOutputStream(op); + out.writeObject(type); + out.writeObject(ip); + } + } } Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1607040&r1=1607039&r2=1607040&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original) +++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Tue Jul 1 10:58:44 2014 @@ -19,7 +19,7 @@ + name="org.jboss.cdi.tck.tests.lookup.injectionpoint.dynamic.DynamicInjectionPointTest" />