[hibernate-dev] Hibernate EntityManager reusing MC facilities

Emmanuel Bernard emmanuel at hibernate.org
Fri Mar 27 17:49:19 EDT 2009


I have been chatting with Ales and here is the contract that HEM could  
rely on to scan entities and DD files.

Context:
An EntityManagerFactory (EMF) is bootstrapped by the container by  
passing a PersistenceUnitInfo class
http://anonsvn.jboss.org/repos/hibernate/jpa-api/trunk/src/main/java/javax/persistence/spi/PersistenceUnitInfo.java

Which gives:
  - the root URL of the PU
  - the mapping files
  - the URLs of the jars to scan

The container will also pass the MC discovery contract implementation  
in the contextual Map.
If this impl is available in the Map, HEM will go use the MC  
facilities, if not, it will rely on it's own legacy infrastructure.

Here is a proposal for the contract

/**
  * return all packages in the jar matching one of these annotations
  * if annotationsToLookFor is empty, return all packages
  */
Set<Package> getPackagesInJar(URL jartoScan, List<Annotation>  
annotationsToLookFor);

/**
  * return all classes in the jar matching one of these annotations
  * if annotationsToLookFor is empty, return all classes
  */
Set<Class<?>> getClassesInJar(URL jartoScan, List<Annotation>  
annotationsToLookFor);

/**
  * return all files in the jar matching one of these file names
  * if filePatterns is empty, return all files
  * eg **/*.hbm.xml, META-INF/orm.xml
  */
Set<[structure containing file name + InputStream]> getFilesInJar(URL  
jartoScan, List<String> filePatterns);

Optional contract but would be nice to have:

/**
  * return all files in the classpath (ie PU visibility) matching one  
of these file names
  * if filePatterns is empty, return all files
  * the use case is really exact file name.
  */
Set<[structure containing file name + InputStream]>  
getFilesInClasspath(URL jartoScan, List<String> filePatterns);

/** return the unqualified JAR name ie customer-model.jar or store.war  
*/
String getUnqualifiedJarName(URL);






More information about the hibernate-dev mailing list