Author: nickarls
Date: 2008-11-03 02:57:36 -0500 (Mon, 03 Nov 2008)
New Revision: 220
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ProxyPool.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java
Log:
Minors:
Fix broken tests
Implicit bean adding to manager for proxy client generation + test
Dropped extra parameter from ProxyPool request
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-11-03
07:40:49 UTC (rev 219)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-11-03
07:57:36 UTC (rev 220)
@@ -286,7 +286,7 @@
contextMap.getDependentContext().setActive(true);
if (getModelManager().getScopeModel(bean.getScopeType()).isNormal())
{
- return (T) proxyPool.getClientProxy(bean, beans.indexOf(bean));
+ return (T) proxyPool.getClientProxy(bean);
}
else
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ProxyPool.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ProxyPool.java 2008-11-03
07:40:49 UTC (rev 219)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/ProxyPool.java 2008-11-03
07:57:36 UTC (rev 220)
@@ -70,13 +70,19 @@
return clientProxy;
}
- public Object getClientProxy(Bean<?> bean, int beanIndex)
+ public Object getClientProxy(Bean<?> bean)
{
Object clientProxy = pool.get(bean);
if (clientProxy == null)
{
try
{
+ int beanIndex = manager.getBeans().indexOf(bean);
+ // Implicit add required since it is looked up on activation with then index
+ if (beanIndex < 0) {
+ manager.addBean(bean);
+ beanIndex = manager.getBeans().size() - 1;
+ }
clientProxy = createClientProxy(bean, beanIndex);
}
catch (Exception e)
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java 2008-11-03
07:40:49 UTC (rev 219)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java 2008-11-03
07:57:36 UTC (rev 220)
@@ -105,5 +105,12 @@
assert tuna.getClass().getName().indexOf("$$_javassist_") > 0;
assert tuna.getState().equals("tuned");
}
+
+ @Test(groups = "clientProxy")
+ public void testProxyCreationDoesImplicitAddBean() {
+ Bean<Tuna> tunaBean = Util.createSimpleWebBean(Tuna.class, manager);
+ Tuna tuna = manager.getInstance(tunaBean);
+ assert manager.getBeans().size() == 1;
+ }
}
Modified:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java
===================================================================
---
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java 2008-11-03
07:40:49 UTC (rev 219)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ResolutionByTypeTest.java 2008-11-03
07:57:36 UTC (rev 220)
@@ -2,7 +2,9 @@
import static org.jboss.webbeans.test.util.Util.createSimpleWebBean;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.webbeans.AnnotationLiteral;
@@ -57,7 +59,7 @@
{
InjectableField<Tuna> tunaField = new
InjectableField<Tuna>(FishFarm.class.getDeclaredField("tuna"));
Bean<Tuna> tunaBean = createSimpleWebBean(Tuna.class, manager);
- Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ List<Bean<?>> beans = new ArrayList<Bean<?>>();
beans.add(tunaBean);
Set<Bean<?>> possibleTargets = tunaField.getMatchingBeans(beans,
manager.getModelManager());
assert possibleTargets.size() == 1;
@@ -84,7 +86,7 @@
Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
- Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ List<Bean<?>> beans = new ArrayList<Bean<?>>();
beans.add(codBean);
beans.add(salmonBean);
beans.add(soleBean);
@@ -103,7 +105,7 @@
Bean<Salmon> salmonBean = createSimpleWebBean(Salmon.class, manager);
Bean<Sole> soleBean = createSimpleWebBean(Sole.class, manager);
- Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ List<Bean<?>> beans = new ArrayList<Bean<?>>();
beans.add(codBean);
beans.add(salmonBean);
beans.add(soleBean);
@@ -118,7 +120,7 @@
InjectableField<Animal> animalField = new
InjectableField<Animal>(FishFarm.class.getDeclaredField("animal"));
Bean<SeaBass> seaBassBean = createSimpleWebBean(SeaBass.class, manager);
Bean<Haddock> haddockBean = createSimpleWebBean(Haddock.class, manager);
- Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ List<Bean<?>> beans = new ArrayList<Bean<?>>();
beans.add(seaBassBean);
beans.add(haddockBean);
Set<Bean<?>> possibleTargets = animalField.getMatchingBeans(beans,
manager.getModelManager());
Show replies by date