1 28 29 package com.caucho.ejb.cfg; 30 31 import com.caucho.config.BuilderProgram; 32 import com.caucho.config.BuilderProgramContainer; 33 import com.caucho.config.ConfigException; 34 import com.caucho.config.DependencyBean; 35 import com.caucho.util.L10N; 36 import com.caucho.vfs.PersistentDependency; 37 38 import javax.annotation.PostConstruct; 39 import java.util.ArrayList ; 40 41 45 public class EjbBeanConfigProxy implements DependencyBean { 46 private static final L10N L = new L10N(EjbBeanConfigProxy.class); 47 48 private final EjbConfig _config; 49 private final String _ejbModuleName; 50 51 private String _ejbName; 52 53 private String _filename = ""; 54 private String _location = ""; 55 56 private BuilderProgramContainer _program = new BuilderProgramContainer(); 58 59 private EjbBean _bean; 60 61 ArrayList <PersistentDependency> _dependList = 62 new ArrayList <PersistentDependency>(); 63 64 67 public EjbBeanConfigProxy(EjbConfig config, String ejbModuleName) 68 { 69 _config = config; 70 _ejbModuleName = ejbModuleName; 71 } 72 73 76 public EjbConfig getConfig() 77 { 78 return _config; 79 } 80 81 public String getEJBModuleName() 82 { 83 return _ejbModuleName; 84 } 85 86 89 public void setConfigLocation(String filename, int line) 90 { 91 _filename = filename; 92 _location = filename + ":" + line + ": "; 93 } 94 95 98 public String getLocation() 99 { 100 return _location; 101 } 102 103 106 public String getFilename() 107 { 108 return _filename; 109 } 110 111 114 public void setEJBName(String ejbName) 115 { 116 _ejbName = ejbName; 117 } 118 119 122 public String getEJBName() 123 { 124 return _ejbName; 125 } 126 127 130 public void addDependency(PersistentDependency depend) 131 { 132 if (! _dependList.contains(depend)) 133 _dependList.add(depend); 134 } 135 136 139 public ArrayList <PersistentDependency> getDependencyList() 140 { 141 return _dependList; 142 } 143 144 147 public void addBuilderProgram(BuilderProgram program) 148 { 149 _program.addProgram(program); 150 } 151 152 155 public BuilderProgram getBuilderProgram() 156 { 157 return _program; 158 } 159 160 163 @PostConstruct 164 public void init() 165 throws Throwable 166 { 167 _bean = getConfig().getBeanConfig(getEJBName()); 168 169 if (_bean == null) { 170 throw new ConfigException(L.l("bean '{0}' has no primary definition.", 171 getEJBName())); 172 } 173 174 176 getBuilderProgram().configure(_bean); 177 } 178 179 182 public EjbBean getBean() 183 { 184 return _bean; 185 } 186 } 187 | Popular Tags |