diff --git a/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java b/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java index 645dff709a..615ab565b4 100644 --- a/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java +++ b/entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java @@ -324,7 +324,7 @@ public class Ejb3Configuration implements Serializable, Referenceable { Scanner scanner = null; URL jarURL = null; if ( metadata.getName() == null ) { - scanner = buildScanner( metadata.getProps() ); + scanner = buildScanner( metadata.getProps(), integration ); jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" ); metadata.setName( scanner.getUnqualifiedJarName(jarURL) ); } @@ -333,7 +333,7 @@ public class Ejb3Configuration implements Serializable, Referenceable { } else if ( persistenceUnitName == null || metadata.getName().equals( persistenceUnitName ) ) { if (scanner == null) { - scanner = buildScanner( metadata.getProps() ); + scanner = buildScanner( metadata.getProps(), integration ); jarURL = JarVisitorFactory.getJarURLFromURLEntry( url, "/META-INF/persistence.xml" ); } //scan main JAR @@ -373,8 +373,12 @@ public class Ejb3Configuration implements Serializable, Referenceable { } } - private Scanner buildScanner(Properties properties) { - final Object scanner = properties.getProperty( AvailableSettings.SCANNER ); + private Scanner buildScanner(Properties properties, Map integration) { + //read the String or Instance from the integration map first and use the properties as a backup. + Object scanner = integration.get( AvailableSettings.SCANNER ); + if (scanner == null) { + scanner = properties.getProperty( AvailableSettings.SCANNER ); + } if (scanner != null) { Class scannerClass; if ( scanner instanceof String ) { @@ -565,7 +569,7 @@ public class Ejb3Configuration implements Serializable, Referenceable { ScanningContext context = new ScanningContext(); final Properties copyOfProperties = (Properties) info.getProperties().clone(); ConfigurationHelper.overrideProperties( copyOfProperties, integration ); - context.scanner( buildScanner( copyOfProperties ) ) + context.scanner( buildScanner( copyOfProperties, integration ) ) .searchOrm( searchForORMFiles ) .explicitMappingFiles( null ); //URLs provided by the container already diff --git a/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/ScannerTest.java b/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/ScannerTest.java index 3c5936e5f9..643d533fe5 100644 --- a/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/ScannerTest.java +++ b/entitymanager/src/test/java/org/hibernate/ejb/test/packaging/ScannerTest.java @@ -35,6 +35,7 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.MappedSuperclass; import javax.persistence.Persistence; +import org.hibernate.ejb.AvailableSettings; import org.hibernate.ejb.packaging.NamedInputStream; import org.hibernate.ejb.packaging.NativeScanner; import org.hibernate.ejb.packaging.Scanner; @@ -82,12 +83,19 @@ public class ScannerTest extends PackagingTestCase { EntityManagerFactory emf; CustomScanner.resetUsed(); - emf = Persistence.createEntityManagerFactory( "defaultpar", new HashMap() ); + final HashMap integration = new HashMap(); + emf = Persistence.createEntityManagerFactory( "defaultpar", integration ); assertTrue( ! CustomScanner.isUsed() ); emf.close(); CustomScanner.resetUsed(); - emf = Persistence.createEntityManagerFactory( "manager1", new HashMap() ); + emf = Persistence.createEntityManagerFactory( "manager1", integration ); + assertTrue( CustomScanner.isUsed() ); + emf.close(); + + CustomScanner.resetUsed(); + integration.put( AvailableSettings.SCANNER, new CustomScanner() ); + emf = Persistence.createEntityManagerFactory( "defaultpar", integration ); assertTrue( CustomScanner.isUsed() ); emf.close(); }