Author: nickarls
Date: 2008-12-03 06:40:01 -0500 (Wed, 03 Dec 2008)
New Revision: 391
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java
Log:
implicit add -> fail when getting instance of bean not registered in manager
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-02
22:26:39 UTC (rev 390)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/proxy/ProxyPool.java 2008-12-03
11:40:01 UTC (rev 391)
@@ -27,6 +27,7 @@
import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyObject;
+import javax.webbeans.DefinitionException;
import javax.webbeans.UnproxyableDependencyException;
import javax.webbeans.manager.Bean;
@@ -174,15 +175,16 @@
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;
+ throw new DefinitionException(bean + " is not known to the
manager");
}
clientProxy = createClientProxy(bean, beanIndex);
}
+ catch (DefinitionException e)
+ {
+ throw e;
+ }
catch (Exception e)
{
// TODO: What to *really* do here?
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-12-02
22:26:39 UTC (rev 390)
+++
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ClientProxyTest.java 2008-12-03
11:40:01 UTC (rev 391)
@@ -6,6 +6,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import javax.webbeans.DefinitionException;
import javax.webbeans.UnproxyableDependencyException;
import javax.webbeans.manager.Bean;
@@ -85,11 +86,11 @@
assert tuna.getState().equals("tuned");
}
- @Test(groups = "Reflections")
- public void testProxyCreationDoesImplicitAddBean() {
+ @Test(groups = "Reflections", expectedExceptions=DefinitionException.class)
+ public void testGettingUnknownBeanFails() {
Bean<Tuna> tunaBean = BeanFactory.createSimpleBean(Tuna.class, manager);
Tuna tuna = manager.getInstance(tunaBean);
- assert manager.getBeans().size() == 2;
+ assert false;
}
}