use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project Assignment by WMPeople.
the class AssignmentApplication method sqlSessionFactory.
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
Resource[] res = new PathMatchingResourcePatternResolver().getResources("Mapper/*Mapper.xml");
sessionFactory.setMapperLocations(res);
return sessionFactory.getObject();
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project OpenClinica by OpenClinica.
the class CoreResources method copyImportRulesFiles.
private void copyImportRulesFiles() throws IOException {
ByteArrayInputStream[] listSrcFiles = new ByteArrayInputStream[3];
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(resourceLoader);
String[] fileNames = { "rules.xsd", "rules_template.xml", "rules_template_with_notes.xml" };
Resource[] resources = null;
FileOutputStream out = null;
resources = resolver.getResources("classpath*:properties/rules_template*.xml");
File dest = new File(getField("filePath") + "rules");
if (!dest.exists()) {
if (!dest.mkdirs()) {
throw new OpenClinicaSystemException("Copying files, Could not create direcotry: " + dest.getAbsolutePath() + ".");
}
}
for (Resource r : resources) {
File f = new File(dest, r.getFilename());
out = new FileOutputStream(f);
IOUtils.copy(r.getInputStream(), out);
out.close();
}
Resource[] r1 = resolver.getResources("classpath*:properties/" + fileNames[0]);
File f1 = new File(dest, r1[0].getFilename());
out = new FileOutputStream(f1);
IOUtils.copy(r1[0].getInputStream(), out);
out.close();
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project OpenClinica by OpenClinica.
the class CoreResources method copyODMMappingXMLtoResources.
private void copyODMMappingXMLtoResources(ResourceLoader resourceLoader) {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(resourceLoader);
String[] fileNames = { "cd_odm_mapping.xml" };
Resource[] resources;
try {
resources = resolver.getResources("classpath*:properties/cd_odm_mapping.xml");
} catch (IOException ioe) {
OpenClinicaSystemException oe = new OpenClinicaSystemException("Unable to read source files");
oe.initCause(ioe);
oe.setStackTrace(ioe.getStackTrace());
logger.debug(ioe.getMessage());
throw oe;
}
File dest = null;
try {
dest = new File(getField("filePath"));
if (!dest.exists()) {
if (!dest.mkdirs()) {
throw new OpenClinicaSystemException("Copying files, Could not create direcotry: " + dest.getAbsolutePath() + ".");
}
}
File f = new File(dest, resources[0].getFilename());
FileOutputStream out = new FileOutputStream(f);
IOUtils.copy(resources[0].getInputStream(), out);
out.close();
} catch (IOException ioe) {
OpenClinicaSystemException oe = new OpenClinicaSystemException("Unable to get web app base path");
oe.initCause(ioe);
oe.setStackTrace(ioe.getStackTrace());
throw oe;
}
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project OpenClinica by OpenClinica.
the class CoreResources method copyConfig.
private void copyConfig() throws IOException {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(resourceLoader);
Resource[] resources = null;
FileOutputStream out = null;
Resource resource1 = null;
Resource resource2 = null;
resource1 = resolver.getResource("classpath:datainfo.properties");
resource2 = resolver.getResource("classpath:extract.properties");
String filePath = "$catalina.home/$WEBAPP.lower.config";
filePath = replaceWebapp(filePath);
filePath = replaceCatHome(filePath);
File dest = new File(filePath);
if (!dest.exists()) {
if (!dest.mkdirs()) {
throw new OpenClinicaSystemException("Copying files, Could not create directory: " + dest.getAbsolutePath() + ".");
}
}
File f1 = new File(dest, resource1.getFilename());
File f2 = new File(dest, resource2.getFilename());
if (!f1.exists()) {
out = new FileOutputStream(f1);
IOUtils.copy(resource1.getInputStream(), out);
out.close();
}
if (!f2.exists()) {
out = new FileOutputStream(f2);
IOUtils.copy(resource2.getInputStream(), out);
out.close();
}
/*
*
* for (Resource r: resources) { File f = new File(dest, r.getFilename()); if(!f.exists()){ out = new
* FileOutputStream(f); IOUtils.copy(r.getInputStream(), out); out.close(); } }
*/
}
use of org.springframework.core.io.support.PathMatchingResourcePatternResolver in project mybatis.flying by limeng32.
the class SqlSessionFactory3Config method sqlSessionFactoryBean.
@Bean(name = "sqlSessionFactoryExamine")
public SqlSessionFactoryBean sqlSessionFactoryBean() throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
// 配置数据源,此处配置为关键配置,如果没有将 dynamicDataSource作为数据源则不能实现切换
sessionFactory.setDataSource(dataSourceExamine);
VFS.addImplClass(SpringBootVFS.class);
// 扫描Model
sessionFactory.setTypeAliasesPackage("indi.mybatis.flying");
sessionFactory.setConfigLocation(new ClassPathResource("Configuration.xml"));
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource[] ra2 = resolver.getResources("classpath*:indi/mybatis/flying/mapper*/*.xml");
Resource[] ra = (Resource[]) ArrayUtils.addAll(null, ra2);
// 扫描映射文件
sessionFactory.setMapperLocations(ra);
return sessionFactory;
}
Aggregations