ClassPathXmlApplicationContext newContext = new SmartClassPathXmlApplicationContext(emfContextLocation);
try {
// get a reference to the factory bean, don't have it create a new EntityManager
LocalContainerEntityManagerFactoryBean factoryBean = newContext.getBean("&" + emfContextBeanName, LocalContainerEntityManagerFactoryBean.class);
SettingsFactory settingsFactory = new InjectedDataSourceSettingsFactory(factoryBean.getDataSource());
settings = settingsFactory.buildSettings(new Properties());
}
finally {
newContext.close();
}
}