1 24 package fr.dyade.aaa.jndi2.soap; 25 26 import org.objectweb.util.monolog.api.BasicLevel; 27 import org.objectweb.util.monolog.api.Logger; 28 29 import java.util.Hashtable ; 30 31 import javax.naming.Context ; 32 import javax.naming.InitialContext ; 33 import javax.naming.NamingException ; 34 35 36 43 public class JndiSoapService 44 { 45 46 public static final Logger logger = fr.dyade.aaa.util.Debug.getLogger( 47 JndiSoapService.class.getName()); 48 49 50 private Context ctx; 51 52 61 public void init(String jndiHost, int jndiPort) throws NamingException 62 { 63 java.util.Hashtable env = new java.util.Hashtable (); 64 env.put("java.naming.factory.initial", 65 "fr.dyade.aaa.jndi2.client.NamingContextFactory"); 66 env.put("java.naming.factory.host", jndiHost); 67 env.put("java.naming.factory.port", "" + jndiPort); 68 ctx = new InitialContext (env); 69 } 70 71 80 public void bind(String name, Hashtable map) throws NamingException 81 { 82 ctx.bind(name, SoapObjectHelper.soapDecode(map)); 83 } 84 85 94 public void rebind(String name, Hashtable map) throws NamingException 95 { 96 ctx.rebind(name, SoapObjectHelper.soapDecode(map)); 97 } 98 99 105 public Hashtable lookup(String name) throws NamingException 106 { 107 try { 108 return SoapObjectHelper.soapCode(ctx.lookup(name)); 109 } catch (Throwable exc) { 110 if (logger.isLoggable(BasicLevel.DEBUG)) 111 logger.log(BasicLevel.DEBUG, "", exc); 112 throw new NamingException (exc.toString()); 113 } 114 } 115 116 121 public void unbind(String name) throws NamingException 122 { 123 ctx.unbind(name); 124 } 125 } 126 | Popular Tags |