1 28 29 package com.caucho.config.types; 30 31 import com.caucho.config.BuilderProgram; 32 import com.caucho.config.BuilderProgramContainer; 33 import com.caucho.config.Config; 34 import com.caucho.config.ConfigException; 35 import com.caucho.config.NodeBuilder; 36 import com.caucho.util.L10N; 37 38 41 public class InitProgram { 42 private static L10N L = new L10N(InitProgram.class); 43 44 private BuilderProgramContainer _init; 45 46 public InitProgram() 47 { 48 _init = new BuilderProgramContainer(NodeBuilder.getCurrentBuilder()); 49 } 50 51 public InitProgram(BuilderProgram program) 52 { 53 this(); 54 55 addBuilderProgram(program); 56 } 57 58 61 public void addBuilderProgram(BuilderProgram program) 62 { 63 _init.addProgram(program); 64 } 65 66 69 public BuilderProgram getBuilderProgram() 70 { 71 return _init; 72 } 73 74 77 public Object create(Class type) 78 throws ConfigException 79 { 80 if (_init != null) 81 return _init.configure(type); 82 else 83 return null; 84 } 85 86 89 public void configure(Object obj) 90 throws ConfigException 91 { 92 if (_init != null) 93 _init.configure(obj); 94 } 95 96 99 public void init(Object obj) 100 throws Throwable 101 { 102 configure(obj); 103 104 if (_init != null) 105 _init.init(obj); 106 else 107 Config.init(obj); 108 } 109 110 public String toString() 111 { 112 return "Init[" + _init + "]"; 113 } 114 } 115 116 | Popular Tags |