本文整理了Java中org.springframework.context.ApplicationContext.getResources()
方法的一些代码示例,展示了ApplicationContext.getResources()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.getResources()
方法的具体详情如下:
包路径:org.springframework.context.ApplicationContext
类名称:ApplicationContext
方法名:getResources
暂无
代码示例来源:origin: Red5/red5-server
/**
* Return array or resource that match given pattern
*
* @param pattern
* Pattern to check against
* @return Array of Resource objects
* @throws IOException
* On I/O exception
*
* @see org.springframework.core.io.Resource
*/
public Resource[] getResources(String pattern) throws IOException {
return applicationContext.getResources(contextPath + pattern);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a parent ClassLoader for Groovy to use as parent ClassLoader
* when loading and compiling templates.
*/
protected ClassLoader createTemplateClassLoader() throws IOException {
String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath());
List<URL> urls = new ArrayList<>();
for (String path : paths) {
Resource[] resources = getApplicationContext().getResources(path);
if (resources.length > 0) {
for (Resource resource : resources) {
if (resource.exists()) {
urls.add(resource.getURL());
}
}
}
}
ClassLoader classLoader = getApplicationContext().getClassLoader();
Assert.state(classLoader != null, "No ClassLoader");
return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[0]), classLoader) : classLoader);
}
代码示例来源:origin: org.springframework/spring-webmvc
/**
* Create a parent ClassLoader for Groovy to use as parent ClassLoader
* when loading and compiling templates.
*/
protected ClassLoader createTemplateClassLoader() throws IOException {
String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath());
List<URL> urls = new ArrayList<>();
for (String path : paths) {
Resource[] resources = getApplicationContext().getResources(path);
if (resources.length > 0) {
for (Resource resource : resources) {
if (resource.exists()) {
urls.add(resource.getURL());
}
}
}
}
ClassLoader classLoader = getApplicationContext().getClassLoader();
Assert.state(classLoader != null, "No ClassLoader");
return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[0]), classLoader) : classLoader);
}
代码示例来源:origin: 527515025/springBoot
@Bean(name = "sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(ApplicationContext applicationContext) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
// sessionFactory.setPlugins(new Interceptor[]{new PageInterceptor()});
sessionFactory.setMapperLocations(applicationContext.getResources("classpath*:mapper/*.xml"));
return sessionFactory;
}
代码示例来源:origin: spring-projects/spring-security
ldifs = ctxt.getResources(ldifResources);
代码示例来源:origin: spring-projects/spring-batch
private void register(String[] paths) throws DuplicateJobException, IOException {
maybeCreateJobLoader();
for (int i = 0; i < paths.length; i++) {
Resource[] resources = parentContext.getResources(paths[i]);
for (int j = 0; j < resources.length; j++) {
Resource path = resources[j];
logger.info("Registering Job definitions from " + Arrays.toString(resources));
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(path);
factory.setApplicationContext(parentContext);
jobLoader.load(factory);
}
}
}
代码示例来源:origin: 527515025/springBoot
@Bean(name = "sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(
ApplicationContext applicationContext) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
configuration.setMapUnderscoreToCamelCase(true);
configuration.setJdbcTypeForNull(JdbcType.NULL);
sessionFactory.setMapperLocations(applicationContext.getResources("classpath:mapper/*.xml"));
return sessionFactory;
}
代码示例来源:origin: 527515025/springBoot
@Bean(name = "sqlSessionFactory")
public SqlSessionFactoryBean sqlSessionFactory(
ApplicationContext applicationContext) throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration();
configuration.setMapUnderscoreToCamelCase(true);
configuration.setJdbcTypeForNull(JdbcType.NULL);
configuration.setLogImpl(org.apache.ibatis.logging.log4j.Log4jImpl.class);//use log4j log
sessionFactory.setConfiguration(configuration);
sessionFactory.setMapperLocations(applicationContext.getResources("classpath:com/yy/example/mapper/*.xml"));
//
// Properties prop = new Properties();
// prop.setProperty("supportMethodsArguments","true");
// prop.setProperty("rowBoundsWithCount", "true");
// prop.setProperty("params","pageNum=pageNum;pageSize=pageSize;");
// PageInterceptor pi = new PageInterceptor();
// pi.setProperties(prop);
// sessionFactory.setPlugins(new Interceptor[]{pi});
return sessionFactory;
}
代码示例来源:origin: hengyunabc/xdiamond
for (String location : locations) {
try {
Resource[] resources = context.getResources(location);
if (resources != null) {
for (Resource resource : resources) {
代码示例来源:origin: briandilley/jsonrpc4j
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
SimpleMetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(applicationContext);
DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
String resolvedPath = resolvePackageToScan();
logger.debug("Scanning '{}' for JSON-RPC service interfaces.", resolvedPath);
try {
for (Resource resource : applicationContext.getResources(resolvedPath)) {
if (resource.isReadable()) {
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
ClassMetadata classMetadata = metadataReader.getClassMetadata();
AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
String jsonRpcPathAnnotation = JsonRpcService.class.getName();
if (annotationMetadata.isAnnotated(jsonRpcPathAnnotation)) {
String className = classMetadata.getClassName();
String path = (String) annotationMetadata.getAnnotationAttributes(jsonRpcPathAnnotation).get("value");
logger.debug("Found JSON-RPC service to proxy [{}] on path '{}'.", className, path);
registerJsonProxyBean(defaultListableBeanFactory, className, path);
}
}
}
} catch (IOException e) {
throw new IllegalStateException(format("Cannot scan package '%s' for classes.", resolvedPath), e);
}
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-common
/**
* @param arg0
* @return
* @throws IOException
* @see org.springframework.core.io.support.ResourcePatternResolver#getResources(java.lang.String)
*/
public Resource[] getResources(String arg0) throws IOException {
return target.getResources(arg0);
}
代码示例来源:origin: net.sf.taverna.t2.infrastructure/platform-spring
/**
* Delegates to internal ApplicationContext supplied by constructor
*/
public final Resource[] getResources(String arg0) throws IOException {
return context.getResources(arg0);
}
代码示例来源:origin: stackoverflow.com
@Autowired
private ApplicationContext applicationContext;
private Resource[] resources ;
public loadResources() {
try {
resources = applicationContext.getResources("file:C:/XYZ/*_vru_*");
} catch (IOException ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: rancher/cattle
@Override
public URL[] getObject() throws Exception {
List<URL> resources = new ArrayList<URL>();
for (String location : locations) {
for (Resource resource : applicationContext.getResources(location)) {
resources.add(resource.getURL());
}
}
return resources.toArray(new URL[resources.size()]);
}
代码示例来源:origin: com.graphql-java/graphql-spring-boot-autoconfigure
@Override
public List<String> schemaStrings() throws IOException {
Resource[] resources = applicationContext.getResources("classpath*:" + schemaLocationPattern);
if (resources.length <= 0) {
throw new IllegalStateException(
"No graphql schema files found on classpath with location pattern '"
+ schemaLocationPattern
+ "'. Please add a graphql schema to the classpath or add a SchemaParser bean to your application context.");
}
return Arrays.stream(resources)
.map(this::readSchema)
.collect(Collectors.toList());
}
代码示例来源:origin: apache/archiva
@Override
public Resource[] getResources( String s )
throws IOException
{
return applicationContext.getResources( s );
}
代码示例来源:origin: pl.edu.icm.synat/synat-platform-container
public void findBundles() throws IOException {
Resource[] resources = applicationContext.getResources("classpath*:"+BUNDLE_CONF_FILE);
logger.debug("Found {} boundle definition", resources.length);
for (Resource resource : resources) {
parseBundleXml(resource.getInputStream());
}
}
代码示例来源:origin: cloudfoundry/java-buildpack-auto-reconfiguration
private static boolean isUsingCloudServices(ApplicationContext applicationContext) {
try {
return Arrays.stream(applicationContext.getResources("classpath*:/META-INF/cloud/cloud-services"))
.flatMap(ApplicationContextCloudServicesHolder::getCloudServiceClasses)
.filter(ApplicationContextCloudServicesHolder::isClassPresent)
.anyMatch(klass -> hasBeansOfType(applicationContext, klass));
} catch (IOException e) {
LOGGER.warning("Unable to read cloud service classes");
return false;
}
}
代码示例来源:origin: org.carewebframework/org.carewebframework.web.sandbox
private void findResources(ApplicationContext applicationContext, String pattern) {
try {
for (Resource resource : applicationContext.getResources(pattern)) {
model.add(resource);
}
} catch (Exception e) {
throw MiscUtil.toUnchecked(e);
}
}
代码示例来源:origin: org.springframework.batch/spring-batch-core
private void register(String[] paths) throws DuplicateJobException, IOException {
maybeCreateJobLoader();
for (int i = 0; i < paths.length; i++) {
Resource[] resources = parentContext.getResources(paths[i]);
for (int j = 0; j < resources.length; j++) {
Resource path = resources[j];
logger.info("Registering Job definitions from " + Arrays.toString(resources));
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(path);
factory.setApplicationContext(parentContext);
jobLoader.load(factory);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!