[webbeans-commits] Webbeans SVN: r3239 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-26 13:38:25 -0400 (Sun, 26 Jul 2009)
New Revision: 3239
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java
Log:
mark test working
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java 2009-07-26 17:35:08 UTC (rev 3238)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java 2009-07-26 17:38:25 UTC (rev 3239)
@@ -32,7 +32,7 @@
public class BindingAnnotationWithMemberTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "5.3.5", id = "cb")
public void testAnnotationMemberWithoutNonBinding()
{
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3238 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-26 13:35:08 -0400 (Sun, 26 Jul 2009)
New Revision: 3238
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/TheBeatles.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Watch.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Expensive_Broken.java
Log:
The annotation must be used for it to be validated. The spec does *not* require validation of all annotations on the classpath AFAIK
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java 2009-07-25 23:25:44 UTC (rev 3237)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/BindingAnnotationWithMemberTest.java 2009-07-26 17:35:08 UTC (rev 3238)
@@ -17,6 +17,7 @@
package org.jboss.jsr299.tck.tests.lookup.binding.members.annotation;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.jsr299.tck.DefinitionError;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
@@ -28,12 +29,14 @@
*/
@Artifact
@ExpectedDeploymentException(DefinitionError.class)
-public class BindingAnnotationWithMemberTest {
+public class BindingAnnotationWithMemberTest extends AbstractJSR299Test
+{
- @Test(groups="ri-broken")
- @SpecAssertion(section="5.3.5", id="cb")
- public void testAnnotationMemberWithoutNonBinding() {
- assert false;
- }
-
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "5.3.5", id = "cb")
+ public void testAnnotationMemberWithoutNonBinding()
+ {
+ assert false;
+ }
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Expensive_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Expensive_Broken.java 2009-07-25 23:25:44 UTC (rev 3237)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Expensive_Broken.java 2009-07-26 17:35:08 UTC (rev 3238)
@@ -16,20 +16,21 @@
*/
package org.jboss.jsr299.tck.tests.lookup.binding.members.annotation;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.inject.BindingType;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
@BindingType
@Retention(RUNTIME)
@Target( { METHOD, FIELD, PARAMETER, TYPE })
-@interface Expensive_Broken {
- SimpleAnnotation member();
+@interface Expensive_Broken
+{
+ SimpleAnnotation member();
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/TheBeatles.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/TheBeatles.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/TheBeatles.java 2009-07-26 17:35:08 UTC (rev 3238)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.lookup.binding.members.annotation;
+
+/**
+ * @author pmuir
+ *
+ */
+public class TheBeatles
+{
+
+ @Expensive_Broken(member = @SimpleAnnotation) Watch watch;
+
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/TheBeatles.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Watch.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Watch.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Watch.java 2009-07-26 17:35:08 UTC (rev 3238)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.lookup.binding.members.annotation;
+
+/**
+ * @author pmuir
+ *
+ */
+@Expensive_Broken(member = @SimpleAnnotation)
+public class Watch
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/binding/members/annotation/Watch.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3237 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 19:25:44 -0400 (Sat, 25 Jul 2009)
New Revision: 3237
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java
Log:
Comment out annotations until we support EJB 3.1
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java 2009-07-25 22:28:54 UTC (rev 3236)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java 2009-07-25 23:25:44 UTC (rev 3237)
@@ -16,16 +16,15 @@
*/
package org.jboss.jsr299.tck.tests.implementation.enterprise.definition;
-import javax.ejb.LocalBean;
-import javax.ejb.Stateful;
/**
* @author pmuir
*
*/
-@Stateful
-@LocalBean
+// TODO Enable when we support EJB 3.1
+//@Stateful
+//@LocalBean
public class Retriever
{
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3236 - ri/trunk/impl/src/main/java/org/jboss/webbeans/persistence and 5 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 18:28:54 -0400 (Sat, 25 Jul 2009)
New Revision: 3236
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/ForwardingJpaServices.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java
Log:
Add support for injecting PUs
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -35,7 +35,6 @@
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.injection.ConstructorInjectionPoint;
import org.jboss.webbeans.injection.FieldInjectionPoint;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
@@ -50,7 +49,6 @@
import org.jboss.webbeans.persistence.spi.JpaServices;
import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.util.Names;
-import org.jboss.webbeans.util.Reflections;
/**
* Represents a simple bean
@@ -72,11 +70,14 @@
private WBMethod<?> preDestroy;
private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+ private HashSet<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
private SimpleBean<?> specializedBean;
+
+
/**
* Creates a simple, annotation defined Web Bean
*
@@ -191,35 +192,23 @@
{
this.ejbInjectionPoints.add(FieldInjectionPoint.of(this, field));
}
-
- for (WBMethod<?> method : annotatedItem.getAnnotatedMethods(ejbAnnotationType))
- {
- this.ejbInjectionPoints.add(MethodInjectionPoint.of(this, method));
- }
}
- protected void initPersistenceUnitInjectionPoints()
+ protected void initJpaInjectionPoints()
{
+ this.persistenceContextInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
this.persistenceUnitInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
- Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
- Object extendedPersistenceContextEnum = manager.getServices().get(PersistenceApiAbstraction.class).EXTENDED_PERSISTENCE_CONTEXT_ENUM_VALUE;
+ Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
for (WBField<?> field : annotatedItem.getAnnotatedFields(persistenceContextAnnotationType))
{
- if (extendedPersistenceContextEnum.equals(Reflections.invokeAndWrap("type", field.getAnnotation(persistenceContextAnnotationType))))
- {
- throw new DefinitionException("Cannot inject an extended persistence context into " + field);
- }
- this.persistenceUnitInjectionPoints.add(FieldInjectionPoint.of(this, field));
+ this.persistenceContextInjectionPoints.add(FieldInjectionPoint.of(this, field));
}
-
- for (WBMethod<?> method : annotatedItem.getAnnotatedMethods(persistenceContextAnnotationType))
+
+ Class<? extends Annotation> persistenceUnitAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_UNIT_ANNOTATION_CLASS;
+ for (WBField<?> field : annotatedItem.getAnnotatedFields(persistenceUnitAnnotationType))
{
- if (extendedPersistenceContextEnum.equals(Reflections.invokeAndWrap("type", method.getAnnotation(persistenceContextAnnotationType))))
- {
- throw new DefinitionException("Cannot inject an extended persistence context into " + method);
- }
- this.persistenceUnitInjectionPoints.add(MethodInjectionPoint.of(this, method));
+ this.persistenceUnitInjectionPoints.add(FieldInjectionPoint.of(this, field));
}
}
@@ -253,9 +242,14 @@
if (jpaServices != null)
{
+ for (WBInjectionPoint<?, ?> injectionPoint : persistenceContextInjectionPoints)
+ {
+ Object pcInstance = jpaServices.resolvePersistenceContext(injectionPoint);
+ injectionPoint.inject(beanInstance, pcInstance);
+ }
for (WBInjectionPoint<?, ?> injectionPoint : persistenceUnitInjectionPoints)
{
- Object puInstance = jpaServices.resolvePersistenceContext(injectionPoint);
+ Object puInstance = jpaServices.resolvePersistenceUnit(injectionPoint);
injectionPoint.inject(beanInstance, puInstance);
}
}
@@ -289,7 +283,7 @@
}
if (getManager().getServices().contains(JpaServices.class))
{
- initPersistenceUnitInjectionPoints();
+ initJpaInjectionPoints();
}
if (getManager().getServices().contains(ResourceServices.class))
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/persistence/PersistenceApiAbstraction.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -26,6 +26,7 @@
{
public final Class<? extends Annotation> PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
+ public final Class<? extends Annotation> PERSISTENCE_UNIT_ANNOTATION_CLASS;
public final Object EXTENDED_PERSISTENCE_CONTEXT_ENUM_VALUE;
public final Class<?> PERSISTENCE_CONTEXT_TYPE_CLASS;
public final Class<? extends Annotation> ENTITY_CLASS;
@@ -39,6 +40,7 @@
{
super(resourceLoader);
PERSISTENCE_CONTEXT_ANNOTATION_CLASS = annotationTypeForName("javax.persistence.PersistenceContext");
+ PERSISTENCE_UNIT_ANNOTATION_CLASS = annotationTypeForName("javax.persistence.PersistenceUnit");
PERSISTENCE_CONTEXT_TYPE_CLASS = classForName("javax.persistence.PersistenceContextType");
if (PERSISTENCE_CONTEXT_TYPE_CLASS.getClass().equals( Dummy.class))
{
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/JpaServices.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -48,25 +48,18 @@
public EntityManager resolvePersistenceContext(InjectionPoint injectionPoint);
/**
- * Resolve a persistence context for a given persistence unit name
+ * Resolve the value for the given @PersistenceUnit injection point
*
- * @param unitName the unit name
+ * @param injectionPoint
+ * the injection point metadata
* @return an instance of the entity manager
+ * @throws IllegalArgumentException
+ * if the injection point is not annotated with
+ * @PersistenceUnit, or, if the injection point is a method
+ * that doesn't follow JavaBean conventions
* @throws IllegalStateException
* if no suitable persistence units can be resolved for injection
*/
- public EntityManager resolvePersistenceContext(String unitName);
-
- /**
- * Resolve a persistence unit for a given persistence unit name
- *
- * @param unitName the unit name
- * @return an instance of the entity manager factory
- * @throws IllegalStateException
- * if no suitable persistence units can be resolved for injection
- * @throws IllegalArgumentException
- * if unitName is null
- */
- public EntityManagerFactory resolvePersistenceUnit(String unitName);
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint);
}
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/ForwardingJpaServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/ForwardingJpaServices.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/persistence/spi/helpers/ForwardingJpaServices.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -42,16 +42,11 @@
return delegate().resolvePersistenceContext(injectionPoint);
}
- public EntityManager resolvePersistenceContext(String unitName)
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint)
{
- return delegate().resolvePersistenceContext(unitName);
+ return delegate().resolvePersistenceUnit(injectionPoint);
}
- public EntityManagerFactory resolvePersistenceUnit(String unitName)
- {
- return delegate().resolvePersistenceUnit(unitName);
- }
-
@Override
public String toString()
{
Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJpaServices.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -21,14 +21,9 @@
return null;
}
- public EntityManager resolvePersistenceContext(String unitName)
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint)
{
return null;
}
- public EntityManagerFactory resolvePersistenceUnit(String unitName)
- {
- return null;
- }
-
}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJpaServices.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -31,16 +31,11 @@
return null;
}
- public EntityManager resolvePersistenceContext(String unitName)
+ public EntityManagerFactory resolvePersistenceUnit(InjectionPoint injectionPoint)
{
return null;
}
- public EntityManagerFactory resolvePersistenceUnit(String unitName)
- {
- return null;
- }
-
public Collection<Class<?>> discoverEntities()
{
Set<Class<?>> classes = new HashSet<Class<?>>();
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/PersistenceContextInjectionTest.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -42,7 +42,7 @@
assert managedBean.getPersistenceContext().isOpen() : "Persistence context not open injected into bean";
}
- @Test(groups = { "ri-broken", "beanLifecycle", "commonAnnotations", "integration" })
+ @Test(groups = { "beanLifecycle", "commonAnnotations", "integration" })
@SpecAssertions( {
@SpecAssertion(section = "3.5.1", id = "dd")
})
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java 2009-07-25 21:59:42 UTC (rev 3235)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/resource/persistenceContext/ResourceProducer.java 2009-07-25 22:28:54 UTC (rev 3236)
@@ -11,4 +11,20 @@
private @Produces @Default @PersistenceUnit EntityManagerFactory persistenceUnit;
private @Produces @Default @PersistenceContext EntityManager persistenceContext;
+
+ /**
+ * @return the persistenceContext
+ */
+ public EntityManager getPersistenceContext()
+ {
+ return persistenceContext;
+ }
+
+ /**
+ * @return the persistenceUnit
+ */
+ public EntityManagerFactory getPersistenceUnit()
+ {
+ return persistenceUnit;
+ }
}
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3235 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 17:59:42 -0400 (Sat, 25 Jul 2009)
New Revision: 3235
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/Duck.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor_Broken.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java
Log:
Fix ri
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-07-25 21:49:35 UTC (rev 3234)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -23,6 +23,8 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.spi.Decorator;
@@ -277,6 +279,7 @@
if (!isInitialized())
{
initConstructor();
+ checkConstructor();
super.initialize(environment);
initPostConstruct();
initPreDestroy();
@@ -369,6 +372,18 @@
}
}
}
+
+ protected void checkConstructor()
+ {
+ if (!constructor.getAnnotatedParameters(Disposes.class).isEmpty())
+ {
+ throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
+ }
+ if (!constructor.getAnnotatedParameters(Observes.class).isEmpty())
+ {
+ throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
+ }
+ }
@Override
protected void preSpecialize(BeanDeployerEnvironment environment)
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java 2009-07-25 21:49:35 UTC (rev 3234)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/ConstructorHasDisposesParameterTest.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -17,7 +17,7 @@
@ExpectedDeploymentException(DefinitionError.class)
public class ConstructorHasDisposesParameterTest extends AbstractJSR299Test
{
- @Test(groups = { "disposalMethod", "ri-broken" })
+ @Test(groups = { "disposalMethod" })
@SpecAssertion(section = "3.1.4.1", id = "da")
public void testConstructorHasDisposesParameter() throws Exception
{
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor.java (from rev 3215, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor_Broken.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.definition.constructorHasDisposesParameter;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Initializer;
+
+class DisposingConstructor
+{
+ @Initializer
+ public DisposingConstructor(@Disposes Duck duck)
+ {
+
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor_Broken.java 2009-07-25 21:49:35 UTC (rev 3234)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasDisposesParameter/DisposingConstructor_Broken.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -1,11 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.definition.constructorHasDisposesParameter;
-
-import javax.enterprise.inject.Disposes;
-
-class DisposingConstructor_Broken
-{
- public DisposingConstructor_Broken(@Disposes Duck duck)
- {
-
- }
-}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java 2009-07-25 21:49:35 UTC (rev 3234)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ConstructorHasObservesParameterTest.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -17,7 +17,7 @@
@ExpectedDeploymentException(DefinitionError.class)
public class ConstructorHasObservesParameterTest extends AbstractJSR299Test
{
- @Test(groups = { "ri-broken", "observerMethod" })
+ @Test(groups = { "observerMethod" })
@SpecAssertion(section = "3.1.4.1", id = "ea")
public void testConstructorHasObservesParameter()
{
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/Duck.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/Duck.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/Duck.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.definition.constructorHasObservesParameter;
+
+
+class Duck
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/Duck.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor.java (from rev 3215, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor_Broken.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.implementation.simple.definition.constructorHasObservesParameter;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Initializer;
+
+class ObservingConstructor
+{
+
+ @Initializer
+ public ObservingConstructor(@Observes Duck duck)
+ {
+
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor_Broken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor_Broken.java 2009-07-25 21:49:35 UTC (rev 3234)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/definition/constructorHasObservesParameter/ObservingConstructor_Broken.java 2009-07-25 21:59:42 UTC (rev 3235)
@@ -1,12 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.simple.definition.constructorHasObservesParameter;
-
-import javax.enterprise.event.Observes;
-
-class ObservingConstructor_Broken
-{
-
- public ObservingConstructor_Broken(@Observes String stringEvent)
- {
-
- }
-}
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3234 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: bean/proxy and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 17:49:35 -0400 (Sat, 25 Jul 2009)
New Revision: 3234
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/Marker.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
Log:
Introduce marker interface to make signature conflicts very unlikely
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-07-25 21:48:51 UTC (rev 3233)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -38,6 +38,7 @@
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
+import org.jboss.webbeans.bean.proxy.Marker;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
@@ -256,13 +257,13 @@
}
EnterpriseBeanInstance enterpiseBeanInstance = (EnterpriseBeanInstance) instance;
- if (enterpiseBeanInstance.isDestroyed())
+ if (enterpiseBeanInstance.isDestroyed(Marker.INSTANCE))
{
return;
}
else
{
- enterpiseBeanInstance.destroy(this, creationalContext);
+ enterpiseBeanInstance.destroy(Marker.INSTANCE, this, creationalContext);
}
creationalContext.release();
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyInstance.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyInstance.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyInstance.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.bean.proxy;
+
+/**
+ * @author pmuir
+ *
+ */
+public interface ClientProxyInstance
+{
+
+ public void touch(Marker marker);
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyInstance.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-07-25 21:48:51 UTC (rev 3233)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -42,6 +42,7 @@
*/
public class ClientProxyMethodHandler implements MethodHandler, Serializable
{
+
private static final long serialVersionUID = -5391564935097267888L;
// The log provider
private static transient LogProvider log = Logging.getLogProvider(ClientProxyMethodHandler.class);
@@ -49,11 +50,11 @@
private transient Bean<?> bean;
// The bean index in the manager
private final int beanIndex;
-
- private final BeanManagerImpl manager;
-
- private static final ThreadLocal<CreationalContextImpl<?>> currentCreationalContext = new ThreadLocal<CreationalContextImpl<?>>();
+ private final BeanManagerImpl manager;
+
+ private static final ThreadLocal<CreationalContextImpl<?>> currentCreationalContext = new ThreadLocal<CreationalContextImpl<?>>();
+
/**
* Constructor
*
@@ -69,23 +70,22 @@
}
/**
- * Invokes the method on the correct version of the instance as obtained by
- * a context lookup
+ * Invokes the method on the correct version of the instance as obtained by a
+ * context lookup
*
- * @param self the proxy instance.
- * @param thisMethod the overridden method declared in the super
- * class or interface.
- * @param proceed the forwarder method for invoking the overridden
- * method. It is null if the overridden mehtod is
- * abstract or declared in the interface.
- * @param args an array of objects containing the values of
- * the arguments passed in the method invocation
- * on the proxy instance. If a parameter type is
- * a primitive type, the type of the array element
- * is a wrapper class.
- * @return the resulting value of the method invocation.
- *
- * @throws Throwable if the method invocation fails.
+ * @param self the proxy instance.
+ * @param thisMethod the overridden method declared in the super class or
+ * interface.
+ * @param proceed the forwarder method for invoking the overridden method. It
+ * is null if the overridden mehtod is abstract or declared in the
+ * interface.
+ * @param args an array of objects containing the values of the arguments
+ * passed in the method invocation on the proxy instance. If a
+ * parameter type is a primitive type, the type of the array
+ * element is a wrapper class.
+ * @return the resulting value of the method invocation.
+ *
+ * @throws Throwable if the method invocation fails.
*/
public Object invoke(Object self, Method proxiedMethod, Method proceed, Object[] args) throws Throwable
{
@@ -93,7 +93,14 @@
{
bean = manager.getBeans().get(beanIndex);
}
- Object proxiedInstance = getProxiedInstance(bean);
+ Object proxiedInstance = getProxiedInstance(bean);
+ if ("touch".equals(proxiedMethod.getName()) && Marker.isMarker(0, proxiedMethod, args))
+ {
+ // Our "touch" method, which simply ensures the proxy does any object
+ // instantiation needed, to avoid the annoying side effect of an object
+ // getting lazy created
+ return null;
+ }
try
{
Object returnValue = Reflections.lookupMethod(proxiedMethod, proxiedInstance).invoke(proxiedInstance, args);
@@ -105,7 +112,7 @@
throw e.getCause();
}
}
-
+
private <T> T getProxiedInstance(Bean<T> bean)
{
CreationalContextImpl<T> creationalContext;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-07-25 21:48:51 UTC (rev 3233)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -78,6 +78,7 @@
ClientProxyMethodHandler proxyMethodHandler = new ClientProxyMethodHandler(bean, manager, beanIndex);
Set<Type> classes = new LinkedHashSet<Type>(bean.getTypes());
classes.add(Serializable.class);
+ classes.add(ClientProxyInstance.class);
ProxyFactory proxyFactory = Proxies.getProxyFactory(classes);
proxyFactory.setHandler(proxyMethodHandler);
Class<?> clazz = proxyFactory.createClass();
@@ -108,7 +109,7 @@
*/
public <T> T getClientProxy(final BeanManagerImpl manager, final Bean<T> bean)
{
- return pool.putIfAbsent(bean, new Callable<T>()
+ T instance = pool.putIfAbsent(bean, new Callable<T>()
{
public T call() throws Exception
@@ -122,6 +123,9 @@
}
});
+ // TODO Break circular injection. Can we somehow support both?
+ //((ClientProxyInstance) instance).touch(Marker.INSTANCE);
+ return instance;
}
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-07-25 21:48:51 UTC (rev 3233)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -29,16 +29,15 @@
public interface EnterpriseBeanInstance
{
- // TODO These methods may conflict :-(
/**
* Indicated if a remove method has been invoked by the application
*
* @return True if invoked, false otherwise
*/
- public boolean isDestroyed();
+ public boolean isDestroyed(Marker marker);
- public void setDestroyed(boolean destroyed);
+ public void setDestroyed(Marker marker, boolean destroyed);
- public void destroy(EnterpriseBean<?> enterpriseBean, CreationalContext<?> creationalContext);
+ public void destroy(Marker marker, EnterpriseBean<?> enterpriseBean, CreationalContext<?> creationalContext);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-07-25 21:48:51 UTC (rev 3233)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -128,21 +128,21 @@
public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
{
// EnterpriseBeanInstance methods
- if ("isDestroyed".equals(method.getName()))
+ if ("isDestroyed".equals(method.getName()) && Marker.isMarker(0, method, args))
{
return destroyed;
}
- else if ("setDestroyed".equals(method.getName()))
+ else if ("setDestroyed".equals(method.getName()) && Marker.isMarker(0, method, args))
{
- if (args.length != 1)
+ if (args.length != 2)
{
- throw new IllegalArgumentException("enterpriseBeanInstance.setDestroyed() called with >1 argument");
+ throw new IllegalArgumentException("enterpriseBeanInstance.setDestroyed() called with >2 argument");
}
- if (!(args[0].getClass().equals(boolean.class) || args[0].getClass().equals(Boolean.class)))
+ if (!(args[1].getClass().equals(boolean.class) || args[1].getClass().equals(Boolean.class)))
{
throw new IllegalArgumentException("enterpriseBeanInstance.setDestroyed() called with non-boolean argument");
}
- destroyed = ((Boolean) args[0]).booleanValue();
+ destroyed = ((Boolean) args[1]).booleanValue();
}
if (destroyed)
@@ -150,7 +150,7 @@
return null;
}
- if ("destroy".equals(method.getName()))
+ if ("destroy".equals(method.getName()) && Marker.isMarker(0, method, args))
{
reference.remove();
return null;
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/Marker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/Marker.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/Marker.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.bean.proxy;
+
+import java.lang.reflect.Method;
+
+/**
+ * A marker class we can use to ensure that our method will not collide with a
+ * user provided method
+ *
+ * @author pmuir
+ *
+ */
+public class Marker
+{
+
+ public static final Marker INSTANCE = new Marker();
+
+ private Marker () {}
+
+ public static boolean isMarker(int position, Method method, Object[] args)
+ {
+ return method.getParameterTypes().length >= position && method.getParameterTypes()[position].equals(Marker.class) && INSTANCE.equals(args[position]);
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/Marker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-07-25 21:48:51 UTC (rev 3233)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2009-07-25 21:49:35 UTC (rev 3234)
@@ -30,6 +30,7 @@
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
+import org.jboss.webbeans.bean.proxy.Marker;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
@@ -82,7 +83,7 @@
EnterpriseBeanInstance instance = getEnterpriseBeanInstance(bean);
if (instance != null)
{
- instance.setDestroyed(true);
+ instance.setDestroyed(Marker.INSTANCE, true);
}
}
invocationContext.proceed();
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3233 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 17:48:51 -0400 (Sat, 25 Jul 2009)
New Revision: 3233
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/OakTree.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Pollen.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
Log:
Fix test
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/OakTree.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/OakTree.java 2009-07-25 21:34:10 UTC (rev 3232)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/OakTree.java 2009-07-25 21:48:51 UTC (rev 3233)
@@ -11,7 +11,7 @@
return null;
}
- @Produces @RequestScoped public Pollen pollinate()
+ @Produces @RequestScoped @Yummy public Pollen pollinate()
{
return null;
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Pollen.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Pollen.java 2009-07-25 21:34:10 UTC (rev 3232)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/Pollen.java 2009-07-25 21:48:51 UTC (rev 3233)
@@ -2,5 +2,10 @@
class Pollen
{
+
+ public void ping()
+ {
+
+ }
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-07-25 21:34:10 UTC (rev 3232)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/definition/ProducerMethodDefinitionTest.java 2009-07-25 21:48:51 UTC (rev 3233)
@@ -247,11 +247,11 @@
assert getInstanceByType(Acorn.class) == null;
}
- @Test(groups = { "ri-broken" }, expectedExceptions = { IllegalProductException.class })
+ @Test(expectedExceptions = { IllegalProductException.class })
@SpecAssertion(section = "3.3", id = "f")
public void testNonDependentProducerReturnsNullValue()
{
- getInstanceByType(Pollen.class);
+ getInstanceByType(Pollen.class, new AnnotationLiteral<Yummy>() {}).ping();
assert false;
}
}
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3232 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 17:34:10 -0400 (Sat, 25 Jul 2009)
New Revision: 3232
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java
Log:
fix import
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java 2009-07-25 21:19:28 UTC (rev 3231)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/definition/Retriever.java 2009-07-25 21:34:10 UTC (rev 3232)
@@ -17,8 +17,8 @@
package org.jboss.jsr299.tck.tests.implementation.enterprise.definition;
import javax.ejb.LocalBean;
+import javax.ejb.Stateful;
-import com.sun.xml.internal.ws.developer.Stateful;
/**
* @author pmuir
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3231 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 17:19:28 -0400 (Sat, 25 Jul 2009)
New Revision: 3231
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java
Log:
Fix disposal methods for enterprise beans, use OO for DisposalMethodBean
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -234,13 +234,6 @@
}
/**
- * Gets the default deployment type
- *
- * @return The default deployment type
- */
- protected abstract Class<? extends Annotation> getDefaultDeploymentType();
-
- /**
* Initializes the name
*/
protected void initName()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -426,12 +426,6 @@
return "AbstractClassBean " + getName();
}
- @Override
- /*
- * Gets the default deployment type
- *
- * @return The default deployment type
- */
protected Class<? extends Annotation> getDefaultDeploymentType()
{
return Production.class;
@@ -442,5 +436,6 @@
{
return id;
}
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -40,7 +40,6 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.introspector.WBMember;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -57,11 +56,8 @@
* @param <T>
* @param <S>
*/
-public abstract class AbstractProducerBean<T, S extends Member> extends AbstractBean<T, S>
+public abstract class AbstractProducerBean<T, S extends Member> extends AbstractReceiverBean<T, S>
{
- // The declaring bean
- protected AbstractClassBean<?> declaringBean;
-
private static final LogProvider log = Logging.getLogProvider(AbstractProducerBean.class);
/**
@@ -72,8 +68,7 @@
*/
public AbstractProducerBean(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
{
- super(manager);
- this.declaringBean = declaringBean;
+ super(declaringBean, manager);
}
@Override
@@ -86,28 +81,9 @@
return getDeclaringBean().getBeanClass();
}
- @Override
- public String getId()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * Gets the deployment types
- *
- * @return The deployment types of the declaring bean
- */
- @Override
protected Class<? extends Annotation> getDefaultDeploymentType()
{
- return deploymentType = declaringBean.getDeploymentType();
+ return getDeclaringBean().getDeploymentType();
}
/**
@@ -172,16 +148,6 @@
}
/**
- * Returns the declaring bean
- *
- * @return The bean representation
- */
- public AbstractClassBean<?> getDeclaringBean()
- {
- return declaringBean;
- }
-
- /**
* Validates the producer method
*/
protected void checkProducerReturnType()
@@ -209,7 +175,7 @@
@Override
public void initialize(BeanDeployerEnvironment environment)
{
- declaringBean.initialize(environment);
+ getDeclaringBean().initialize(environment);
super.initialize(environment);
checkProducerReturnType();
}
@@ -322,35 +288,6 @@
}
/**
- * Gets the receiver of the product
- *
- * @return The receiver
- */
- protected Object getReceiver(CreationalContext<?> creationalContext)
- {
- // This is a bit dangerous, as it means that producer methods can end of
- // executing on partially constructed instances. Also, it's not required
- // by the spec...
- if (getAnnotatedItem().isStatic())
- {
- return null;
- }
- else
- {
- if (creationalContext instanceof CreationalContextImpl)
- {
- CreationalContextImpl<?> creationalContextImpl = (CreationalContextImpl<?>) creationalContext;
- if (creationalContextImpl.containsIncompleteInstance(getDeclaringBean()))
- {
- log.warn("Executing producer field or method " + getAnnotatedItem() + " on incomplete declaring bean " + getDeclaringBean() + " due to circular injection");
- return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
- }
- }
- return manager.getReference(getDeclaringBean(), Object.class, creationalContext);
- }
- }
-
- /**
* Creates an instance of the bean
*
* @returns The instance
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.bean;
+
+import java.lang.reflect.Member;
+
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.context.CreationalContextImpl;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * @author pmuir
+ *
+ */
+public abstract class AbstractReceiverBean<T, S extends Member> extends AbstractBean<T, S>
+{
+
+ private static final LogProvider log = Logging.getLogProvider(AbstractReceiverBean.class);
+
+ private AbstractClassBean<?> declaringBean;
+
+ public AbstractReceiverBean(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(manager);
+ this.declaringBean = declaringBean;
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ super.initialize(environment);
+ }
+
+ /**
+ * Gets the receiver of the product
+ *
+ * @return The receiver
+ */
+ protected Object getReceiver(CreationalContext<?> creationalContext)
+ {
+ // This is a bit dangerous, as it means that producer methods can end of
+ // executing on partially constructed instances. Also, it's not required
+ // by the spec...
+ if (getAnnotatedItem().isStatic())
+ {
+ return null;
+ }
+ else
+ {
+ if (creationalContext instanceof CreationalContextImpl<?>)
+ {
+ CreationalContextImpl<?> creationalContextImpl = (CreationalContextImpl<?>) creationalContext;
+ if (creationalContextImpl.containsIncompleteInstance(getDeclaringBean()))
+ {
+ log.warn("Executing producer field or method " + getAnnotatedItem() + " on incomplete declaring bean " + getDeclaringBean() + " due to circular injection");
+ return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
+ }
+ }
+ return manager.getReference(getDeclaringBean(), Object.class, creationalContext);
+ }
+ }
+
+
+ /**
+ * Returns the declaring bean
+ *
+ * @return The bean representation
+ */
+ public AbstractClassBean<?> getDeclaringBean()
+ {
+ return declaringBean;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -20,51 +20,44 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
-import javax.enterprise.context.Dependent;
-import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.deployment.DeploymentType;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.introspector.WBParameter;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-public class DisposalMethodBean<T> extends AbstractBean<T, Method>
+public class DisposalMethodBean<T> extends AbstractReceiverBean<T, Method>
{
- private static final LogProvider log = Logging.getLogProvider(AbstractProducerBean.class);
- protected AbstractClassBean<?> declaringBean;
- private DisposalMethodBean<?> specializedBean;
protected MethodInjectionPoint<T> disposalMethodInjectionPoint;
- protected Set<WBInjectionPoint<?, ?>> disposalInjectionPoints;
private final String id;
protected DisposalMethodBean(BeanManagerImpl manager, WBMethod<T> disposalMethod, AbstractClassBean<?> declaringBean)
{
- super(manager);
+ super(declaringBean, manager);
this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
- this.declaringBean = declaringBean;
- checkDisposalMethod();
+ this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
initBindings();
initType();
initTypes();
- this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
-
}
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ // TODO Auto-generated method stub
+ super.initialize(environment);
+ checkDisposalMethod();
+ }
@SuppressWarnings("unchecked")
protected void initType()
@@ -85,22 +78,7 @@
protected void initInjectionPoints()
{
- disposalInjectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
-
- List<? extends WBParameter<?>> disposalMethodParameters = disposalMethodInjectionPoint.getParameters();
-
- // First one must be @Disposes, if more, register injectionpoints
- if (disposalMethodParameters.size() > 1)
- {
- for (int i = 1; i < disposalMethodParameters.size(); i++)
- {
- WBParameter<?> parameter = disposalMethodParameters.get(i);
- disposalInjectionPoints.add(ParameterInjectionPoint.of(declaringBean, parameter));
- }
- }
-
- injectionPoints.add(MethodInjectionPoint.of(declaringBean, disposalMethodInjectionPoint));
-
+ injectionPoints.add(disposalMethodInjectionPoint);
}
@Override
@@ -112,12 +90,6 @@
initDefaultBindings();
}
- @Override
- public Class<? extends Annotation> getDeploymentType()
- {
- return declaringBean.getDeploymentType();
- }
-
/**
* Initializes the API types
*/
@@ -127,7 +99,6 @@
Set<Type> types = new HashSet<Type>();
types = new HashSet<Type>();
types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
- types.add(getType());
types.add(Object.class);
super.types = types;
}
@@ -141,13 +112,13 @@
@Override
public String getName()
{
- return disposalMethodInjectionPoint.getPropertyName();
+ return null;
}
@Override
public Class<? extends Annotation> getScopeType()
{
- return declaringBean.getScopeType();
+ return null;
}
@Override
@@ -165,13 +136,15 @@
@Override
public boolean isNullable()
{
+ // Not relevant
return false;
}
@Override
public boolean isSerializable()
{
- return declaringBean.isSerializable();
+ // Not relevant
+ return false;
}
@Override
@@ -182,14 +155,21 @@
public T create(CreationalContext<T> creationalContext)
{
+ // Not Relevant
return null;
}
public void invokeDisposeMethod(Object instance, CreationalContext<?> creationalContext)
{
- // TODO WTF - why isn't this using getReceiver!? Why is it assigning the beanInstance as the beanObject!?!
- Object beanInstance = disposalMethodInjectionPoint.isStatic() ? declaringBean : getManager().getReference(declaringBean, declaringBean.getType(), creationalContext);
- disposalMethodInjectionPoint.invokeWithSpecialValue(beanInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+ Object receiverInstance = getReceiver(creationalContext);
+ if (receiverInstance == null)
+ {
+ disposalMethodInjectionPoint.invokeWithSpecialValue(null, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+ }
+ else
+ {
+ disposalMethodInjectionPoint.invokeOnInstanceWithSpecialValue(receiverInstance, Disposes.class, instance, manager, creationalContext, IllegalArgumentException.class);
+ }
}
private void checkDisposalMethod()
@@ -214,13 +194,13 @@
{
throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
}
- if (declaringBean instanceof EnterpriseBean)
+ if (getDeclaringBean() instanceof EnterpriseBean<?>)
{
boolean methodDeclaredOnTypes = false;
// TODO use annotated item?
- for (Type type : declaringBean.getTypes())
+ for (Type type : getDeclaringBean().getTypes())
{
- if (type instanceof Class)
+ if (type instanceof Class<?>)
{
Class<?> clazz = (Class<?>) type;
try
@@ -236,118 +216,68 @@
}
if (!methodDeclaredOnTypes)
{
- throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + declaringBean);
+ throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
}
}
}
@Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
+ public Class<T> getType()
{
- if (declaringBean.getAnnotatedItem().getSuperclass().getDeclaredMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
- {
- throw new DefinitionException("Specialized disposal method does not override a method on the direct superclass");
- }
+ return type;
}
@Override
- protected void specialize(BeanDeployerEnvironment environment)
+ protected String getDefaultName()
{
- WBMethod<?> superClassMethod = declaringBean.getAnnotatedItem().getSuperclass().getMethod(getAnnotatedItem().getAnnotatedMethod());
- if (environment.getProducerMethod(superClassMethod) == null)
- {
- throw new IllegalStateException(toString() + " does not specialize a bean");
- }
- this.specializedBean = environment.getDisposalMethod(superClassMethod);
+ return disposalMethodInjectionPoint.getPropertyName();
}
- @Override
- public Class<T> getType()
+ public void destroy(T instance, CreationalContext<T> creationalContext)
{
- return type;
+ // No-op. Producer method dependent objects are destroyed in producer method bean
}
@Override
- protected Class<? extends Annotation> getDefaultDeploymentType()
+ public String getId()
{
- return declaringBean.getDeploymentType();
+ return id;
}
- @Override
- protected String getDefaultName()
+ public boolean isPolicy()
{
- return disposalMethodInjectionPoint.getPropertyName();
+ return false;
}
@Override
- protected void initDeploymentType()
+ public AbstractBean<?, ?> getSpecializedBean()
{
- Set<Annotation> deploymentTypes = getAnnotatedItem().getMetaAnnotations(DeploymentType.class);
- if (deploymentTypes.size() > 1)
- {
- throw new DefinitionException("At most one deployment type may be specified (" + deploymentTypes + " are specified) on " + getAnnotatedItem().toString());
- }
- else if (deploymentTypes.size() == 1)
- {
- this.deploymentType = deploymentTypes.iterator().next().annotationType();
- log.trace("Deployment type " + deploymentType + " specified by annotation");
- return;
- }
-
- initDeploymentTypeFromStereotype();
-
- if (this.deploymentType == null)
- {
- this.deploymentType = getDefaultDeploymentType();
- log.trace("Using default " + this.deploymentType + " deployment type");
- return;
- }
+ // Doesn't support specialization
+ return null;
}
-
+
@Override
protected void initScopeType()
{
- Set<Annotation> scopeAnnotations = getAnnotatedItem().getMetaAnnotations(ScopeType.class);
- if (scopeAnnotations.size() > 1)
- {
- throw new DefinitionException("At most one scope may be specified");
- }
- if (scopeAnnotations.size() == 1)
- {
- this.scopeType = scopeAnnotations.iterator().next().annotationType();
- log.trace("Scope " + scopeType + " specified by annotation");
- return;
- }
-
- initScopeTypeFromStereotype();
-
- if (this.scopeType == null)
- {
- this.scopeType = Dependent.class;
- log.trace("Using default @Dependent scope");
- }
+ // Disposal methods aren't scoped
}
@Override
- public AbstractBean<?, ?> getSpecializedBean()
+ public Class<? extends Annotation> getDeploymentType()
{
- return specializedBean;
+ return getDeclaringBean().getDeploymentType();
}
- public void destroy(T instance, CreationalContext<T> creationalContext)
+ @Override
+ protected void initDeploymentType()
{
- // No-op. Producer method dependent objects are destroyed in producer method bean
+ // Not used
}
-
+
@Override
- public String getId()
+ protected void checkDeploymentType()
{
- return id;
+ // TODO sort out ordering of init, then we can use initDeploymentType and hence checkDeploymentType
}
- public boolean isPolicy()
- {
- return false;
- }
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -126,11 +126,11 @@
{
throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
}
- else if (declaringBean instanceof EnterpriseBean)
+ else if (getDeclaringBean() instanceof EnterpriseBean<?>)
{
boolean methodDeclaredOnTypes = false;
// TODO use annotated item?
- for (Type type : declaringBean.getTypes())
+ for (Type type : getDeclaringBean().getTypes())
{
if (type instanceof Class)
{
@@ -148,7 +148,7 @@
}
if (!methodDeclaredOnTypes)
{
- throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + declaringBean);
+ throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
}
}
}
@@ -253,7 +253,7 @@
@Override
protected void preSpecialize(BeanDeployerEnvironment environment)
{
- if (declaringBean.getAnnotatedItem().getSuperclass().getDeclaredMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
+ if (getDeclaringBean().getAnnotatedItem().getSuperclass().getDeclaredMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
{
throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
}
@@ -262,7 +262,7 @@
@Override
protected void specialize(BeanDeployerEnvironment environment)
{
- WBMethod<?> superClassMethod = declaringBean.getAnnotatedItem().getSuperclass().getMethod(getAnnotatedItem().getAnnotatedMethod());
+ WBMethod<?> superClassMethod = getDeclaringBean().getAnnotatedItem().getSuperclass().getMethod(getAnnotatedItem().getAnnotatedMethod());
if (environment.getProducerMethod(superClassMethod) == null)
{
throw new IllegalStateException(toString() + " does not specialize a bean");
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -24,7 +24,6 @@
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.ObserverMethod;
import org.jboss.webbeans.BeanManagerImpl;
@@ -131,6 +130,7 @@
for (WBMethod<?> method : annotatedClass.getDeclaredMethodsWithAnnotatedParameters(Disposes.class))
{
DisposalMethodBean<?> disposalBean = DisposalMethodBean.of(manager, method, declaringBean);
+ disposalBean.initialize(environment);
environment.addDisposalBean(disposalBean);
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -54,7 +54,7 @@
private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
private final Set<DecoratorBean<?>> decorators;
private final EjbDescriptorCache ejbDescriptors;
- private final TypeSafeResolver disposalMethodResolver;
+ private final TypeSafeResolver<DisposalMethodBean<?>> disposalMethodResolver;
private final BeanManagerImpl manager;
public BeanDeployerEnvironment(EjbDescriptorCache ejbDescriptors, BeanManagerImpl manager)
@@ -68,7 +68,7 @@
this.decorators = new HashSet<DecoratorBean<?>>();
this.observers = new HashSet<ObserverMethod<?, ?>>();
this.ejbDescriptors = ejbDescriptors;
- this.disposalMethodResolver = new TypeSafeBeanResolver(manager, allDisposalBeans);
+ this.disposalMethodResolver = new TypeSafeBeanResolver<DisposalMethodBean<?>>(manager, allDisposalBeans);
this.manager = manager;
}
@@ -190,11 +190,11 @@
public <T> Set<DisposalMethodBean<T>> resolveDisposalBeans(WBAnnotated<T, ?> annotatedItem)
{
// Correct?
- Set<Bean<?>> beans = disposalMethodResolver.resolve(ResolvableFactory.of(annotatedItem));
+ Set<DisposalMethodBean<?>> beans = disposalMethodResolver.resolve(ResolvableFactory.of(annotatedItem));
Set<DisposalMethodBean<T>> disposalBeans = new HashSet<DisposalMethodBean<T>>();
for (Bean<?> bean : beans)
{
- if (bean instanceof DisposalMethodBean)
+ if (bean instanceof DisposalMethodBean<?>)
{
disposalBeans.add((DisposalMethodBean<T>) bean);
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java 2009-07-25 21:18:10 UTC (rev 3230)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/NewEnterpriseBeanICTest.java 2009-07-25 21:19:28 UTC (rev 3231)
@@ -78,7 +78,7 @@
assert theOnlyDen.getName().equals(fox.getDen().getName());
}
- @Test(groups = { "new", "ri-broken", "disposal" })
+ @Test(groups = { "new", "disposal" })
@SpecAssertion(section = "3.10", id = "x")
public void testNewBeanHasNoDisposalMethods() throws Exception
{
15 years, 4 months
[webbeans-commits] Webbeans SVN: r3230 - ri/trunk/jboss-as.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-25 17:18:10 -0400 (Sat, 25 Jul 2009)
New Revision: 3230
Modified:
ri/trunk/jboss-as/build.xml
Log:
english
Modified: ri/trunk/jboss-as/build.xml
===================================================================
--- ri/trunk/jboss-as/build.xml 2009-07-25 21:01:32 UTC (rev 3229)
+++ ri/trunk/jboss-as/build.xml 2009-07-25 21:18:10 UTC (rev 3230)
@@ -61,7 +61,7 @@
</target>
<target name="install-javassist-update">
- <echo message="Upgrading Javassist to ${javassist.version} to ${jboss.home}" />
+ <echo message="Upgrading Javassist to ${javassist.version} for ${jboss.home}" />
<fail unless="jboss.home" message="Please pass in -Djboss.home=..." />
<artifact:dependencies filesetId="javassist.fileset" versionsId="javassist.versions">
15 years, 4 months