You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2011/07/26 00:53:30 UTC

svn commit: r1150947 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/intercept/ main/java/org/apache/webbeans/proxy/ main/resources/META-INF/openwebbeans/ test/java/org/apache/webbeans/new...

Author: struberg
Date: Mon Jul 25 22:53:25 2011
New Revision: 1150947

URL: http://svn.apache.org/viewvc?rev=1150947&view=rev
Log:
OWB-549 creating a proxy MethodHandler configuration mechanism

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanInterceptorHandler.java
      - copied, changed from r1150863, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/DummyScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/ProxyMappingTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ApplicationBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ConversationBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScoped.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedContext.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedExtension.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
    openwebbeans/trunk/webbeans-impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1150947&r1=1150946&r2=1150947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java Mon Jul 25 22:53:25 2011
@@ -113,6 +113,9 @@ public class OpenWebBeansConfiguration
     /**EL Adaptor*/
     public static final String EL_ADAPTOR_CLASS = "org.apache.webbeans.spi.adaptor.ELAdaptor";
 
+    /** prefix followed by the fully qualified scope name, for configuring InterceptorHandlers for our proxies.*/
+    public static final String PROXY_MAPPING_PREFIX = "org.apache.webbeans.proxy.mapping.";
+
     /**
      * Use BDABeansXmlScanner to determine if interceptors, decorators, and
      * alternatives are enabled in the beans.xml of a given BDA. For an

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanInterceptorHandler.java (from r1150863, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanInterceptorHandler.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanInterceptorHandler.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java&r1=1150863&r2=1150947&rev=1150947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanInterceptorHandler.java Mon Jul 25 22:53:25 2011
@@ -31,7 +31,7 @@ import org.apache.webbeans.component.Owb
  * we can simply cache this instance inside our bean. We only need to reload this instance
  * if it is null. This happens at the first usage and after the MethodHandler got deserialized</p> 
  */
