package org.nutz.ioc.val;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.nutz.ioc.IocMaking;
import org.nutz.ioc.ValueProxy;
import org.nutz.lang.Lang;

/**
 * 通过JNDI查找相应的对象
 * @author wendal(wendal1985@gmail.com)
 *
 */
public class JNDI_Value implements ValueProxy{
	
	private String jndiName;
	private Context cntxt;
	
	public JNDI_Value(String jndiName) {
		this.jndiName = jndiName;
	}

	public Object get(IocMaking ing) {
		try {
			if (cntxt == null)
				cntxt = new InitialContext();
			cntxt.lookup(jndiName);
			return null;
		}
		catch (NamingException e) {
			throw Lang.wrapThrow(e);
		}
	}

}

@@ -558,16 +558,25 @@
 cntxt = 
+(Context)
 new Init
@@ -591,53 +591,68 @@
 xt()
-;%0D%0A%09%09%09cntxt.lookup(jndiName);%0D%0A%09%09%09return null
+.lookup(%22java:/comp/env%22);%0D%0A%09%09%09return cntxt.lookup(jndiName)
 ;%0D%0A%09

修正错误的JNDI_Value实现