[jboss-user] [EJB 3.0] - Re: Web Beans + JPA
epbernard
do-not-reply at jboss.com
Tue Apr 7 10:08:18 EDT 2009
https://anonsvn.jboss.org/repos/hibernate/core/trunk/entitymanager/src/main/java/org/hibernate/ejb/packaging/PersistenceXmlLoader.java
is your best shot.
Enumeration<URL> xmls = Thread.currentThread()
| .getContextClassLoader()
| .getResources( "META-INF/persistence.xml" );
| if ( ! xmls.hasMoreElements() ) {
| log.info( "Could not find any META-INF/persistence.xml file in the classpath");
| }
| while ( xmls.hasMoreElements() ) {
| URL url = xmls.nextElement();
| log.trace( "Analysing persistence.xml: {}", url );
| List<PersistenceMetadata> metadataFiles = PersistenceXmlLoader.deploy(
| url,
| integration,
| cfg.getEntityResolver(),
| PersistenceUnitTransactionType.JTA ); //might be RESOURCE_LOCAL in EE?
| for ( PersistenceMetadata metadata : metadataFiles ) {
| String provider = metadata.getProvider(); //could be used for a shortcut if Hibernate
| List<String> classes = metadata.getClasses();
| //same for mappingFiles can be orm.xml or hbm.xml with Hibernate
| Set<String> jarFiles = ...; //need to scan these for @Entity @Embedded @MappedSuperclass
| boolean exclude = metadata.getExcludeUnlistedClasses();
| //if exclude == true => do not scan @Entity @Embedded @MappedSuperclass in the *main* jar
|
| }
| }
you will also need orm.xml parsing and check for , <mapped-superclass > and
consider as the default package.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4224062#4224062
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4224062
More information about the jboss-user
mailing list