openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1559290 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ test/java/org/apache/webbeans/newtests/contexts/ test/java/org/apache/webbeans/newtests/portable/ test/java/org/apache/webbeans/newtests/portable/...
Date Fri, 17 Jan 2014 23:56:01 GMT
Author: struberg
Date: Fri Jan 17 23:56:01 2014
New Revision: 1559290

URL: http://svn.apache.org/r1559290
Log:
OWB-924 internal beans did miss PassivationCapable


Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/BeanWithExtensionInjected.java
  (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1559290&r1=1559289&r2=1559290&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
Fri Jan 17 23:56:01 2014
@@ -29,6 +29,7 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.CreationException;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.PassivationCapable;
 import javax.enterprise.inject.spi.Producer;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
@@ -46,7 +47,9 @@ import java.util.logging.Logger;
  * @see javax.enterprise.inject.spi.Bean
  * 
  */
-public abstract class AbstractOwbBean<T> extends BeanAttributesImpl<T> implements
OwbBean<T>
+public abstract class AbstractOwbBean<T>
+        extends BeanAttributesImpl<T>
+        implements OwbBean<T>, PassivationCapable
 {
     /**Logger instance*/
     protected Logger logger = null;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java?rev=1559290&r1=1559289&r2=1559290&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/SerializationTest.java
Fri Jan 17 23:56:01 2014
@@ -189,12 +189,12 @@ public class SerializationTest extends A
         Assert.assertTrue(ssb2.getApp().getI() == 4711);
     }
 
-    private byte[] serializeBean(Bean<?> bean) throws IOException
+    public static byte[] serializeBean(Bean<?> bean) throws IOException
     {
         return serializeObject(bean);
     }
     
-    private byte[] serializeObject(Object o) throws IOException
+    public static byte[] serializeObject(Object o) throws IOException
     {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
@@ -202,12 +202,12 @@ public class SerializationTest extends A
         return baos.toByteArray();
     }
 
-    private Bean<?> deSerializeBean(byte[] serial) throws IOException, ClassNotFoundException
+    public static Bean<?> deSerializeBean(byte[] serial) throws IOException, ClassNotFoundException
     {
         return (Bean<?>) deSerializeObject(serial);
     }
     
-    private Object deSerializeObject(byte[] serial) throws IOException, ClassNotFoundException
+    public static Object deSerializeObject(byte[] serial) throws IOException, ClassNotFoundException
     {
         ByteArrayInputStream bais = new ByteArrayInputStream(serial);
         ObjectInputStream ois = new ObjectInputStream(bais);

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java?rev=1559290&r1=1559289&r2=1559290&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/ExtensionTest.java
Fri Jan 17 23:56:01 2014
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Set;
 
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.PassivationCapable;
 
 import junit.framework.Assert;
 
@@ -30,10 +31,12 @@ import org.apache.webbeans.annotation.De
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.contexts.SerializationTest;
 import org.apache.webbeans.newtests.portable.alternative.Egg;
 import org.apache.webbeans.newtests.portable.alternative.HalfEgg;
 import org.apache.webbeans.newtests.portable.alternative.WoodEgg;
 import org.apache.webbeans.newtests.portable.events.extensions.AlternativeExtension;
+import org.apache.webbeans.newtests.portable.scopeextension.BeanWithExtensionInjected;
 import org.apache.webbeans.newtests.portable.scopeextension.ExternalTestScopeExtension;
 import org.apache.webbeans.newtests.portable.scopeextension.ExternalTestScoped;
 import org.apache.webbeans.newtests.portable.scopeextension.ExternalTestScopedBean;
@@ -162,4 +165,28 @@ public class ExtensionTest extends Abstr
 
     }
 
+    @Test
+    public void testInjectedExtensionSerialisation() throws Exception
+    {
+        addExtension(new ExternalTestScopeExtension());
+        startContainer(BeanWithExtensionInjected.class);
+
+        BeanWithExtensionInjected instance = getInstance(BeanWithExtensionInjected.class);
+        Assert.assertNotNull(instance);
+        Assert.assertNotNull(instance.getExtension());
+
+        Bean<ExternalTestScopeExtension> extensionBean = getBean(ExternalTestScopeExtension.class);
+        Assert.assertNotNull(extensionBean);
+        Assert.assertTrue(extensionBean instanceof PassivationCapable);
+        Assert.assertNotNull(((PassivationCapable) extensionBean).getId());
+
+        byte[] ba = SerializationTest.serializeObject(instance);
+        Assert.assertNotNull(ba);
+        BeanWithExtensionInjected serializedInstance
+                = (BeanWithExtensionInjected) SerializationTest.deSerializeObject(ba);
+        Assert.assertNotNull(serializedInstance);
+        Assert.assertNotNull(serializedInstance.getExtension());
+
+    }
+
 }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/BeanWithExtensionInjected.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/BeanWithExtensionInjected.java?rev=1559290&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/BeanWithExtensionInjected.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/BeanWithExtensionInjected.java
Fri Jan 17 23:56:01 2014
@@ -0,0 +1,39 @@
+/*
+ * 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.portable.scopeextension;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+import java.io.Serializable;
+
+/**
+ * This passivating bean has a CDI Extension injected.
+ * CDI Extensions are ApplicationScoped and thus should be
+ * serializable due to their proxy.
+ */
+@SessionScoped
+public class BeanWithExtensionInjected implements Serializable
+{
+    private @Inject ExternalTestScopeExtension extension;
+
+    public ExternalTestScopeExtension getExtension()
+    {
+        return extension;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/scopeextension/BeanWithExtensionInjected.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message