use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project ORCID-Source by ORCID.
the class TestXmlValidity method testAllOrcidMessages.
@Test
public void testAllOrcidMessages() throws IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resolver.getResources("classpath*:**/*message-latest.xml");
for (Resource resource : resources) {
LOG.info("Found resource: {}", resource);
InputStream is = null;
try {
is = resource.getInputStream();
OrcidMessage message = (OrcidMessage) unmarshaller.unmarshal(is);
validationManager = getValidationManager(message.getMessageVersion());
validationManager.validateMessage(message);
} catch (IOException e) {
Assert.fail("Unable to read resource: " + resource + "\n" + e);
} catch (JAXBException e) {
Assert.fail("ORCID message is not well formed: " + resource + "\n" + e);
} catch (OrcidValidationException e) {
Assert.fail("Validation failed: " + resource + "\n" + e.getCause());
} finally {
IOUtils.closeQuietly(is);
}
}
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project PublicCMS-preview by sanluan.
the class ApplicationConfig method mybatisSqlSessionFactoryBean.
/**
* Mybatis会话工厂
*
* @param dataSource
* @return mybatis session factory
* @throws IOException
*/
@Bean
public SqlSessionFactoryBean mybatisSqlSessionFactoryBean(DataSource dataSource) throws IOException {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
configuration.setCacheEnabled(true);
configuration.setLazyLoadingEnabled(false);
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
bean.setMapperLocations(resolver.getResources("classpath*:mapper/**/*Mapper.xml"));
bean.setConfiguration(configuration);
return bean;
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project CBEC-B2B by A-Cubic.
the class DataSourceConfig method sqlSessionFactoryBean.
@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
// mybatis分页
PageHelper pageHelper = new PageHelper();
Properties props = new Properties();
props.setProperty("dialect", "mysql");
props.setProperty("reasonable", "true");
props.setProperty("supportMethodsArguments", "false");
// props.setProperty("returnPageInfo", "check");
// props.setProperty("params", "count=countSql");
pageHelper.setProperties(props);
// 添加插件
sqlSessionFactoryBean.setPlugins(new Interceptor[] { pageHelper });
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));
return sqlSessionFactoryBean.getObject();
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project nextprot-api by calipho-sib.
the class FilePatternDictionary method loadResources.
protected void loadResources() {
resourcesMap = new TreeMap<>();
Resource[] resources;
try {
resources = new PathMatchingResourcePatternResolver().getResources(getLocation());
for (Resource r : resources) {
resourcesMap.put(r.getFilename().replace(getExtension(), ""), Resources.toString(r.getURL(), Charsets.UTF_8));
}
} catch (IOException e) {
throw new NextProtException("Error on loading SQL Dict", e);
}
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project molgenis by molgenis.
the class SchemaLoader method getSchema.
private Resource getSchema(String schemaName) throws IOException {
if (schemaName.contains("/")) {
schemaName = schemaName.substring(schemaName.lastIndexOf('/'));
}
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
String searchPattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "/**/" + schemaName;
Resource[] resources = resourcePatternResolver.getResources(searchPattern);
if ((resources == null) || (resources.length == 0)) {
throw new RuntimeException("Could not find schema [" + schemaName + "]");
}
return resources[0];
}
Aggregations