1 29 30 package com.caucho.amber.cfg; 31 32 import com.caucho.amber.manager.AmberContainer; 33 import com.caucho.amber.manager.AmberPersistenceUnit; 34 import com.caucho.bytecode.JClass; 35 import com.caucho.vfs.Path; 36 37 import javax.sql.DataSource ; 38 import java.util.HashMap ; 39 import java.util.Map ; 40 41 44 public class PersistenceUnitConfig { 45 private String _name; 46 private String _provider; 47 private DataSource _jtaDataSource; 48 private DataSource _nonJtaDataSource; 49 private boolean _isExcludeUnlistedClasses; 50 51 private HashMap <String , JClass> _classMap 53 = new HashMap <String , JClass>(); 54 55 58 public String getName() 59 { 60 return _name; 61 } 62 63 66 public void setName(String name) 67 { 68 _name = name; 69 } 70 71 74 public void setTransactionType(String type) 75 { 76 } 77 78 81 public void setDescription(String description) 82 { 83 } 84 85 88 public void setProvider(String provider) 89 { 90 _provider = provider; 91 } 92 93 96 public void setJtaDataSource(DataSource ds) 97 { 98 _jtaDataSource = ds; 99 } 100 101 104 public void setNonJtaDataSource(DataSource ds) 105 { 106 _nonJtaDataSource = ds; 107 } 108 109 112 public void addMappingFile(Path file) 113 { 114 } 115 116 119 public void addJarFile(Path file) 120 { 121 } 122 123 126 public void addClass(String cl) 127 { 128 131 _classMap.put(cl, null); 132 } 133 134 137 public void addAllClasses(Map <String , JClass> classMap) 138 { 139 for (Map.Entry <String , JClass> entry : classMap.entrySet()) { 140 String k = entry.getKey(); 141 JClass v = entry.getValue(); 142 143 if (! _classMap.containsKey(k)) 144 _classMap.put(k, v); 145 } 146 } 147 148 151 public void setExcludeUnlistedClasses(boolean isExclude) 152 { 153 _isExcludeUnlistedClasses = isExclude; 154 } 155 156 159 public PropertiesConfig createProperties() 160 { 161 return new PropertiesConfig(); 162 } 163 164 public AmberPersistenceUnit init(AmberContainer container, 165 EntityMappingsConfig entityMappings) 166 throws Exception 167 { 168 AmberPersistenceUnit unit 169 = new AmberPersistenceUnit(container, _name); 170 171 unit.setJPA(true); 172 173 unit.setEntityMappingsConfig(entityMappings); 174 175 unit.init(); 176 177 for (Map.Entry <String , JClass> entry : _classMap.entrySet()) { 178 String className = entry.getKey(); 179 JClass type = entry.getValue(); 180 181 unit.addEntityClass(className, type); 182 } 183 184 unit.generate(); 185 186 return unit; 187 } 188 189 public String toString() 190 { 191 return "PersistenceUnitConfig[" + _name + "]"; 192 } 193 194 public class PropertiesConfig { 195 public PropertyConfig createProperty() 196 { 197 return new PropertyConfig(); 198 } 199 } 200 201 public class PropertyConfig { 202 public void setName(String name) 203 { 204 } 205 206 public void setValue(String name) 207 { 208 } 209 } 210 } 211 | Popular Tags |