01: package org.enhydra.util;
02:
03: import java.util.Enumeration;
04: import java.util.Hashtable;
05:
06: import javax.naming.Context;
07: import javax.naming.Name;
08: import javax.naming.NamingException;
09: 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, Name name,
16: Context nameCtx, Hashtable environment)
17: throws NamingException {
18: // Acquire an instance of our specified bean class
19: //MyBean bean = new MyBean();
20: ConfConfiguration conf = new ConfConfiguration();
21:
22: // Customize the bean properties from our attributes
23: 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: } catch (Exception e) {
33: throw new NamingException(e.getMessage());
34: }
35: }
36: }
37: // Return the customized instance
38: return (conf);
39: }
40:
41: }
|