Author: arne
Date: Mon Jan 14 20:57:22 2013
New Revision: 1433125

URL: http://svn.apache.org/viewvc?rev=1433125&view=rev
Log:
OWB-755: Created ExtensionProducer

Added:
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
Modified:
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java?rev=1433125&r1=1433124&r2=1433125&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
 Mon Jan 14 20:57:22 2013
@@ -25,7 +25,6 @@ import javax.enterprise.context.Applicat
 import javax.enterprise.context.spi.CreationalContext;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.portable.events.ExtensionLoader;
 import org.apache.webbeans.util.AnnotationUtil;
 
 /**
@@ -35,6 +34,7 @@ import org.apache.webbeans.util.Annotati
  *
  * @param <T> type info
  */
+// TODO : Should not extend InjectionTargetBean, but AbstractOwbBean
 public class ExtensionBean<T> extends InjectionTargetBean<T>
 {
     /**
@@ -62,9 +62,7 @@ public class ExtensionBean<T> extends In
     @Override
     protected T createComponentInstance(CreationalContext<T> creationalContext)
     {
-        ExtensionLoader loader = getWebBeansContext().getExtensionLoader();
-        
-        return loader.getBeanInstance(this);
+        return getInjectionTarget().produce(creationalContext);
     }
     
     /**

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java?rev=1433125&r1=1433124&r2=1433125&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
 Mon Jan 14 20:57:22 2013
@@ -22,8 +22,13 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.Set;
 
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+
 import org.apache.webbeans.component.ExtensionBean;
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.ExtensionProducer;
 
 public class ExtensionBeanBuilder<T> extends 
AbstractInjectionTargetBeanBuilder<T, ExtensionBean<T>>
 {
@@ -33,6 +38,13 @@ public class ExtensionBeanBuilder<T> ext
         super(webBeansContext, 
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type));
     }
 
+    protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> 
annotatedType,
+                                                      Set<InjectionPoint> 
points,
+                                                      WebBeansContext 
webBeansContext)
+    {
+        return new ExtensionProducer<T>(annotatedType, points, 
webBeansContext);
+    }
+
     @Override
     protected ExtensionBean<T> createBean(Set<Type> types,
                                           Set<Annotation> qualifiers,

Added: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java?rev=1433125&view=auto
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
 (added)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
 Mon Jan 14 20:57:22 2013
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.portable;
+
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.portable.events.ExtensionLoader;
+
+public class ExtensionProducer<T> extends InjectionTargetImpl<T>
+{
+
+    public ExtensionProducer(AnnotatedType<T> annotatedType,
+                             Set<InjectionPoint> points,
+                             WebBeansContext webBeansContext)
+    {
+        super(annotatedType, points, webBeansContext);
+    }
+
+    @Override
+    public T produce(CreationalContext<T> creationalContext)
+    {
+        ExtensionLoader loader = context.getExtensionLoader();
+        
+        return loader.getBeanInstance((Bean<T>)((CreationalContextImpl<T>) 
creationalContext).getBean());
+    }
+}

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java?rev=1433125&r1=1433124&r2=1433125&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
 Mon Jan 14 20:57:22 2013
@@ -52,7 +52,7 @@ public class InjectionTargetImpl<T> exte
 
     private AnnotatedType<T> type;
     private AnnotatedConstructor<T> constructor;
-    private WebBeansContext context;
+    protected final WebBeansContext context;
 
     /**
      * If the InjectionTarget has a &#064;PostConstruct method, 
<code>null</code> if not.
@@ -60,7 +60,7 @@ public class InjectionTargetImpl<T> exte
      * This methods must have the signature <code>void METHOD();</code>
      * They are ordered as <b>superclass first</b>.
      */
-    private AnnotatedMethod[] postConstructMethods;
+    private AnnotatedMethod<T>[] postConstructMethods;
 
     /**
      * If the InjectionTarget has a &#064;PreDestroy method, <code>null</code> 
if not.
@@ -68,7 +68,7 @@ public class InjectionTargetImpl<T> exte
      * This methods must have the signature <code>void METHOD();</code>
      * They are ordered as <b>subclass first</b>.
      */
-    private AnnotatedMethod[] preDestroyMethods;
+    private AnnotatedMethod<T>[] preDestroyMethods;
 
     public InjectionTargetImpl(AnnotatedType<T> annotatedType, 
Set<InjectionPoint> points, WebBeansContext webBeansContext)
     {


Reply via email to