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 2014/09/03 23:58:56 UTC
svn commit: r1622367 - in /openwebbeans/trunk:
webbeans-impl/src/main/java/org/apache/webbeans/component/creation/
webbeans-impl/src/test/java/org/apache/webbeans/test/portable/
webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextensi...
Author: struberg
Date: Wed Sep 3 21:58:55 2014
New Revision: 1622367
URL: http://svn.apache.org/r1622367
Log:
Disposal methods must not have an InjectionPoint
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/CustomBeanTest.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopedBean.java
openwebbeans/trunk/webbeans-tck/standalone-suite.xml
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java?rev=1622367&r1=1622366&r2=1622367&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java Wed Sep 3 21:58:55 2014
@@ -30,6 +30,7 @@ import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.DefinitionException;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.Producer;
import javax.inject.Inject;
@@ -178,12 +179,21 @@ public class MethodProducerFactory<P> im
}
if(annotatedMethod.isAnnotationPresent(Inject.class)
- || AnnotationUtil.hasAnnotatedMethodParameterAnnotation(annotatedMethod, Observes.class)
- || annotatedMethod.isAnnotationPresent(Produces.class))
+ || AnnotationUtil.hasAnnotatedMethodParameterAnnotation(annotatedMethod, Observes.class)
+ || annotatedMethod.isAnnotationPresent(Produces.class))
{
- throw new WebBeansConfigurationException("Error in definining disposal method of annotated method : " + annotatedMethod
+ throw new DefinitionException("Error in definining disposal method of annotated method : " + annotatedMethod
+ ". Disposal methods can not be annotated with" + " @Initializer/@Destructor/@Produces annotation or has a parameter annotated with @Observes.");
- }
+ }
+
+ for (AnnotatedParameter param : annotatedMethod.getParameters())
+ {
+ if (param.getBaseType().equals(InjectionPoint.class))
+ {
+ throw new DefinitionException("Error in definining disposal method of annotated method : " + annotatedMethod
+ + ". Disposal methods must not have an InjectionPoint.");
+ }
+ }
}
protected Set<InjectionPoint> createInjectionPoints(Bean<?> bean)
Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/CustomBeanTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/CustomBeanTest.java?rev=1622367&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/CustomBeanTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/CustomBeanTest.java Wed Sep 3 21:58:55 2014
@@ -0,0 +1,176 @@
+/*
+ * 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.test.portable;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.sql.DataSource;
+import java.io.PrintWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Set;
+import java.util.logging.Logger;
+
+/**
+ * Test that custom Bean<T> impls work
+ */
+public class CustomBeanTest
+{
+
+
+ public static class CustomBeanExtension implements Extension
+ {
+ public void addBean(@Observes AfterBeanDiscovery abd, BeanManager beanManager)
+ {
+
+ }
+ }
+
+ public static class MyBean implements Bean<DataSource>
+ {
+ @Override
+ public DataSource create(CreationalContext<DataSource> context)
+ {
+ return new DataSource()
+ {
+ @Override
+ public Connection getConnection() throws SQLException
+ {
+ return null;
+ }
+
+ @Override
+ public Connection getConnection(String username, String password) throws SQLException
+ {
+ return null;
+ }
+
+ @Override
+ public PrintWriter getLogWriter() throws SQLException
+ {
+ return null;
+ }
+
+ @Override
+ public void setLogWriter(PrintWriter out) throws SQLException
+ {
+
+ }
+
+ @Override
+ public void setLoginTimeout(int seconds) throws SQLException
+ {
+
+ }
+
+ @Override
+ public int getLoginTimeout() throws SQLException
+ {
+ return 0;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException
+ {
+ return null;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+ return false;
+ }
+ };
+ }
+
+ @Override
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return null;
+ }
+
+ @Override
+ public Class<?> getBeanClass()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return false;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return null;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ @Override
+ public void destroy(DataSource instance, CreationalContext<DataSource> context)
+ {
+
+ }
+ }
+}
Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopedBean.java?rev=1622367&r1=1622366&r2=1622367&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopedBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopedBean.java Wed Sep 3 21:58:55 2014
@@ -18,6 +18,7 @@
*/
package org.apache.webbeans.test.portable.scopeextension;
+import javax.annotation.PreDestroy;
import java.io.Serializable;
@ExternalTestScoped
@@ -25,6 +26,8 @@ public class ExternalTestScopedBean impl
private static final long serialVersionUID = -917790714891819356L;
+ public static boolean destroyed;
+
private int i = 0;
public int getI() {
@@ -34,4 +37,10 @@ public class ExternalTestScopedBean impl
public void setI(int i) {
this.i = i;
}
+
+ @PreDestroy
+ public void destroyMe()
+ {
+ destroyed = true;
+ }
}
Modified: openwebbeans/trunk/webbeans-tck/standalone-suite.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/standalone-suite.xml?rev=1622367&r1=1622366&r2=1622367&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/standalone-suite.xml (original)
+++ openwebbeans/trunk/webbeans-tck/standalone-suite.xml Wed Sep 3 21:58:55 2014
@@ -68,6 +68,11 @@
<exclude name=".*"/>
</methods>
</class>
+ <class name="org.jboss.cdi.tck.tests.extensions.annotated.delivery.broken.WithAnnotationsAppliedToIllegalContainerLifecycleEventParameterTest">
+ <methods>
+ <exclude name=".*"/>
+ </methods>
+ </class>
<!-- CDITCK-418 -->
<class name="org.jboss.cdi.tck.interceptors.tests.contract.interceptorLifeCycle.environment.jndi.ejb.InterceptorEnvironmentJNDISessionBeanTest">