KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > util > ConfConfigurationFactory


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