Author: struberg
Date: Wed Oct 12 13:47:38 2011
New Revision: 1182364
URL: http://svn.apache.org/viewvc?rev=1182364&view=rev
Log:
OWB-589 fix 'passivation capable Dependencies' check
txs 2 Markus Mueller for the unit test!
This will switch our behaviour to the fixed definition of 6.6.4 in CDI-1.1.
Please note that we needed to disable 1 single CDI-1.0 TCK test
but this is basically the way Weld works too atm.
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/NonSerializableParametersTest.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/ProducerWithNonSerializableParameterBean.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/SerializableBean.java
(with props)
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
openwebbeans/trunk/webbeans-tck/standalone-suite.xml
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=1182364&r1=1182363&r2=1182364&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
Wed Oct 12 13:47:38 2011
@@ -694,7 +694,7 @@ public abstract class AbstractOwbBean<T>
public void validatePassivationDependencies()
{
- if(isPassivationCapable() || (this instanceof AbstractProducerBean))
+ if(isPassivationCapable())
{
Set<InjectionPoint> injectionPoints = getInjectionPoints();
for(InjectionPoint injectionPoint : injectionPoints)
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1182364&r1=1182363&r2=1182364&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
Wed Oct 12 13:47:38 2011
@@ -178,5 +178,12 @@ public abstract class AbstractProducerBe
}
return false;
- }
+ }
+
+ public void validatePassivationDependencies()
+ {
+ // don't call super.validatePassivationDependencies()!
+ // the injection points of producers are the parameters of the
producermethod.
+ // since CDI-1.1 we must not check those for is serializable anymore.
+ }
}
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1182364&r1=1182363&r2=1182364&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
Wed Oct 12 13:47:38 2011
@@ -93,13 +93,11 @@ public abstract class AbstractLifeCycle
return webBeansContext;
}
- @Override
public BeanManager getBeanManager()
{
return this.beanManager;
}
- @Override
public void startApplication(Object startupObject)
{
// Initalize Application Context
@@ -134,7 +132,6 @@ public abstract class AbstractLifeCycle
logger.info(OWBLogConst.INFO_0001,
Long.toString(System.currentTimeMillis() - begin));
}
- @Override
public void stopApplication(Object endObject)
{
logger.debug("OpenWebBeans Container is stopping.");
@@ -209,7 +206,6 @@ public abstract class AbstractLifeCycle
return contextsService;
}
- @Override
public void initApplication(Properties properties)
{
afterInitApplication(properties);
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/NonSerializableParametersTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/NonSerializableParametersTest.java?rev=1182364&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/NonSerializableParametersTest.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/NonSerializableParametersTest.java
Wed Oct 12 13:47:38 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.injection.serialization;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import
org.apache.webbeans.newtests.injection.serialization.beans.NonSerializableDependentBean;
+import
org.apache.webbeans.newtests.injection.serialization.beans.ProducerWithNonSerializableParameterBean;
+import
org.apache.webbeans.newtests.injection.serialization.beans.SerializableBean;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * <p>
+ * Test non serializable parameters in producer methods and @Inject
methods.
+ * </p>
+ */
+public class NonSerializableParametersTest extends AbstractUnitTest
+{
+ /**
+ * This tests if the container correctly allows non serializable parameters
+ * for producer methods according to CDI-1.1 spec 6.6.4.
+ */
+ @Test
+ public void testInvalidNonSerializableDependentInjection()
+ {
+ Collection<String> beanXmls = new ArrayList<String>();
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+ beanClasses.add(ProducerWithNonSerializableParameterBean.class);
+ beanClasses.add(SerializableBean.class);
+ beanClasses.add(NonSerializableDependentBean.class);
+
+ try
+ {
+ startContainer(beanClasses, beanXmls);
+ SerializableBean sb = getInstance(SerializableBean.class);
+ Assert.assertNotNull(sb);
+ }
+ finally {
+ shutDownContainer();
+ }
+ }
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/NonSerializableParametersTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/ProducerWithNonSerializableParameterBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/ProducerWithNonSerializableParameterBean.java?rev=1182364&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/ProducerWithNonSerializableParameterBean.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/ProducerWithNonSerializableParameterBean.java
Wed Oct 12 13:47:38 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.injection.serialization.beans;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Produces;
+
+/**
+ * Producer method with non serializable producer method parameters.
+ * See specification issues CDI-140, CDI-141 and CDI-153.
+ * @since CDI-1.1
+ */
+public class ProducerWithNonSerializableParameterBean
+{
+
+ /**
+ * Non serializable parameters did crush in CDI-1.0 but are fine in
CDI-1.1.
+ */
+ @Produces
+ @SessionScoped
+ public SerializableBean newSerializableBean(NonSerializableDependentBean
someParameter)
+ {
+ return new SerializableBean();
+ }
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/ProducerWithNonSerializableParameterBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/SerializableBean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/SerializableBean.java?rev=1182364&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/SerializableBean.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/SerializableBean.java
Wed Oct 12 13:47:38 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.injection.serialization.beans;
+
+import java.io.Serializable;
+
+import javax.enterprise.inject.Typed;
+
+/**
+ * Simple serializable bean.
+ */
+@Typed()
+public class SerializableBean implements Serializable {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 1L;
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/injection/serialization/beans/SerializableBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openwebbeans/trunk/webbeans-tck/standalone-suite.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/standalone-suite.xml?rev=1182364&r1=1182363&r2=1182364&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/standalone-suite.xml (original)
+++ openwebbeans/trunk/webbeans-tck/standalone-suite.xml Wed Oct 12 13:47:38
2011
@@ -96,6 +96,14 @@
</methods>
</class>
+ <!-- see CDI-140 -->
+ <class
+
name="org.jboss.jsr299.tck.tests.context.passivating.broken.passivatingProducerMethodWithNonPassivatingParameter.PassivatingProducerMethodWithNonPassivatingParameterTest">
+ <methods>
+ <exclude
name="testSimpleDependentWebBeanWithNonSerializableImplementationInjectedIntoProducerMethodParameterWithPassivatingScopeFails"></exclude>
+ </methods>
+ </class>
+
</classes>
<packages>