-public class ApplicationScopedBeanIntereptorHandler extends NormalScopedBeanInterceptorHandler 
+public class ApplicationScopedBeanInterceptorHandler extends NormalScopedBeanInterceptorHandler
 {
     /**default serial id*/
     private static final long serialVersionUID = 1L;
@@ -50,7 +50,7 @@ public class ApplicationScopedBeanIntere
      * @param bean bean
      * @param creationalContext creaitonal context
      */
-    public ApplicationScopedBeanIntereptorHandler(OwbBean<?> bean, CreationalContext<?> creationalContext)
+    public ApplicationScopedBeanInterceptorHandler(OwbBean<?> bean, CreationalContext<?> creationalContext)
     {
         super(bean, creationalContext);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=1150947&r1=1150946&r2=1150947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Mon Jul 25 22:53:25 2011
@@ -20,6 +20,8 @@ package org.apache.webbeans.proxy;
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Type;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -29,7 +31,6 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
@@ -41,12 +42,14 @@ import org.apache.webbeans.annotation.We
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.ResourceBean;
+import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.WebBeansDecorator;
-import org.apache.webbeans.intercept.ApplicationScopedBeanIntereptorHandler;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.DependentScopedBeanInterceptorHandler;
 import org.apache.webbeans.intercept.InterceptorData;
+import org.apache.webbeans.intercept.InterceptorHandler;
 import org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler;
 import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
 import org.apache.webbeans.util.ClassUtil;
@@ -67,7 +70,15 @@ public final class JavassistProxyFactory
     private ConcurrentMap<OwbBean<?>, Class<?>> interceptorProxyClasses = new ConcurrentHashMap<OwbBean<?>, Class<?>>();
     private ConcurrentMap<ResourceBean<?, ?>, Class<?>> resourceBeanProxyClasses = new ConcurrentHashMap<ResourceBean<?,?>, Class<?>>();
     // second level map is indexed on local interface
-    private ConcurrentMap<OwbBean<?>, ConcurrentMap<Class<?>, Class<?>>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>, ConcurrentMap<Class<?>, Class<?>>>();    
+    private ConcurrentMap<OwbBean<?>, ConcurrentMap<Class<?>, Class<?>>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>, ConcurrentMap<Class<?>, Class<?>>>();
+
+    /**
+     * This map contains all configured special Scope->InterceptorHandler mappings.
+     * If no mapping is configured, a {@link org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler} will get created.
+     */
+    private Map<String, Class<? extends InterceptorHandler>> interceptorHandlerClasses =
+            new ConcurrentHashMap<String, Class<? extends InterceptorHandler>>();
+
     
     public   Map<OwbBean<?>, Class<?>> getInterceptorProxyClasses()
     {
@@ -205,24 +216,105 @@ public final class JavassistProxyFactory
             
             if (!(bean instanceof WebBeansDecorator<?>) && !(bean instanceof WebBeansInterceptor<?>))
             {
-                if (bean.getScope().equals(ApplicationScoped.class))
+                setInterceptorMethodHandler((ProxyObject) result, bean, creationalContext);
+            }
+        }
+        catch (Exception e)
+        {
+            WebBeansUtil.throwRuntimeExceptions(e);
+        }
+
+        return result;
+    }
+
+    /**
+     * This helper method will set the correct InterceptorHandler into our proxy.
+     * @param proxyObject
+     * @param bean
+     * @param creationalContext
+     */
+    private void setInterceptorMethodHandler(ProxyObject proxyObject, OwbBean<?> bean, CreationalContext<?> creationalContext)
+    {
+        InterceptorHandler interceptorHandler = null;
+        String scopeClassName = bean.getScope().getName();
+        Class<? extends InterceptorHandler> interceptorHandlerClass = null;
+        if (!interceptorHandlerClasses.containsKey(scopeClassName))
+        {
+            String proxyMappingConfigKey = OpenWebBeansConfiguration.PROXY_MAPPING_PREFIX + scopeClassName;
+            String className = bean.getWebBeansContext().getOpenWebBeansConfiguration().getProperty(proxyMappingConfigKey);
+            if (className != null)
+            {
+                try
                 {
-                    ((ProxyObject)result).setHandler(new ApplicationScopedBeanIntereptorHandler(bean, creationalContext));
+                    interceptorHandlerClass = (Class<? extends InterceptorHandler>) Class.forName(className, true, WebBeansUtil.getCurrentClassLoader());
                 }
-                else 
+                catch (ClassNotFoundException e)
                 {
-                    ((ProxyObject)result).setHandler(new NormalScopedBeanInterceptorHandler(bean, creationalContext));
+                    throw new WebBeansConfigurationException("Configured InterceptorHandler "
+                                                             + className
+                                                             +" cannot be found",
+                                                             e);
                 }
             }
+            else
+            {
+                // we need to explicitely store a class because ConcurrentHashMap will throw a NPE if value == null
+                interceptorHandlerClass = NormalScopedBeanInterceptorHandler.class;
+            }
+
+            interceptorHandlerClasses.put(scopeClassName, interceptorHandlerClass);
         }
-        catch (Exception e)
+        else
         {
-            WebBeansUtil.throwRuntimeExceptions(e);
+            interceptorHandlerClass = interceptorHandlerClasses.get(scopeClassName);
         }
 
-        return result;
+        if (interceptorHandlerClass.equals(NormalScopedBeanInterceptorHandler.class))
+        {
+            // this is faster that way...
+            interceptorHandler = new NormalScopedBeanInterceptorHandler(bean, creationalContext);
+        }
+        else
+        {
+            try
+            {
+                Constructor ct = interceptorHandlerClass.getConstructor(OwbBean.class, CreationalContext.class);
+                interceptorHandler = (InterceptorHandler) ct.newInstance(bean, creationalContext);
+            }
+            catch (NoSuchMethodException e)
+            {
+                throw new WebBeansConfigurationException("Configured InterceptorHandler "
+                                                         + interceptorHandlerClass.getName()
+                                                         +" has the wrong contructor",
+                                                         e);
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new WebBeansConfigurationException("Configured InterceptorHandler "
+                                                         + interceptorHandlerClass.getName()
+                                                         +" has the wrong contructor",
+                                                         e);
+            }
+            catch (InstantiationException e)
+            {
+                throw new WebBeansConfigurationException("Configured InterceptorHandler "
+                                                         + interceptorHandlerClass.getName()
+                                                         +" has the wrong contructor",
+                                                         e);
+            }
+            catch (IllegalAccessException e)
+            {
+                throw new WebBeansConfigurationException("Configured InterceptorHandler "
+                                                         + interceptorHandlerClass.getName()
+                                                         +" has the wrong contructor",
+                                                         e);
+            }
+        }
+
+
+        proxyObject.setHandler(interceptorHandler);
     }
-    
+
     public Object createBuildInBeanProxy(OwbBean<?> bean) 
     {
         Object result = null;

Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1150947&r1=1150946&r2=1150947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Mon Jul 25 22:53:25 2011
@@ -111,3 +111,11 @@ org.apache.webbeans.useBDABeansXMLScanne
 org.apache.webbeans.javassist.useClassLoaderProvider=false
 ################################################################################################
 
+########################### Proxy Implmenentation Mapping ######################################
+# This allows mapping a Scope Annotation class to a specific InterceptorProxy which are
+# typically sub classes of NormalScopedBeanInterceptorHandler
+#
+org.apache.webbeans.proxy.mapping.javax.enterprise.context.RequestScoped=org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler
+org.apache.webbeans.proxy.mapping.javax.enterprise.context.ApplicationScoped=org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler
+
+################################################################################################

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/DummyScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/DummyScopedBeanInterceptorHandler.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/DummyScopedBeanInterceptorHandler.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/DummyScopedBeanInterceptorHandler.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,36 @@
+/*
+ * 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.newtests.proxy;
+
+import org.apache.webbeans.component.OwbBean;
+import org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+/**
+ * We don't do anything special. This is just for testing the
+ * configuration of our scope->proxyMethodHandler mapping.
+ */
+public class DummyScopedBeanInterceptorHandler extends NormalScopedBeanInterceptorHandler
+{
+    public DummyScopedBeanInterceptorHandler(OwbBean<?> bean, CreationalContext<?> creationalContext)
+    {
+        super(bean, creationalContext);
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/ProxyMappingTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/ProxyMappingTest.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/ProxyMappingTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/ProxyMappingTest.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,66 @@
+/*
+ * 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.newtests.proxy;
+
+
+import javassist.util.proxy.ProxyObject;
+import org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler;
+import org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler;
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.proxy.beans.ApplicationBean;
+import org.apache.webbeans.newtests.proxy.beans.ConversationBean;
+import org.apache.webbeans.newtests.proxy.beans.DummyScopedExtension;
+import org.junit.Test;
+import org.junit.Assert;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * Test the mapping of scopes to proxy MethodHandler implementations.
+ */
+public class ProxyMappingTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testProxyMappingConfig()
+    {
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+        addExtension(new DummyScopedExtension());
+        beanClasses.add(ConversationBean.class);
+        beanClasses.add(ApplicationBean.class);
+        startContainer(beanClasses, null);
+
+        ConversationBean conversationBean = getInstance(ConversationBean.class);
+        Assert.assertNotNull(conversationBean);
+        Assert.assertTrue(conversationBean instanceof ProxyObject);
+        Assert.assertNotNull(((ProxyObject) conversationBean).getHandler());
+        Assert.assertEquals(((ProxyObject) conversationBean).getHandler().getClass(), NormalScopedBeanInterceptorHandler.class);
+
+
+        ApplicationBean applicationBean = getInstance(ApplicationBean.class);
+        Assert.assertNotNull(applicationBean);
+        Assert.assertTrue(applicationBean instanceof ProxyObject);
+        Assert.assertNotNull(((ProxyObject) applicationBean).getHandler());
+        Assert.assertEquals(((ProxyObject) applicationBean).getHandler().getClass(), ApplicationScopedBeanInterceptorHandler.class);
+
+    }
+
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ApplicationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ApplicationBean.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ApplicationBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ApplicationBean.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.newtests.proxy.beans;
+
+
+import javax.enterprise.context.ApplicationScoped;
+
+/**
+ * To test the proxy for application scoped beans.
+ */
+@ApplicationScoped
+public class ApplicationBean
+{
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ConversationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ConversationBean.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ConversationBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/ConversationBean.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.newtests.proxy.beans;
+
+
+import javax.enterprise.context.ConversationScoped;
+import java.io.Serializable;
+
+/**
+ * To test the proxy for conversation scoped beans.
+ */
+@ConversationScoped
+public class ConversationBean implements Serializable
+{
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyBean.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyBean.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.newtests.proxy.beans;
+
+import javax.enterprise.context.ConversationScoped;
+
+/**
+ * just a standard dummy scoped
+ */
+@ConversationScoped
+public class DummyBean
+{
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScoped.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScoped.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScoped.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScoped.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.newtests.proxy.beans;
+
+import javax.enterprise.context.NormalScope;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Dummy Scope implementation for testing the proxy methodhandler mapping
+ */
+@Target( { TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+@NormalScope
+@Inherited
+public @interface DummyScoped
+{
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedContext.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedContext.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedContext.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,64 @@
+/*
+ * 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.newtests.proxy.beans;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Context for the DummyScope
+ */
+public class DummyScopedContext implements Context
+{
+    private Map<Contextual<?>, Object> map = new HashMap<Contextual<?>, Object>();
+
+    @Override
+    public <T> T get(Contextual<T> component)
+    {
+        return (T) map.get(component);
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope()
+    {
+        return DummyScoped.class;
+    }
+
+    @Override
+    public <T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
+    {
+        Object obj = map.get(component);
+        if (obj == null)
+        {
+            obj = component.create(creationalContext);
+            map.put(component, obj);
+        }
+        return (T) obj;
+    }
+
+    @Override
+    public boolean isActive()
+    {
+        return true;
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedExtension.java?rev=1150947&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedExtension.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/proxy/beans/DummyScopedExtension.java Mon Jul 25 22:53:25 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.newtests.proxy.beans;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+/**
+ * Register the DummyScopedContext
+ */
+public class DummyScopedExtension implements Extension
+{
+    public void registerDummyScopedContext(@Observes AfterBeanDiscovery afterBeanDiscovery)
+    {
+        afterBeanDiscovery.addContext(new DummyScopedContext());
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1150947&r1=1150946&r2=1150947&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/META-INF/openwebbeans/openwebbeans.properties Mon Jul 25 22:53:25 2011
@@ -29,4 +29,10 @@
 # The key is the Interface, the value the implementation of the service
 
 #use the web metadata as default
-org.apache.webbeans.spi.deployer.MetaDataDiscoveryService=org.apache.webbeans.test.util.OpenWebBeansTestMetaDataDiscoveryService
\ No newline at end of file
+org.apache.webbeans.spi.deployer.MetaDataDiscoveryService=org.apache.webbeans.test.util.OpenWebBeansTestMetaDataDiscoveryService
+
+
+# specific proxy mapping which should get tested
+
+org.apache.webbeans.proxy.mapping.javax.enterprise.context.RequestScoped=org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler
+org.apache.webbeans.proxy.mapping.javax.enterprise.context.ApplicationScoped=org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler