1 package org.enhydra.util; 2 3 import java.util.Enumeration ; 4 import java.util.Hashtable ; 5 6 import javax.naming.Context ; 7 import javax.naming.Name ; 8 import javax.naming.NamingException ; 9 import javax.naming.RefAddr ; 10 import javax.naming.Reference ; 11 import javax.naming.spi.ObjectFactory ; 12 13 public class ConfConfigurationFactory implements ObjectFactory { 14 15 public Object getObjectInstance(Object obj, 16 Name name, Context nameCtx, Hashtable environment) 17 throws NamingException { 18 ConfConfiguration conf = new ConfConfiguration(); 21 22 Reference ref = (Reference ) obj; 24 Enumeration addrs = ref.getAll(); 25 while (addrs.hasMoreElements()) { 26 RefAddr addr = (RefAddr ) addrs.nextElement(); 27 String paramName = addr.getType(); 28 String paramValue = (String ) addr.getContent(); 29 if (paramName.equals("path")) { 30 try { 31 conf.parseConfConfiguration(paramValue); 32 } 33 catch (Exception e){ 34 throw new NamingException (e.getMessage()); 35 } 36 } 37 } 38 return (conf); 40 } 41 42 } 43 44 | Popular Tags |