openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1493652 - in /openwebbeans/trunk: webbeans-cdi11/ webbeans-impl/src/main/java/org/apache/webbeans/annotation/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/...
Date Mon, 17 Jun 2013 06:42:32 GMT
Author: arne
Date: Mon Jun 17 06:42:31 2013
New Revision: 1493652

URL: http://svn.apache.org/r1493652
Log:
OWB-846: Implemented Bean metadata injection

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Decorated.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Intercepted.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanMetadataBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorMetadataBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptedOrDecoratedBeanMetadataBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorMetadataBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BeanMetadataProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/MetadataProducer.java
Modified:
    openwebbeans/trunk/webbeans-cdi11/pom.xml
    openwebbeans/trunk/webbeans-cdi11/standalone-suite.xml
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/WebBeansType.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-cdi11/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-cdi11/pom.xml?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-cdi11/pom.xml (original)
+++ openwebbeans/trunk/webbeans-cdi11/pom.xml Mon Jun 17 06:42:31 2013
@@ -187,6 +187,14 @@
                             <value>import javax.enterprise.inject.spi.DeploymentException</value>
                         </replacement>         
                         <replacement>
+                            <token>import org.apache.webbeans.annotation.Intercepted</token>
+                            <value>import javax.enterprise.inject.Intercepted</value>
+                        </replacement>
+                        <replacement>
+                            <token>import org.apache.webbeans.annotation.Decorated</token>
+                            <value>import javax.enterprise.inject.Decorated</value>
+                        </replacement>
+                        <replacement>
                             <token>public class InconsistentSpecializationException
extends DefinitionException</token>
                             <value>public class InconsistentSpecializationException
extends javax.enterprise.inject.spi.DefinitionException</value>
                         </replacement>

Modified: openwebbeans/trunk/webbeans-cdi11/standalone-suite.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-cdi11/standalone-suite.xml?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-cdi11/standalone-suite.xml (original)
+++ openwebbeans/trunk/webbeans-cdi11/standalone-suite.xml Mon Jun 17 06:42:31 2013
@@ -39,12 +39,17 @@
                 <exclude name="org.jboss.cdi.tck.tests.implementation.disposal.method.definition.broken.validation.unsatisfied"
/>
                 <exclude name="org.jboss.cdi.tck.tests.implementation.disposal.method.definition.broken.decorator"
/>
                 <exclude name="org.jboss.cdi.tck.tests.implementation.simple.definition.broken.field"
/>
+                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.injection"
/>
+                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.injection.decorated"
/>
+                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.injection.intercepted"
/>
+                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.typeparam.interceptor"
/>
+                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.typeparam"
/>
+                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.broken.typeparam.decorator"
/>
                 <exclude name="org.jboss.cdi.tck.tests.event.metadata.broken.initializer"
/>
                 <exclude name="org.jboss.cdi.tck.tests.event.broken.raw" />
                 <exclude name="org.jboss.cdi.tck.tests.event.observer.broken.validation.ambiguous"
/>
                 <exclude name="org.jboss.cdi.tck.tests.event.observer.broken.validation.unsatisfied"
/>
                 <exclude name="org.jboss.cdi.tck.tests.interceptors.definition.broken.observer"
/>
-                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata.*"
/>
                 <exclude name="org.jboss.cdi.tck.tests.extensions.observer.broken.exception"
/>
                 <exclude name="org.jboss.cdi.tck.tests.extensions.observer.broken.definitionError"
/>
                 <exclude name="org.jboss.cdi.tck.tests.extensions.annotated.broken.processAnnotatedObserverThrowsException"
/>
@@ -75,7 +80,6 @@
                 <exclude name="org.jboss.cdi.tck.tests.lookup.dynamic.broken.raw" />
                 <exclude name="org.jboss.cdi.tck.tests.deployment.exclude" />
                 <exclude name="org.jboss.cdi.tck.tests.inheritance.generics" />
-                <exclude name="org.jboss.cdi.tck.tests.implementation.builtin.metadata"
/>
                 <exclude name="org.jboss.cdi.tck.tests.implementation.simple.lifecycle.unproxyable"
/>
                 <exclude name="org.jboss.cdi.tck.tests.implementation.producer.field.definition"
/>
                 <exclude name="org.jboss.cdi.tck.tests.implementation.producer.field.lifecycle"
/>
@@ -116,6 +120,7 @@
                 
                 <!-- The following tests are broken and tck issues exist for it -->
                 
+                <!-- We currently implement the wrong behavior -->
                 <!-- https://issues.jboss.org/browse/CDITCK-280 -->
 <!--                 <exclude name="org.jboss.cdi.tck.tests.context.passivating.broken.producer.field"
