Author: pete.muir(a)jboss.org
Date: 2009-12-09 12:10:51 -0500 (Wed, 09 Dec 2009)
New Revision: 5254
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/Baz.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/FooDB.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/circular/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/circular/resource/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/circular/resource/persistence.xml
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
core/trunk/impl/src/main/java/org/jboss/weld/context/CreationalContextImpl.java
core/trunk/jboss-as/pom.xml
Log:
WELD-310
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java 2009-12-09
16:07:40 UTC (rev 5253)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractReceiverBean.java 2009-12-09
17:10:51 UTC (rev 5254)
@@ -62,7 +62,7 @@
*/
protected Object getReceiver(CreationalContext<?> creationalContext)
{
- // This is a bit dangerous, as it means that producer methods can end of
+ // This is a bit dangerous, as it means that producer methods can end up
// executing on partially constructed instances. Also, it's not required
// by the spec...
if (getAnnotatedItem().isStatic())
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java 2009-12-09
16:07:40 UTC (rev 5253)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java 2009-12-09
17:10:51 UTC (rev 5254)
@@ -36,7 +36,6 @@
import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
import org.jboss.weld.ejb.EJBApiAbstraction;
import org.jboss.weld.introspector.WeldField;
-import org.jboss.weld.logging.messages.BeanMessage;
import org.jboss.weld.persistence.PersistenceApiAbstraction;
import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.util.Proxies;
@@ -59,11 +58,13 @@
private final String beanId;
private transient T instance;
+ private final CreationalContext<T> creationalContext;
- public EEResourceCallable(BeanManagerImpl beanManager, ProducerField<?, T>
producerField/*, CreationalContext<T> creationalContext*/)
+ public EEResourceCallable(BeanManagerImpl beanManager, ProducerField<?, T>
producerField, CreationalContext<T> creationalContext)
{
super(beanManager);
this.beanId = producerField.getId();
+ this.creationalContext = creationalContext;
}
public T call() throws Exception
@@ -76,7 +77,7 @@
@SuppressWarnings("unchecked")
EEResourceProducerField<?, T> bean = (EEResourceProducerField<?,
T>) contextual;
- this.instance =
bean.createUnderlying(getBeanManager().createCreationalContext(bean));
+ this.instance = bean.createUnderlying(creationalContext);
}
else
{
@@ -106,31 +107,10 @@
{
return new EEResourceProducerField<X, T>(field, declaringBean, manager);
}
-
- private final T proxy;
protected EEResourceProducerField(WeldField<T, X> field,
AbstractClassBean<X> declaringBean, BeanManagerImpl manager)
{
super(field, declaringBean, manager);
- try
- {
- if (Reflections.isFinal(field.getJavaClass()) ||
Serializable.class.isAssignableFrom(field.getJavaClass()))
- {
- this.proxy = null;
- }
- else
- {
- this.proxy = Proxies.<T>createProxy(new CallableMethodHandler(new
EEResourceCallable<T>(getManager(), this)),
TypeInfo.of(getTypes()).add(Serializable.class));
- }
- }
- catch (InstantiationException e)
- {
- throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
- }
- catch (IllegalAccessException e)
- {
- throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
- }
}
@Override
@@ -157,14 +137,25 @@
@Override
public T create(CreationalContext<T> creationalContext)
{
- if (proxy == null)
+ try
{
- return createUnderlying(creationalContext);
+ if (Reflections.isFinal(getAnnotatedItem().getJavaClass()) ||
Serializable.class.isAssignableFrom(getAnnotatedItem().getJavaClass()))
+ {
+ return createUnderlying(creationalContext);
+ }
+ else
+ {
+ return Proxies.<T>createProxy(new CallableMethodHandler(new
EEResourceCallable<T>(getManager(), this, creationalContext)),
TypeInfo.of(getTypes()).add(Serializable.class));
+ }
}
- else
+ catch (InstantiationException e)
{
- return proxy;
+ throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
}
+ catch (IllegalAccessException e)
+ {
+ throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
+ }
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/CreationalContextImpl.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/context/CreationalContextImpl.java 2009-12-09
16:07:40 UTC (rev 5253)
+++
core/trunk/impl/src/main/java/org/jboss/weld/context/CreationalContextImpl.java 2009-12-09
17:10:51 UTC (rev 5254)
@@ -54,19 +54,19 @@
incompleteInstances.put(contextual, incompleteInstance);
}
- public <S> WeldCreationalContext<S>
getCreationalContext(Contextual<S> Contextual)
+ public <S> WeldCreationalContext<S>
getCreationalContext(Contextual<S> contextual)
{
- return new CreationalContextImpl<S>(Contextual, new
HashMap<Contextual<?>, Object>(incompleteInstances),
dependentInstancesStore);
+ return new CreationalContextImpl<S>(contextual, incompleteInstances == null ?
new HashMap<Contextual<?>, Object>() : new HashMap<Contextual<?>,
Object>(incompleteInstances), dependentInstancesStore);
}
public <S> S getIncompleteInstance(Contextual<S> bean)
{
- return (S) incompleteInstances.get(bean);
+ return incompleteInstances == null ? null : (S) incompleteInstances.get(bean);
}
public boolean containsIncompleteInstance(Contextual<?> bean)
{
- return incompleteInstances.containsKey(bean);
+ return incompleteInstances == null ? false :
incompleteInstances.containsKey(bean);
}
public DependentInstancesStore getParentDependentInstancesStore()
@@ -77,7 +77,10 @@
public void release()
{
dependentInstancesStore.destroyDependentInstances();
- incompleteInstances.clear();
+ if (incompleteInstances != null)
+ {
+ incompleteInstances.clear();
+ }
}
}
Modified: core/trunk/jboss-as/pom.xml
===================================================================
--- core/trunk/jboss-as/pom.xml 2009-12-09 16:07:40 UTC (rev 5253)
+++ core/trunk/jboss-as/pom.xml 2009-12-09 17:10:51 UTC (rev 5254)
@@ -13,7 +13,7 @@
<relativePath>../parent/pom.xml</relativePath>
</parent>
- <name>Weld JBoss AS Updater</name>
+ <name>JBoss AS Updater</name>
<!-- Minimal metadata -->
<description>A script to update Weld in JBoss AS</description>
@@ -57,7 +57,7 @@
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
- <overwriteSnapshots>true</overwriteSnapshots>
+ <overWriteSnapshots>true</overWriteSnapshots>
<stripVersion>true</stripVersion>
<includeArtifactIds>cdi-api,weld-api,weld-core,weld-jboss-int-deployer-assembly</includeArtifactIds>
</configuration>
@@ -78,7 +78,7 @@
<tasks>
<property
file="${project.directory}/local.build.properties" />
<property
file="${project.directory}/build.properties" />
- <property name="jboss.home"
value="${env.JBOSS_HOME}" />
+ <property name="jboss.home"
value="${env.JBOSS_HOME}" />s
<delete
dir="${jboss.home}/server/default/deployers/weld.deployer"
failonerror="false" />
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/Baz.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/Baz.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/Baz.java 2009-12-09
17:10:51 UTC (rev 5254)
@@ -0,0 +1,19 @@
+package org.jboss.weld.tests.resolution.circular.resource;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class Baz
+{
+
+ @Produces @FooDB @PersistenceContext private EntityManager db;
+ @Inject @FooDB EntityManager fooDb;
+
+ public EntityManager getFooDb()
+ {
+ return fooDb;
+ }
+
+}
Property changes on:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/Baz.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/FooDB.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/FooDB.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/FooDB.java 2009-12-09
17:10:51 UTC (rev 5254)
@@ -0,0 +1,20 @@
+package org.jboss.weld.tests.resolution.circular.resource;
+
+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 java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+@Target({FIELD, METHOD, TYPE, PARAMETER})
+public @interface FooDB
+{
+
+}
Property changes on:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/FooDB.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java
===================================================================
---
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java
(rev 0)
+++
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java 2009-12-09
17:10:51 UTC (rev 5254)
@@ -0,0 +1,25 @@
+package org.jboss.weld.tests.resolution.circular.resource;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+@Artifact
+@IntegrationTest
+@Resources({
+ @Resource(source="persistence.xml",
destination="WEB-INF/classes/META-INF/persistence.xml")
+})
+public class ResourceCircularDependencyTest extends AbstractWeldTest
+{
+
+ @Test
+ public void testResourceProducerField() throws Exception
+ {
+ assert getCurrentManager().getInstanceByType(Baz.class).getFooDb().isOpen();
+ assert true;
+ }
+
+}
Property changes on:
core/trunk/tests/src/test/java/org/jboss/weld/tests/resolution/circular/resource/ResourceCircularDependencyTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added:
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/circular/resource/persistence.xml
===================================================================
---
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/circular/resource/persistence.xml
(rev 0)
+++
core/trunk/tests/src/test/resources/org/jboss/weld/tests/resolution/circular/resource/persistence.xml 2009-12-09
17:10:51 UTC (rev 5254)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="test">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ </persistence-unit>
+</persistence>