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


Java ResourceLoader类代码示例

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


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

示例1: isTemplateAvailable

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Override
public boolean isTemplateAvailable(String view, Environment environment,
                                   ClassLoader classLoader, ResourceLoader resourceLoader) {
    if (ClassUtils.isPresent("org.apache.velocity.app.VelocityEngine", classLoader)) {
        PropertyResolver resolver = new RelaxedPropertyResolver(environment,
                "spring.velocity.");
        String loaderPath = resolver.getProperty("resource-loader-path",
                VelocityProperties.DEFAULT_RESOURCE_LOADER_PATH);
        String prefix = resolver.getProperty("prefix",
                VelocityProperties.DEFAULT_PREFIX);
        String suffix = resolver.getProperty("suffix",
                VelocityProperties.DEFAULT_SUFFIX);
        return resourceLoader.getResource(loaderPath + prefix + view + suffix)
                             .exists();
    }
    return false;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:18,代码来源:VelocityTemplateAvailabilityProvider.java

示例2: newCredentialSelectionPredicate

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
/**
 * Gets credential selection predicate.
 *
 * @param selectionCriteria the selection criteria
 * @return the credential selection predicate
 */
public static Predicate<org.apereo.cas.authentication.Credential> newCredentialSelectionPredicate(final String selectionCriteria) {
    try {
        if (StringUtils.isBlank(selectionCriteria)) {
            return credential -> true;
        }

        if (selectionCriteria.endsWith(".groovy")) {
            final ResourceLoader loader = new DefaultResourceLoader();
            final Resource resource = loader.getResource(selectionCriteria);
            if (resource != null) {
                final String script = IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8);
                final GroovyClassLoader classLoader = new GroovyClassLoader(Beans.class.getClassLoader(),
                        new CompilerConfiguration(), true);
                final Class<Predicate> clz = classLoader.parseClass(script);
                return clz.newInstance();
            }
        }

        final Class predicateClazz = ClassUtils.getClass(selectionCriteria);
        return (Predicate<org.apereo.cas.authentication.Credential>) predicateClazz.newInstance();
    } catch (final Exception e) {
        final Predicate<String> predicate = Pattern.compile(selectionCriteria).asPredicate();
        return credential -> predicate.test(credential.getId());
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:32,代码来源:Beans.java

示例3: setUp

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Before
public void setUp() {
    applicationContext = new XmlWebApplicationContext();
    applicationContext.setConfigLocations(
            "classpath:/webappContext.xml",
            "file:src/main/webapp/WEB-INF/cas-servlet.xml",
            "file:src/main/webapp/WEB-INF/deployerConfigContext.xml",
    "file:src/main/webapp/WEB-INF/spring-configuration/*.xml");
    applicationContext.setServletContext(new MockServletContext(new ResourceLoader() {
        @Override
        public Resource getResource(final String location) {
            return new FileSystemResource("src/main/webapp" + location);
        }

        @Override
        public ClassLoader getClassLoader() {
            return getClassLoader();
        }
    }));
    applicationContext.refresh();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:WiringTests.java

示例4: setUp

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Before
public void setUp() {
    applicationContext = new XmlWebApplicationContext();
    applicationContext.setConfigLocations(
            "classpath:/cas-management-servlet.xml",
            "classpath:/managementConfigContext.xml",
            "classpath:/spring-configuration/*.xml");
    applicationContext.setServletContext(new MockServletContext(new ResourceLoader() {
        @Override
        public Resource getResource(final String location) {
            return new FileSystemResource("src/main/webapp" + location);
        }

        @Override
        public ClassLoader getClassLoader() {
            return WiringTests.class.getClassLoader();
        }
    }));
    applicationContext.refresh();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:WiringTests.java

示例5: verifyGetServiceWithTheme

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Test
public void verifyGetServiceWithTheme() throws Exception {
    final MockRequestContext requestContext = new MockRequestContext();
    RequestContextHolder.setRequestContext(requestContext);

    final WebApplicationService webApplicationService = new WebApplicationServiceFactory().createService("myServiceId");
    requestContext.getFlowScope().put("service", webApplicationService);

    final ResourceLoader loader = mock(ResourceLoader.class);
    final Resource resource = mock(Resource.class);
    when(resource.exists()).thenReturn(true);
    when(loader.getResource(anyString())).thenReturn(resource);

    this.registeredServiceThemeBasedViewResolver.setResourceLoader(loader);

    assertEquals("/WEB-INF/view/jsp/myTheme/ui/casLoginView",
            this.registeredServiceThemeBasedViewResolver.buildView("casLoginView").getUrl());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:19,代码来源:RegisteredServiceThemeBasedViewResolverTests.java

示例6: setUp

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Before
public void setUp() {
    applicationContext = new XmlWebApplicationContext();
    applicationContext.setConfigLocations(
            "file:src/main/webapp/WEB-INF/cas-servlet.xml",
            "file:src/main/webapp/WEB-INF/deployerConfigContext.xml",
    "file:src/main/webapp/WEB-INF/spring-configuration/*.xml");
    applicationContext.setServletContext(new MockServletContext(new ResourceLoader() {
        @Override
        public Resource getResource(final String location) {
            return new FileSystemResource("src/main/webapp" + location);
        }

        @Override
        public ClassLoader getClassLoader() {
            return getClassLoader();
        }
    }));
    applicationContext.refresh();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:WiringTests.java

示例7: KeywhizKeyStore

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
/**
 * Create a keywhiz key store to communicate with Keywhiz server.
 *
 * @param name             Keystore name
 * @param trustStoreConfig {@link OneOpsConfig.TrustStore} trust-store properties
 * @param keystoreConfig   {@link OneOpsConfig.Keystore} keystore properties
 * @param loader           {@link ResourceLoader} for loading resources from classpath for file system.
 */
public KeywhizKeyStore(Name name,
                       OneOpsConfig.TrustStore trustStoreConfig,
                       OneOpsConfig.Keystore keystoreConfig,
                       ResourceLoader loader) {
    this.name = name;
    this.loader = loader;
    if (trustStoreConfig != null) {
        trustStore = keyStoreFromResource(trustStoreConfig);
    } else {
        trustStore = null;
    }
    if (keystoreConfig != null) {
        keyStore = keyStoreFromResource(keystoreConfig);
        keyPassword = keystoreConfig.getKeyPassword();
    } else {
        keyStore = null;
        keyPassword = null;
    }
}
 
开发者ID:oneops,项目名称:secrets-proxy,代码行数:28,代码来源:KeywhizKeyStore.java

示例8: importStream

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
public InputStream importStream(String content)
{
    ResourceLoader loader = new DefaultResourceLoader();
    Resource resource = loader.getResource(content);
    if (resource.exists() == false)
    {
        throw new ImporterException("Content URL " + content + " does not exist.");
    }
    
    try
    {
        return resource.getInputStream();
    }
    catch(IOException e)
    {
        throw new ImporterException("Failed to retrieve input stream for content URL " + content);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:ImporterComponent.java

示例9: setUp

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Before
public void setUp() {
    applicationContext = new XmlWebApplicationContext();
    applicationContext.setConfigLocations(new String[]{
            "file:src/main/webapp/WEB-INF/cas-servlet.xml",
            "file:src/main/webapp/WEB-INF/deployerConfigContext.xml",
    "file:src/main/webapp/WEB-INF/spring-configuration/*.xml"});
    applicationContext.setServletContext(new MockServletContext(new ResourceLoader() {
        @Override
        public Resource getResource(final String location) {
            return new FileSystemResource("src/main/webapp" + location);
        }

        @Override
        public ClassLoader getClassLoader() {
            return getClassLoader();
        }
    }));
    applicationContext.refresh();
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:WiringTests.java

示例10: setUp

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Before
public void setUp() {
    applicationContext = new XmlWebApplicationContext();
    applicationContext.setConfigLocations(new String[]{
            "file:src/main/webapp/WEB-INF/cas-management-servlet.xml",
            "file:src/main/webapp/WEB-INF/managementConfigContext.xml",
    "file:src/main/webapp/WEB-INF/spring-configuration/*.xml"});
    applicationContext.setServletContext(new MockServletContext(new ResourceLoader() {
        @Override
        public Resource getResource(final String location) {
            return new FileSystemResource("src/main/webapp" + location);
        }

        @Override
        public ClassLoader getClassLoader() {
            return getClassLoader();
        }
    }));
    applicationContext.refresh();
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:21,代码来源:WiringTests.java

示例11: deploySingleProcess

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
/**
 * 部署单个流程定义
 *
 * @param resourceLoader {@link ResourceLoader}
 * @param processKey     模块名称
 * @throws IOException 找不到zip文件时
 */
private void deploySingleProcess(ResourceLoader resourceLoader, String processKey, String exportDir) throws IOException {
    String classpathResourceUrl = "classpath:/deployments/" + processKey + ".bar";
    logger.debug("read workflow from: {}", classpathResourceUrl);
    Resource resource = resourceLoader.getResource(classpathResourceUrl);
    InputStream inputStream = resource.getInputStream();
    if (inputStream == null) {
        logger.warn("ignore deploy workflow module: {}", classpathResourceUrl);
    } else {
        logger.debug("finded workflow module: {}, deploy it!", classpathResourceUrl);
        ZipInputStream zis = new ZipInputStream(inputStream);
        Deployment deployment = repositoryService.createDeployment().addZipInputStream(zis).deploy();

        // export diagram
        List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
        for (ProcessDefinition processDefinition : list) {
            WorkflowUtils.exportDiagramToFile(repositoryService, processDefinition, exportDir);
        }
    }
}
 
开发者ID:batizhao,项目名称:microservice,代码行数:27,代码来源:WorkflowProcessDefinitionService.java

示例12: AppRegistry

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
public AppRegistry(UriRegistry uriRegistry, ResourceLoader resourceLoader, EavRegistryRepository eavRegistryRepository) {
	this.uriRegistry = uriRegistry;
	this.uriRegistryPopulator = new UriRegistryPopulator();
	this.uriRegistryPopulator.setResourceLoader(resourceLoader);
	this.resourceLoader = resourceLoader;
	this.eavRegistryRepository = eavRegistryRepository;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:8,代码来源:AppRegistry.java

示例13: delegatingResourceLoader

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
@Bean
public DelegatingResourceLoader delegatingResourceLoader(MavenConfigurationProperties mavenProperties) {
	DockerResourceLoader dockerLoader = new DockerResourceLoader();
	MavenResourceLoader mavenResourceLoader = new MavenResourceLoader(mavenProperties);
	Map<String, ResourceLoader> loaders = new HashMap<>();
	loaders.put("docker", dockerLoader);
	loaders.put("maven", mavenResourceLoader);
	return new DelegatingResourceLoader(loaders);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:10,代码来源:SkipperServerConfiguration.java

示例14: ImageService

import org.springframework.core.io.ResourceLoader; //导入依赖的package包/类
public ImageService(ResourceLoader resourceLoader,
					ImageRepository imageRepository,
					MeterRegistry meterRegistry) {

	this.resourceLoader = resourceLoader;
	this.imageRepository = imageRepository;
	this.meterRegistry = meterRegistry;
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:9,代码来源:ImageService.java

示例15: LocalSessionFactoryBuilder

import org.springframework.core.io.ResourceLoader; //导入依赖的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


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