I want to read a bunch of text files, by loading them as resources using the context classloader.
URL url = Thread.currentThread()
.getContextCla
Comment from "Binil Thomas" was on the right track, I was looking for confirmation that Spring's PathMatchingResourcePatternResolver could be used from Java Config so that I could give the resulting "Resource" list to the Spring Hibernate SessionFactory.mappingLocations without having to update the list of Hibernate *.hbm.xml files every time a new mapping file was added. I was able to achieve this with the PathMatchingResourcePatternResolver using the below code:
import org.hibernate.SessionFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
...
ResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
Resource [] mappingLocations = patternResolver.getResources("classpath*:mappings/**/*.hbm.xml");
sessionFactory.setMappingLocations(mappingLocations);
Works like a charm.