1 25 26 package org.objectweb.easybeans.persistence.xml; 27 28 import java.net.URL ; 29 import java.util.ArrayList ; 30 import java.util.List ; 31 import java.util.Properties ; 32 33 import javax.persistence.spi.ClassTransformer; 34 import javax.persistence.spi.PersistenceProvider; 35 import javax.persistence.spi.PersistenceUnitInfo; 36 import javax.persistence.spi.PersistenceUnitTransactionType; 37 import javax.sql.DataSource ; 38 39 import org.objectweb.easybeans.loader.EasyBeansClassLoader; 40 41 46 public class JPersistenceUnitInfo implements PersistenceUnitInfo { 47 48 52 private String persistenceUnitName = null; 53 54 57 private String persistenceProviderClassName = null; 58 59 64 private PersistenceUnitTransactionType transactionType = null; 65 66 69 private DataSource jtaDataSource = null; 70 71 74 private DataSource nonJtaDataSource = null; 75 76 79 private String jtaDataSourceName = null; 80 81 84 private String nonJtaDataSourceName = null; 85 86 90 private List <String > mappingFileNames = null; 91 92 97 private List <URL > jarFiles = null; 98 99 104 private URL persistenceUnitRootUrl = null; 105 106 111 private List <String > managedClassNames = null; 112 113 119 private boolean excludeUnlistedClasses = false; 120 121 125 private Properties properties = null; 126 127 131 private ClassLoader classLoader = null; 132 133 136 private URL persistenceXmlFileUrl = null; 137 138 142 private List <ClassTransformer> classTransformers = null; 143 144 147 private PersistenceProvider persistenceProvider = null; 148 149 150 153 public JPersistenceUnitInfo() { 154 this.properties = new Properties (); 155 mappingFileNames = new ArrayList <String >(); 156 managedClassNames = new ArrayList <String >(); 157 classTransformers = new ArrayList <ClassTransformer>(); 158 jarFiles = new ArrayList <URL >(); 159 } 160 161 166 public void setClassLoader(final ClassLoader classLoader) { 167 this.classLoader = classLoader; 168 } 169 170 174 public void setPersistenceUnitName(final String persistenceUnitName) { 175 this.persistenceUnitName = persistenceUnitName; 176 } 177 178 182 public String getPersistenceUnitName() { 183 return persistenceUnitName; 184 } 185 186 192 public void addJarFile(final URL jarFile) { 193 this.jarFiles.add(jarFile); 194 } 195 196 200 public void setJtaDataSource(final DataSource jtaDataSource) { 201 this.jtaDataSource = jtaDataSource; 202 } 203 204 208 public void setNonJtaDataSource(final DataSource nonJtaDataSource) { 209 this.nonJtaDataSource = nonJtaDataSource; 210 } 211 212 216 public void setJtaDataSourceName(final String jtaDataSourceName) { 217 this.jtaDataSourceName = jtaDataSourceName; 218 } 219 220 224 public void setNonJtaDataSourceName(final String nonJtaDataSourceName) { 225 this.nonJtaDataSourceName = nonJtaDataSourceName; 226 } 227 228 232 public void addMappingFileName(final String mappingFileName) { 233 this.mappingFileNames.add(mappingFileName); 234 } 235 236 240 public void setPersistenceProviderClassName(final String persistenceProviderClassName) { 241 this.persistenceProviderClassName = persistenceProviderClassName; 242 } 243 244 248 public void setPersistenceProvider(final PersistenceProvider persistenceProvider) { 249 this.persistenceProvider = persistenceProvider; 250 } 251 252 256 public void setPersistenceXmlFileUrl(final URL persistenceXmlFileUrl) { 257 this.persistenceXmlFileUrl = persistenceXmlFileUrl; 258 } 259 260 264 public void setProperties(final Properties properties) { 265 this.properties = properties; 266 } 267 268 272 public String getPersistenceProviderClassName() { 273 return persistenceProviderClassName; 274 } 275 276 279 public PersistenceProvider getPersistenceProvider() { 280 return persistenceProvider; 281 } 282 283 288 public DataSource getJtaDataSource() { 289 return jtaDataSource; 290 } 291 292 299 public DataSource getNonJtaDataSource() { 300 return nonJtaDataSource; 301 } 302 303 312 public List <String > getMappingFileNames() { 313 return mappingFileNames; 314 } 315 316 324 public List <URL > getJarFiles() { 325 return jarFiles; 326 } 327 328 333 public Properties getProperties() { 334 return properties; 335 } 336 337 341 public ClassLoader getClassLoader() { 342 return classLoader; 343 } 344 345 351 public URL getPersistenceXmlFileUrl() { 352 return persistenceXmlFileUrl; 353 } 354 355 359 public String getJtaDataSourceName() { 360 return jtaDataSourceName; 361 } 362 363 367 public String getNonJtaDataSourceName() { 368 return nonJtaDataSourceName; 369 } 370 371 376 public PersistenceUnitTransactionType getTransactionType() { 377 return transactionType; 378 } 379 380 386 public void setTransactionType(final PersistenceUnitTransactionType transactionType) { 387 this.transactionType = transactionType; 388 } 389 390 396 public List <URL > getJarFileUrls() { 397 return jarFiles; 398 } 399 400 405 public void setPersistenceUnitRootUrl(final URL persistenceUnitRootUrl) { 406 this.persistenceUnitRootUrl = persistenceUnitRootUrl; 407 } 408 409 415 public URL getPersistenceUnitRootUrl() { 416 return persistenceUnitRootUrl; 417 } 418 419 424 public void addClass(final String className) { 425 managedClassNames.add(className); 426 } 427 428 434 public List <String > getManagedClassNames() { 435 return managedClassNames; 436 } 437 438 443 public void setExcludeUnlistedClasses(final boolean excludeUnlistedClasses) { 444 this.excludeUnlistedClasses = excludeUnlistedClasses; 445 } 446 447 454 public boolean excludeUnlistedClasses() { 455 return excludeUnlistedClasses; 456 } 457 458 469 public void addTransformer(final ClassTransformer transformer) { 470 classTransformers.add(transformer); 471 } 472 473 483 public ClassLoader getNewTempClassLoader() { 484 if (classLoader instanceof EasyBeansClassLoader) { 485 EasyBeansClassLoader currentCL = (EasyBeansClassLoader) classLoader; 486 return (EasyBeansClassLoader) currentCL.clone(); 487 } 488 throw new IllegalStateException ("Cannot build a new temporary classloader"); 489 } 490 491 } 492 | Popular Tags |