Search in sources :

Example 11 with ResourcePatternResolver

use of org.springframework.core.io.support.ResourcePatternResolver in project modesti by jlsalmon.

the class RequestParserFactoryTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(Thread.currentThread().getContextClassLoader());
    Resource[] sheets = resolver.getResources("classpath:/sheets/**/*.xls*");
    for (Resource sheet : sheets) {
        RequestParserFactoryTest.sheets.put(sheet.getFilename(), sheet);
    }
}
Also used : PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) Resource(org.springframework.core.io.Resource) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) BeforeClass(org.junit.BeforeClass)

Example 12 with ResourcePatternResolver

use of org.springframework.core.io.support.ResourcePatternResolver in project syndesis by syndesisio.

the class DataManager method loadData.

private void loadData() {
    try {
        final ResourcePatternResolver resolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
        final Resource[] resources = resolver.getResources("classpath:/META-INF/syndesis/connector/*.json");
        if (resources != null) {
            ReadApiClientData reader = new ReadApiClientData(encryptionComponent);
            for (Resource resource : resources) {
                try (InputStream is = resource.getInputStream()) {
                    // Replace placeholders
                    final String text = reader.findAndReplaceTokens(StreamUtils.copyToString(is, StandardCharsets.UTF_8), System.getenv());
                    Connector connector = Json.reader().forType(Connector.class).readValue(text);
                    if (connector != null) {
                        LOGGER.info("Load connector: {} from resource: {}", connector.getId().orElse(""), resource.getURI());
                        store(connector, Connector.class);
                    }
                }
            }
        }
    } catch (FileNotFoundException ignored) {
    // ignore
    } catch (IOException e) {
        throw new IllegalStateException("Cannot load connector from resources due to: " + e.getMessage(), e);
    }
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ReadApiClientData(io.syndesis.server.dao.init.ReadApiClientData)

Example 13 with ResourcePatternResolver

use of org.springframework.core.io.support.ResourcePatternResolver in project spring-cloud by Rogge666.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(ProjectConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    // 分页尺寸为0时查询所有纪录不再执行分页
    properties.setProperty("pageSizeZero", "true");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 14 with ResourcePatternResolver

use of org.springframework.core.io.support.ResourcePatternResolver in project spring-cloud by Rogge666.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(ProjectConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    // 分页尺寸为0时查询所有纪录不再执行分页
    properties.setProperty("pageSizeZero", "true");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 15 with ResourcePatternResolver

use of org.springframework.core.io.support.ResourcePatternResolver in project spring-cloud by Rogge666.

the class MybatisConfigurer method sqlSessionFactoryBean.

@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setTypeAliasesPackage(ProjectConstant.MODEL_PACKAGE);
    // 分页插件
    PageHelper pageHelper = new PageHelper();
    Properties properties = new Properties();
    properties.setProperty("reasonable", "true");
    properties.setProperty("supportMethodsArguments", "true");
    properties.setProperty("returnPageInfo", "check");
    properties.setProperty("params", "count=countSql");
    // 分页尺寸为0时查询所有纪录不再执行分页
    properties.setProperty("pageSizeZero", "true");
    pageHelper.setProperties(properties);
    // 添加插件
    bean.setPlugins(new Interceptor[] { pageHelper });
    // 添加XML目录
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
    return bean.getObject();
}
Also used : PageHelper(com.github.pagehelper.PageHelper) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Properties(java.util.Properties) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)65 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)62 Resource (org.springframework.core.io.Resource)49 IOException (java.io.IOException)15 Bean (org.springframework.context.annotation.Bean)11 ArrayList (java.util.ArrayList)10 PageHelper (com.github.pagehelper.PageHelper)9 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)9 CachingMetadataReaderFactory (org.springframework.core.type.classreading.CachingMetadataReaderFactory)9 MetadataReader (org.springframework.core.type.classreading.MetadataReader)9 MetadataReaderFactory (org.springframework.core.type.classreading.MetadataReaderFactory)9 File (java.io.File)8 Properties (java.util.Properties)8 InputStream (java.io.InputStream)5 URL (java.net.URL)5 FileOutputStream (java.io.FileOutputStream)3 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)3 EventLoopGroup (io.netty.channel.EventLoopGroup)2 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 SocketChannel (io.netty.channel.socket.SocketChannel)2