Author: dallen6
Date: 2009-03-23 14:42:31 -0400 (Mon, 23 Mar 2009)
New Revision: 2151
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/NamingContext.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractNamingContext.java
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java
Log:
Added some servlet session context tests, JNDI manager test (broken), and RI/SPI changes
to support JNDI binding of Manager.
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/NamingContext.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/NamingContext.java 2009-03-23
18:42:20 UTC (rev 2150)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/NamingContext.java 2009-03-23
18:42:31 UTC (rev 2151)
@@ -50,4 +50,10 @@
*/
public void bind(String name, Object value);
+ /**
+ * Unbinds an entry from JNDI.
+ *
+ * @param key The key of the object in JNDI to unbind
+ */
+ public void unbind(String key);
}
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractNamingContext.java
===================================================================
---
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractNamingContext.java 2009-03-23
18:42:20 UTC (rev 2150)
+++
ri/trunk/spi/src/main/java/org/jboss/webbeans/resources/spi/helpers/AbstractNamingContext.java 2009-03-23
18:42:31 UTC (rev 2151)
@@ -49,9 +49,18 @@
{
List<String> parts = splitIntoContexts(key);
Context context = getContext();
+ Context nextContext = null;
for (int i = 0; i < parts.size() - 1; i++)
{
- context = (Context) context.lookup(parts.get(i));
+ try
+ {
+ nextContext = (Context) context.lookup(parts.get(i));
+ }
+ catch (NamingException e)
+ {
+ nextContext = context.createSubcontext(parts.get(i));
+ }
+ context = nextContext;
}
context.bind(parts.get(parts.size() - 1), value);
}
@@ -62,6 +71,23 @@
}
/**
+ * Unbinds an entry from JNDI.
+ *
+ * @param key The key of the object in JNDI to unbind
+ */
+ public void unbind(String key)
+ {
+ try
+ {
+ getContext().unbind(key);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Cannot unbind " + key, e);
+ }
+ }
+
+ /**
* Lookup an item from JNDI
*
* @param name The key
Modified:
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java
===================================================================
---
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java 2009-03-23
18:42:20 UTC (rev 2150)
+++
ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockNamingContext.java 2009-03-23
18:42:31 UTC (rev 2151)
@@ -16,5 +16,11 @@
// TODO Auto-generated method stub
return null;
}
+
+ public void unbind(String key)
+ {
+ // TODO Auto-generated method stub
+
+ }
}
Show replies by date