[hibernate-dev] Hibernate EntityManager reusing MC facilities

Emmanuel Bernard emmanuel at hibernate.org
Sat Apr 18 10:37:07 EDT 2009


I have implemented the first part of it (committed in trunk)

The scanning process is now abstracted according to an interface  
similar to the one proposed in this email.
I've retrofitted the existing model into this interface. We're just  
waiting for the implementation on the jboss infra side and we will use  
it when available (using reflection to avoid runtime dependency).

http://opensource.atlassian.com/projects/hibernate/browse/EJB-427
http://opensource.atlassian.com/projects/hibernate/browse/EJB-428

PS: Set<Class<? extends Annotation>> turns out to be a bit annoying to  
use. Maybe we should use varargs and lose some of the type safety?


On  Mar 28, 2009, at 03:19, Emmanuel Bernard wrote:

> 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);
>
>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev




More information about the hibernate-dev mailing list