当前位置: 首页>>代码示例>>Java>>正文


Java ResourcePatternUtils类代码示例

本文整理汇总了Java中org.springframework.core.io.support.ResourcePatternUtils的典型用法代码示例。如果您正苦于以下问题:Java ResourcePatternUtils类的具体用法?Java ResourcePatternUtils怎么用?Java ResourcePatternUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResourcePatternUtils类属于org.springframework.core.io.support包,在下文中一共展示了ResourcePatternUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
void map(@NonNull HttpConfiguration httpConfiguration) throws IOException {
  org.springframework.core.io.Resource[] resources;

  try {
    resources = ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources(
        applicationProperties.getResourcePath() + "/openapi/**.y*ml");
  } catch (FileNotFoundException exp) {
    LOG.warn("No Open API resources found in path:{}/openapi",
        applicationProperties.getResourcePath());
    return;
  }

  for (org.springframework.core.io.Resource resource : resources) {
    InputStream inputStream =
        new EnvironmentAwareResource(resource.getInputStream(), environment).getInputStream();
    String result = CharStreams.toString(new InputStreamReader(inputStream, Charsets.UTF_8));

    if (!StringUtils.isBlank(result)) {
      Swagger swagger = openApiParser.parse(result);
      mapOpenApiDefinition(swagger, httpConfiguration);
    }
  }
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:24,代码来源:OpenApiRequestMapper.java

示例2: getInstance

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Returns an instance which uses the the specified selector, as the name of the
 * definition file(s). In the case of a name with a Spring "classpath*:" prefix,
 * or with no prefix, which is treated the same, the current thread's context class
 * loader's {@code getResources} method will be called with this value to get
 * all resources having that name. These resources will then be combined to form a
 * definition. In the case where the name uses a Spring "classpath:" prefix, or
 * a standard URL prefix, then only one resource file will be loaded as the
 * definition.
 * @param selector the location of the resource(s) which will be read and
 * combined to form the definition for the BeanFactoryLocator instance.
 * Any such files must form a valid ApplicationContext definition.
 * @return the corresponding BeanFactoryLocator instance
 * @throws BeansException in case of factory loading failure
 */
public static BeanFactoryLocator getInstance(String selector) throws BeansException {
	String resourceLocation = selector;
	if (resourceLocation == null) {
		resourceLocation = DEFAULT_RESOURCE_LOCATION;
	}

	// For backwards compatibility, we prepend "classpath*:" to the selector name if there
	// is no other prefix (i.e. "classpath*:", "classpath:", or some URL prefix).
	if (!ResourcePatternUtils.isUrl(resourceLocation)) {
		resourceLocation = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resourceLocation;
	}

	synchronized (instances) {
		if (logger.isTraceEnabled()) {
			logger.trace("ContextSingletonBeanFactoryLocator.getInstance(): instances.hashCode=" +
					instances.hashCode() + ", instances=" + instances);
		}
		BeanFactoryLocator bfl = instances.get(resourceLocation);
		if (bfl == null) {
			bfl = new ContextSingletonBeanFactoryLocator(resourceLocation);
			instances.put(resourceLocation, bfl);
		}
		return bfl;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:ContextSingletonBeanFactoryLocator.java

示例3: getInstance

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Returns an instance which uses the the specified selector, as the name of the
 * definition file(s). In the case of a name with a Spring 'classpath*:' prefix,
 * or with no prefix, which is treated the same, the current thread context
 * ClassLoader's {@code getResources} method will be called with this value
 * to get all resources having that name. These resources will then be combined to
 * form a definition. In the case where the name uses a Spring 'classpath:' prefix,
 * or a standard URL prefix, then only one resource file will be loaded as the
 * definition.
 * @param selector the name of the resource(s) which will be read and
 * combined to form the definition for the BeanFactoryLocator instance.
 * Any such files must form a valid BeanFactory definition.
 * @return the corresponding BeanFactoryLocator instance
 * @throws BeansException in case of factory loading failure
 */
public static BeanFactoryLocator getInstance(String selector) throws BeansException {
	String resourceLocation = selector;
	if (resourceLocation == null) {
		resourceLocation = DEFAULT_RESOURCE_LOCATION;
	}

	// For backwards compatibility, we prepend 'classpath*:' to the selector name if there
	// is no other prefix (i.e. classpath*:, classpath:, or some URL prefix.
	if (!ResourcePatternUtils.isUrl(resourceLocation)) {
		resourceLocation = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resourceLocation;
	}

	synchronized (instances) {
		if (logger.isTraceEnabled()) {
			logger.trace("SingletonBeanFactoryLocator.getInstance(): instances.hashCode=" +
					instances.hashCode() + ", instances=" + instances);
		}
		BeanFactoryLocator bfl = instances.get(resourceLocation);
		if (bfl == null) {
			bfl = new SingletonBeanFactoryLocator(resourceLocation);
			instances.put(resourceLocation, bfl);
		}
		return bfl;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:SingletonBeanFactoryLocator.java

示例4: getConfigLocations

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Subclasses can override this method to return the locations of their
 * config files.
 * <p>A plain path will be treated as class path location, e.g.:
 * "org/springframework/whatever/foo.xml". Note however that you may prefix
 * path locations with standard Spring resource prefixes. Therefore, a
 * config location path prefixed with "classpath:" with behave the same as a
 * plain path, but a config location such as
 * "file:/some/path/path/location/appContext.xml" will be treated as a
 * filesystem location.
 * <p>The default implementation builds config locations for the config paths
 * specified through {@link #getConfigPaths()}.
 * @return an array of config locations
 * @see #getConfigPaths()
 * @see org.springframework.core.io.ResourceLoader#getResource(String)
 */
protected final String[] getConfigLocations() {
	String[] paths = getConfigPaths();
	String[] convertedPaths = new String[paths.length];
	for (int i = 0; i < paths.length; i++) {
		String path = paths[i];
		if (path.startsWith(SLASH)) {
			convertedPaths[i] = ResourceUtils.CLASSPATH_URL_PREFIX + path;
		}
		else if (!ResourcePatternUtils.isUrl(path)) {
			convertedPaths[i] = ResourceUtils.CLASSPATH_URL_PREFIX + SLASH
					+ StringUtils.cleanPath(ClassUtils.classPackageAsResourcePath(getClass()) + SLASH + path);
		}
		else {
			convertedPaths[i] = StringUtils.cleanPath(path);
		}
	}
	return convertedPaths;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:35,代码来源:AbstractSingleSpringContextTests.java

示例5: getInstance

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Returns an instance which uses the specified selector, as the name of the
 * definition file(s). In the case of a name with a Spring "classpath*:" prefix,
 * or with no prefix, which is treated the same, the current thread's context class
 * loader's {@code getResources} method will be called with this value to get
 * all resources having that name. These resources will then be combined to form a
 * definition. In the case where the name uses a Spring "classpath:" prefix, or
 * a standard URL prefix, then only one resource file will be loaded as the
 * definition.
 * @param selector the location of the resource(s) which will be read and
 * combined to form the definition for the BeanFactoryLocator instance.
 * Any such files must form a valid ApplicationContext definition.
 * @return the corresponding BeanFactoryLocator instance
 * @throws BeansException in case of factory loading failure
 */
public static BeanFactoryLocator getInstance(String selector) throws BeansException {
	String resourceLocation = selector;
	if (resourceLocation == null) {
		resourceLocation = DEFAULT_RESOURCE_LOCATION;
	}

	// For backwards compatibility, we prepend "classpath*:" to the selector name if there
	// is no other prefix (i.e. "classpath*:", "classpath:", or some URL prefix).
	if (!ResourcePatternUtils.isUrl(resourceLocation)) {
		resourceLocation = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resourceLocation;
	}

	synchronized (instances) {
		if (logger.isTraceEnabled()) {
			logger.trace("ContextSingletonBeanFactoryLocator.getInstance(): instances.hashCode=" +
					instances.hashCode() + ", instances=" + instances);
		}
		BeanFactoryLocator bfl = instances.get(resourceLocation);
		if (bfl == null) {
			bfl = new ContextSingletonBeanFactoryLocator(resourceLocation);
			instances.put(resourceLocation, bfl);
		}
		return bfl;
	}
}
 
开发者ID:txazo,项目名称:spring,代码行数:41,代码来源:ContextSingletonBeanFactoryLocator.java

示例6: getInstance

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Returns an instance which uses the specified selector, as the name of the
 * definition file(s). In the case of a name with a Spring 'classpath*:' prefix,
 * or with no prefix, which is treated the same, the current thread context
 * ClassLoader's {@code getResources} method will be called with this value
 * to get all resources having that name. These resources will then be combined to
 * form a definition. In the case where the name uses a Spring 'classpath:' prefix,
 * or a standard URL prefix, then only one resource file will be loaded as the
 * definition.
 * @param selector the name of the resource(s) which will be read and
 * combined to form the definition for the BeanFactoryLocator instance.
 * Any such files must form a valid BeanFactory definition.
 * @return the corresponding BeanFactoryLocator instance
 * @throws BeansException in case of factory loading failure
 */
public static BeanFactoryLocator getInstance(String selector) throws BeansException {
	String resourceLocation = selector;
	if (resourceLocation == null) {
		resourceLocation = DEFAULT_RESOURCE_LOCATION;
	}

	// For backwards compatibility, we prepend 'classpath*:' to the selector name if there
	// is no other prefix (i.e. classpath*:, classpath:, or some URL prefix.
	if (!ResourcePatternUtils.isUrl(resourceLocation)) {
		resourceLocation = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + resourceLocation;
	}

	synchronized (instances) {
		if (logger.isTraceEnabled()) {
			logger.trace("SingletonBeanFactoryLocator.getInstance(): instances.hashCode=" +
					instances.hashCode() + ", instances=" + instances);
		}
		BeanFactoryLocator bfl = instances.get(resourceLocation);
		if (bfl == null) {
			bfl = new SingletonBeanFactoryLocator(resourceLocation);
			instances.put(resourceLocation, bfl);
		}
		return bfl;
	}
}
 
开发者ID:txazo,项目名称:spring,代码行数:41,代码来源:SingletonBeanFactoryLocator.java

示例7: sqlSessionFactory

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory() {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource());

    try {
        Properties properties = new Properties();
        properties.put("prefix", env.getProperty("datasource.prefix", ""));
        sqlSessionFactoryBean.setConfigurationProperties(properties);
        sqlSessionFactoryBean
                .setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/admin-mybatis-mappings/*.xml"));
        sqlSessionFactoryBean.afterPropertiesSet();
        return sqlSessionFactoryBean.getObject();
    } catch (Exception e) {
        throw new RuntimeException("Could not create sqlSessionFactory", e);
    }

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:19,代码来源:DatabaseConfiguration.java

示例8: DatabaseScriptContainer

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
public DatabaseScriptContainer(String scriptLocation, IDatabasePlatform platform) {
    try {
        this.scriptLocation = scriptLocation;
        this.platform = platform;
        this.jdbcTemplate = new JdbcTemplate(platform.getDataSource());

        replacementTokens = new HashMap<String, String>();
        // Add any replacement tokens

        Resource[] resources = ResourcePatternUtils.getResourcePatternResolver(new DefaultResourceLoader())
                .getResources(String.format("classpath*:%s/*.sql", scriptLocation));
        for (Resource r : resources) {
            DatabaseScript script = new DatabaseScript(r.getFilename());
            script.setResource(r);

            if (script.getWhen() == DatabaseScript.WHEN_PREINSTALL) {
                preInstallScripts.add(script);
            } else if (script.getWhen() == DatabaseScript.WHEN_POSTINSTALL) {
                postInstallScripts.add(script);
            }
        }
    } catch (IOException e) {
        throw new IoException(e);
    }
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:26,代码来源:DatabaseScriptContainer.java

示例9: executeImports

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
protected void executeImports(Resource resource) throws IOException {
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
        String line = reader.readLine();
        while (line != null) {
            if (line.startsWith(IMPORT_PREFIX)) {
                String file = line.substring(IMPORT_PREFIX.length()).trim();
                Resource[] resources = ResourcePatternUtils.getResourcePatternResolver(new DefaultResourceLoader())
                        .getResources(String.format("classpath*:%s/%s", scriptLocation, file));
                for (Resource resource2 : resources) {
                    execute(resource2.getURL());
                }
            }
            line = reader.readLine();
        }
    } finally {
        IOUtils.closeQuietly(reader);
    }
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:21,代码来源:DatabaseScriptContainer.java

示例10: importBeans

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Import Spring bean definitions from either XML or Groovy sources into the
 * current bean builder instance.
 * @param resourcePattern the resource pattern
 */
public void importBeans(String resourcePattern) throws IOException {
	Resource[] resources =
			ResourcePatternUtils.getResourcePatternResolver(getResourceLoader()).getResources(resourcePattern);
	for (Resource resource : resources) {
		String filename = resource.getFilename();
		if (filename.endsWith(".groovy")) {
			loadBeanDefinitions(resource);
		}
		else if (filename.endsWith(".xml")) {
			this.xmlBeanDefinitionReader.loadBeanDefinitions(resource);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:GroovyBeanDefinitionReader.java

示例11: LocalSessionFactoryBuilder

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Create a new LocalSessionFactoryBuilder for the given DataSource.
 * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be using
 * (may be {@code null})
 * @param resourceLoader the ResourceLoader to load application classes from
 */
@SuppressWarnings("deprecation")  // to be able to build against Hibernate 4.3
public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) {
	getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
	if (dataSource != null) {
		getProperties().put(Environment.DATASOURCE, dataSource);
	}
	// APP_CLASSLOADER is deprecated as of Hibernate 4.3 but we need to remain compatible with 4.0+
	getProperties().put(AvailableSettings.APP_CLASSLOADER, resourceLoader.getClassLoader());
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:LocalSessionFactoryBuilder.java

示例12: LocalSessionFactoryBuilder

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
/**
 * Create a new LocalSessionFactoryBuilder for the given DataSource.
 * @param dataSource the JDBC DataSource that the resulting Hibernate SessionFactory should be using
 * (may be {@code null})
 * @param resourceLoader the ResourceLoader to load application classes from
 */
public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) {
	getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, SpringSessionContext.class.getName());
	if (dataSource != null) {
		getProperties().put(Environment.DATASOURCE, dataSource);
	}
	getProperties().put(AvailableSettings.CLASSLOADERS, Collections.singleton(resourceLoader.getClassLoader()));
	this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:LocalSessionFactoryBuilder.java

示例13: getResourcesWithContent

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
private Resource[] getResourcesWithContent() throws IOException {
	Resource[] candidates = ResourcePatternUtils
			.getResourcePatternResolver(new DefaultResourceLoader())
			.getResources("file:target/output/**");
	for (Resource candidate : candidates) {
		if (candidate.contentLength() == 0) {
			return new Resource[0];
		}
	}
	return candidates;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:SampleIntegrationApplicationTests.java

示例14: sqlSessionFactory

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
@Bean
public SqlSessionFactory sqlSessionFactory() {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    DataSource dataSource = dataSource();
    sqlSessionFactoryBean.setDataSource(dataSource);
    String databaseType = initDatabaseType(dataSource);
    if (databaseType == null) {
        throw new FlowableException("couldn't deduct database type");
    }

    try {
        Properties properties = new Properties();
        properties.put("prefix", env.getProperty("datasource.prefix", ""));
        properties.put("blobType", "BLOB");
        properties.put("boolValue", "TRUE");

        properties.load(this.getClass().getClassLoader().getResourceAsStream("org/flowable/db/properties/" + databaseType + ".properties"));

        sqlSessionFactoryBean.setConfigurationProperties(properties);
        sqlSessionFactoryBean
                .setMapperLocations(ResourcePatternUtils.getResourcePatternResolver(resourceLoader).getResources("classpath:/META-INF/modeler-mybatis-mappings/*.xml"));
        sqlSessionFactoryBean.afterPropertiesSet();
        return sqlSessionFactoryBean.getObject();
    } catch (Exception e) {
        throw new FlowableException("Could not create sqlSessionFactory", e);
    }

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:29,代码来源:DatabaseConfiguration.java

示例15: setApplicationContext

import org.springframework.core.io.support.ResourcePatternUtils; //导入依赖的package包/类
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(applicationContext);
    String dsName = ConnectionSource.DEFAULT.equals(dataSourceName) ? "dataSource" : "dataSource_" + dataSourceName;
    Properties properties = getProperties();

    if(applicationContext.containsBean(dsName)) {
        properties.put(Environment.DATASOURCE, applicationContext.getBean(dsName));
    }
    properties.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, currentSessionContext.getName());
    properties.put(AvailableSettings.CLASSLOADERS, applicationContext.getClassLoader());
}
 
开发者ID:grails,项目名称:gorm-hibernate5,代码行数:13,代码来源:HibernateMappingContextConfiguration.java


注:本文中的org.springframework.core.io.support.ResourcePatternUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。