DATAJPA-813 - Made JNDI EntityManagerFactory detection more lenient.

We now don't assume an expectedType property configured for every declaration of <jee:jndi-lookup /> but rather skip elements that don't have the attribute configured.
This commit is contained in:
Oliver Gierke
2016-03-05 16:12:25 +01:00
parent 2509955a54
commit 154e3370cf
3 changed files with 6 additions and 2 deletions

View File

@@ -124,7 +124,7 @@ public class BeanDefinitionUtils {
BeanDefinition definition = beanFactory.getBeanDefinition(name);
if (JNDI_OBJECT_FACTORY_BEAN.equals(definition.getBeanClassName())) {
if (!definition.getPropertyValues().get("expectedType").equals(EntityManagerFactory.class.getName())) {
if (!EntityManagerFactory.class.getName().equals(definition.getPropertyValues().get("expectedType"))) {
return;
}
}

View File

@@ -133,6 +133,7 @@ public class DefaultJpaContextIntegrationTests {
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
builder.bind("some/EMF", createEntityManagerFactory("spring-data-jpa"));
builder.bind("some/other/Component", new Object());
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("config/jpa-context-with-jndi.xml");
ApplicationComponent component = context.getBean(ApplicationComponent.class);

View File

@@ -14,7 +14,10 @@
<jee:jndi-lookup id="entityManagerFactory"
jndi-name="some/EMF"
expected-type="javax.persistence.EntityManagerFactory" />
<jee:jndi-lookup id="someOtherJndiBean"
jndi-name="some/other/Component" />
<bean class="org.springframework.data.jpa.repository.support.DefaultJpaContextIntegrationTests$ApplicationComponent" autowire="constructor" />
</beans>