User: starksm
Date: 01/05/09 01:15:02
Added: src/main/org/jboss/naming Util.java
Log:
A static utility class for common JNDI operations
Revision Changes Path
1.1 jboss/src/main/org/jboss/naming/Util.java
Index: Util.java
===================================================================
package org.jboss.naming;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
/** A static utility class for common JNDI operations.
*
* @author [EMAIL PROTECTED]
* @version
*/
public class Util
{
/** Bind val to name in ctx, and make sure that all intermediate contexts exist
*/
public static void bind(Context ctx, String name, Object value) throws
NamingException
{
Name n = ctx.getNameParser("").parse(name);
while( n.size() > 1 )
{
String ctxName = n.get(0);
try
{
ctx = (Context) ctx.lookup(ctxName);
}
catch(NameNotFoundException e)
{
ctx = ctx.createSubcontext(ctxName);
}
n = n.getSuffix(1);
}
ctx.bind(n.get(0), value);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development