/>  -->
 

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Decorated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Decorated.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Decorated.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Decorated.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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;
+
+@Target({ PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface Decorated
+{
+}
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Intercepted.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Intercepted.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Intercepted.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/Intercepted.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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;
+
+@Target({ PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface Intercepted
+{
+}
\ No newline at end of file

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanMetadataBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanMetadataBean.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanMetadataBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanMetadataBean.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.component;
+
+import java.lang.reflect.Type;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.TypeLiteral;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.MetadataProducer;
+import org.apache.webbeans.util.CollectionUtil;
+
+/**
+ * Implicit metadata bean definition.
+ * 
+ * @version $Rev: 1493478 $ $Date: 2013-06-16 11:19:42 +0200 (So, 16 Jun 2013) $
+ */
+public class BeanMetadataBean<T> extends BuiltInOwbBean<Bean<T>>
+{
+
+    @SuppressWarnings("serial")
+    public BeanMetadataBean(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext,
+              WebBeansType.METADATA,
+              new BeanAttributesImpl<Bean<T>>(CollectionUtil.<Type>unmodifiableSet(Bean.class,
Contextual.class, Object.class)),
+              new TypeLiteral<Bean<T>>(){}.getRawType(),
+              false,
+              new SimpleProducerFactory<Bean<T>>(new MetadataProducer<Bean<T>>()));
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractOwbBean#isPassivationCapable()
+     */
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return true;
+    }
+    
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorMetadataBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorMetadataBean.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorMetadataBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorMetadataBean.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,58 @@
+/*
+ * 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.component;
+
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.util.TypeLiteral;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.MetadataProducer;
+import org.apache.webbeans.util.CollectionUtil;
+
+/**
+ * Implicit metadata bean definition.
+ * 
+ * @version $Rev: 1493478 $ $Date: 2013-06-16 11:19:42 +0200 (So, 16 Jun 2013) $
+ */
+public class DecoratorMetadataBean<T> extends BuiltInOwbBean<Decorator<T>>
+{
+
+    @SuppressWarnings("serial")
+    public DecoratorMetadataBean(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext,
+              WebBeansType.METADATA,
+              new BeanAttributesImpl<Decorator<T>>(CollectionUtil.<Type>unmodifiableSet(Decorator.class,
Object.class)),
+              new TypeLiteral<Decorator<T>>(){}.getRawType(),
+              false,
+              new SimpleProducerFactory<Decorator<T>>(new MetadataProducer<Decorator<T>>()));
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractOwbBean#isPassivationCapable()
+     */
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return true;
+    }
+    
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptedOrDecoratedBeanMetadataBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptedOrDecoratedBeanMetadataBean.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptedOrDecoratedBeanMetadataBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptedOrDecoratedBeanMetadataBean.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,65 @@
+/*
+ * 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.component;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.enterprise.util.TypeLiteral;
+
+import org.apache.webbeans.annotation.Decorated;
+import org.apache.webbeans.annotation.Intercepted;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.BeanMetadataProducer;
+import org.apache.webbeans.util.CollectionUtil;
+
+/**
+ * Implicit metadata bean definition.
+ * 
+ * @version $Rev: 1493478 $ $Date: 2013-06-16 11:19:42 +0200 (So, 16 Jun 2013) $
+ */
+public class InterceptedOrDecoratedBeanMetadataBean<T> extends BuiltInOwbBean<Bean<T>>
+{
+
+    @SuppressWarnings("serial")
+    public InterceptedOrDecoratedBeanMetadataBean(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext,
+              WebBeansType.METADATA,
+              new BeanAttributesImpl<Bean<T>>(
+                      CollectionUtil.<Type>unmodifiableSet(Bean.class, Contextual.class,
Object.class),
+                      CollectionUtil.<Annotation>unmodifiableSet(new AnnotationLiteral<Intercepted>()
{}, new AnnotationLiteral<Decorated>() {})),
+              new TypeLiteral<Bean<T>>(){}.getRawType(),
+              false,
+              new SimpleProducerFactory<Bean<T>>(new BeanMetadataProducer<Bean<T>>()));
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractOwbBean#isPassivationCapable()
+     */
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return true;
+    }
+    
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorMetadataBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorMetadataBean.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorMetadataBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorMetadataBean.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,58 @@
+/*
+ * 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.component;
+
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.Interceptor;
+import javax.enterprise.util.TypeLiteral;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.MetadataProducer;
+import org.apache.webbeans.util.CollectionUtil;
+
+/**
+ * Implicit metadata bean definition.
+ * 
+ * @version $Rev: 1493478 $ $Date: 2013-06-16 11:19:42 +0200 (So, 16 Jun 2013) $
+ */
+public class InterceptorMetadataBean<T> extends BuiltInOwbBean<Interceptor<T>>
+{
+
+    @SuppressWarnings("serial")
+    public InterceptorMetadataBean(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext,
+              WebBeansType.METADATA,
+              new BeanAttributesImpl<Interceptor<T>>(CollectionUtil.<Type>unmodifiableSet(Interceptor.class,
Object.class)),
+              new TypeLiteral<Interceptor<T>>(){}.getRawType(),
+              false,
+              new SimpleProducerFactory<Interceptor<T>>(new MetadataProducer<Interceptor<T>>()));
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractOwbBean#isPassivationCapable()
+     */
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return true;
+    }
+    
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
Mon Jun 17 06:42:31 2013
@@ -18,10 +18,13 @@
  */
 package org.apache.webbeans.component;
 
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.PassivationCapable;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 
 /**
  * Managed bean implementation of the {@link javax.enterprise.inject.spi.Bean}.
@@ -38,4 +41,22 @@ public class ManagedBean<T> extends Inje
     {
         super(webBeansContext, webBeansType, annotated, beanAttributes, beanClass);
     }
+
+    public T create(CreationalContext<T> creationalContext)
+    {
+        if (!(creationalContext instanceof CreationalContextImpl))
+        {
+            creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext,
this);
+        }
+        CreationalContextImpl<T> creationalContextImpl = (CreationalContextImpl<T>)creationalContext;
+        Bean<T> oldBean = creationalContextImpl.putBean(this);
+        try
+        {
+            return super.create(creationalContext);
+        }
+        finally
+        {
+            creationalContextImpl.putBean(oldBean);
+        }
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/WebBeansType.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/WebBeansType.java?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/WebBeansType.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/WebBeansType.java
Mon Jun 17 06:42:31 2013
@@ -69,5 +69,6 @@ public enum WebBeansType
     USERTRANSACTION,
     PRINCIPAL,
     VALIDATIONFACT,
-    VALIDATION
+    VALIDATION,
+    METADATA
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Mon Jun 17 06:42:31 2013
@@ -258,6 +258,12 @@ public class BeansDeployer
         //Register Event Bean
         beanManager.addInternalBean(webBeansUtil.getEventBean());
         
+        //Register Metadata Beans
+        beanManager.addInternalBean(webBeansUtil.getBeanMetadataBean());
+        beanManager.addInternalBean(webBeansUtil.getInterceptorMetadataBean());
+        beanManager.addInternalBean(webBeansUtil.getDecoratorMetadataBean());
+        beanManager.addInternalBean(webBeansUtil.getInterceptedOrDecoratedBeanMetadataBean());
+        
         //REgister Provider Beans
         OpenWebBeansJavaEEPlugin beanEeProvider = webBeansContext.getPluginLoader().getJavaEEPlugin();
         OpenWebBeansWebPlugin beanWebProvider = webBeansContext.getPluginLoader().getWebPlugin();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Mon Jun 17 06:42:31 2013
@@ -60,7 +60,14 @@ public class CreationalContextImpl<T> im
      */
     private List<DependentCreationalContext<?>> dependentObjects = null;
 
-    /**Contextual bean*/
+    /**
+     * Contains the currently created bean
+     */
+    private Bean<T> bean = null;
+    
+    /**
+     * Contains the currently created contextual, may be a bean, interceptor or decorator

+     */
     private Contextual<T> contextual = null;
 
     private WebBeansContext webBeansContext;
@@ -76,6 +83,10 @@ public class CreationalContextImpl<T> im
      */
     CreationalContextImpl(Contextual<T> contextual, WebBeansContext webBeansContext)
     {
+        if (contextual instanceof Bean)
+        {
+            this.bean = (Bean<T>)contextual;
+        }
         this.contextual = contextual;
         this.webBeansContext = webBeansContext;
     }
@@ -160,7 +171,7 @@ public class CreationalContextImpl<T> im
                     dependentObjects = new ArrayList<DependentCreationalContext<?>>();
                 }
 
-                if (dependent == contextual)
+                if (dependent == bean)
                 {
                     dependentObjects.add(0, dependentCreational);
                 }
@@ -242,7 +253,7 @@ public class CreationalContextImpl<T> im
                     
                 if (maxRemoval == 0)
                 {
-                    throw new WebBeansException("infinite loop detected while destroying
bean " + contextual);
+                    throw new WebBeansException("infinite loop detected while destroying
bean " + bean);
                 }
             }
         }
@@ -259,15 +270,30 @@ public class CreationalContextImpl<T> im
         removeAllDependents();
     }
     
-    /**
-     * Gets owner bean.
-     * @return bean
-     */
-    public Contextual<T> getBean()
+    public Bean<T> getBean()
+    {
+        return bean;
+    }
+
+    public Bean<T> putBean(Bean<T> newBean)
+    {
+        Bean<T> oldBean = bean;
+        bean = newBean;
+        return oldBean;
+    }
+    
+    public Contextual<T> getContextual()
     {
         return contextual;
     }
 
+    public Contextual<T> putContextual(Contextual<T> newContextual)
+    {
+        Contextual<T> oldContextual = contextual;
+        contextual = newContextual;
+        return oldContextual;
+    }
+
     /**
      * Write Object. 
      */
@@ -276,8 +302,8 @@ public class CreationalContextImpl<T> im
     {
         s.writeObject(dependentObjects);
 
-        String id = WebBeansUtil.getPassivationId(contextual);
-        if (contextual != null && id != null)
+        String id = WebBeansUtil.getPassivationId(bean);
+        if (bean != null && id != null)
         {
             s.writeObject(id);
         }
@@ -301,7 +327,7 @@ public class CreationalContextImpl<T> im
         String id = (String) s.readObject();
         if (id != null)
         {
-            contextual = (Contextual<T>) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
+            bean = (Bean<T>) webBeansContext.getBeanManagerImpl().getPassivationCapableBean(id);
         }
 
     }
@@ -312,15 +338,7 @@ public class CreationalContextImpl<T> im
 
         final StringBuilder sb = new StringBuilder("CreationalContext{name=");
 
-        if (contextual instanceof Bean)
-        {
-            Bean bean = (Bean) contextual;
-            sb.append(bean.getBeanClass().getSimpleName());
-        }
-        else
-        {
-            sb.append("unknown");
-        }
+        sb.append(bean.getBeanClass().getSimpleName());
 
         return sb.append("}").toString();
     }

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BeanMetadataProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BeanMetadataProducer.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BeanMetadataProducer.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/BeanMetadataProducer.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,40 @@
+/*
+ * 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 javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+
+public class BeanMetadataProducer<T> extends AbstractProducer<Contextual<T>>
+{
+
+    @Override
+    public Contextual<T> produce(CreationalContext<Contextual<T>> creationalContext)
+    {
+        if (!(creationalContext instanceof CreationalContextImpl))
+        {
+            // TODO What to do here?
+            throw new IllegalStateException("MetadataProducer does work only with CreationalContextImpl");
+        }
+        CreationalContextImpl<T> contextImpl = (CreationalContextImpl<T>)creationalContext;
+        return contextImpl.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=1493652&r1=1493651&r2=1493652&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 Jun 17 06:42:31 2013
@@ -39,6 +39,7 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ExceptionUtil;
 
 import javax.decorator.Delegate;
+import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Disposes;
@@ -177,10 +178,12 @@ public class InjectionTargetImpl<T> exte
     @Override
     public T produce(CreationalContext<T> creationalContext)
     {
-        T instance = newInstance((CreationalContextImpl<T>) creationalContext);
+        CreationalContextImpl<T> creationalContextImpl = (CreationalContextImpl<T>)
creationalContext;
+        T instance = newInstance(creationalContextImpl);
 
         if (proxyClass != null)
         {
+            Contextual<T> oldContextual = creationalContextImpl.getContextual();
             // apply interceptorInfo
             InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
 
@@ -189,12 +192,14 @@ public class InjectionTargetImpl<T> exte
             // create EJB-style interceptors
             for (Interceptor interceptorBean : interceptorInfo.getEjbInterceptors())
             {
+                creationalContextImpl.putContextual(interceptorBean);
                 interceptorInstances.put(interceptorBean, interceptorBean.create(creationalContext));
             }
 
             // create CDI-style interceptors
             for (Interceptor interceptorBean : interceptorInfo.getCdiInterceptors())
             {
+                creationalContextImpl.putContextual(interceptorBean);
                 interceptorInstances.put(interceptorBean, interceptorBean.create(creationalContext));
             }
 
@@ -209,10 +214,10 @@ public class InjectionTargetImpl<T> exte
             {
                 List<Decorator<?>> decorators = interceptorInfo.getDecorators();
                 Map<Decorator<?>, Object> instances = new HashMap<Decorator<?>,
Object>();
-                CreationalContextImpl<T> creationalContextImpl = (CreationalContextImpl<T>)creationalContext;
                 for (int i = decorators.size(); i > 0; i--)
                 {
-                    Decorator<?> decorator = decorators.get(i - 1);
+                    Decorator decorator = decorators.get(i - 1);
+                    creationalContextImpl.putContextual(decorator);
                     creationalContextImpl.putDelegate(delegate);
                     Object decoratorInstance = decorator.create((CreationalContext) creationalContext);
                     instances.put(decorator, decoratorInstance);
@@ -223,6 +228,7 @@ public class InjectionTargetImpl<T> exte
 
             T proxyInstance = pf.createProxyInstance(proxyClass, instance, interceptorHandler);
             instance = proxyInstance;
+            creationalContextImpl.putContextual(oldContextual);
         }
 
         return instance;

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/MetadataProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/MetadataProducer.java?rev=1493652&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/MetadataProducer.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/MetadataProducer.java
Mon Jun 17 06:42:31 2013
@@ -0,0 +1,40 @@
+/*
+ * 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 javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+
+public class MetadataProducer<T> extends AbstractProducer<Contextual<T>>
+{
+
+    @Override
+    public Contextual<T> produce(CreationalContext<Contextual<T>> creationalContext)
+    {
+        if (!(creationalContext instanceof CreationalContextImpl))
+        {
+            // TODO What to do here?
+            throw new IllegalStateException("MetadataProducer does work only with CreationalContextImpl");
+        }
+        CreationalContextImpl<T> contextImpl = (CreationalContextImpl<T>)creationalContext;
+        return contextImpl.getContextual();
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Mon Jun 17 06:42:31 2013
@@ -23,6 +23,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.exception.inject.DefinitionException;
 
 import javax.enterprise.event.Event;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Provider;
 import java.lang.reflect.GenericArrayType;
@@ -505,10 +506,18 @@ public final class ClassUtil
             final Class<?> clazzReqType = (Class<?>)ptReq.getRawType();
             final Type genericSuperClass = clazzBeanType.getGenericSuperclass();
 
-            if(Provider.class.isAssignableFrom(clazzReqType) ||
+            if (Provider.class.isAssignableFrom(clazzReqType) ||
                     Event.class.isAssignableFrom(clazzReqType))
             {
-                if(isClassAssignable(clazzReqType, clazzBeanType))
+                if (isClassAssignable(clazzReqType, clazzBeanType))
+                {
+                    return true;
+                }
+            }
+            else if (Bean.class.isAssignableFrom(clazzReqType))
+            {
+                // May be Bean, Interceptor or Decorator and thus must match directly
+                if (clazzReqType.equals(clazzBeanType))
                 {
                     return true;
                 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1493652&r1=1493651&r2=1493652&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Mon Jun 17 06:42:31 2013
@@ -79,13 +79,17 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.component.AbstractProducerBean;
 import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.BeanManagerBean;
+import org.apache.webbeans.component.BeanMetadataBean;
 import org.apache.webbeans.component.ConversationBean;
+import org.apache.webbeans.component.DecoratorMetadataBean;
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.EventBean;
 import org.apache.webbeans.component.ExtensionBean;
 import org.apache.webbeans.component.InjectionPointBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.InstanceBean;
+import org.apache.webbeans.component.InterceptedOrDecoratedBeanMetadataBean;
+import org.apache.webbeans.component.InterceptorMetadataBean;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.NewBean;
 import org.apache.webbeans.component.NewManagedBean;
@@ -479,6 +483,41 @@ public final class WebBeansUtil
         return new EventBean<T>(webBeansContext);
     }
 
+    /**
+     * Creates a new bean metadata bean.
+     * @return new  bean
+     */
+    public <T> BeanMetadataBean<T> getBeanMetadataBean()
+    {
+        return new BeanMetadataBean<T>(webBeansContext);
+    }
+
+    /**
+     * Creates a new interceptor metadata bean.
+     * @return new bean
+     */
+    public <T> InterceptorMetadataBean<T> getInterceptorMetadataBean()
+    {
+        return new InterceptorMetadataBean<T>(webBeansContext);
+    }
+
+    /**
+     * Creates a new decorator metadata bean.
+     * @return new bean
+     */
+    public <T> DecoratorMetadataBean<T> getDecoratorMetadataBean()
+    {
+        return new DecoratorMetadataBean<T>(webBeansContext);
+    }
+
+    /**
+     * Creates a new metadata bean.
+     * @return new bean
+     */
+    public <T> InterceptedOrDecoratedBeanMetadataBean<T> getInterceptedOrDecoratedBeanMetadataBean()
+    {
+        return new InterceptedOrDecoratedBeanMetadataBean<T>(webBeansContext);
+    }
 
     /**
      * Returns new conversation bean instance.



Mime
View raw message