Java 类org.springframework.core.io.ResourceLoader 实例源码

项目:ARCLib    文件:VelocityTemplateAvailabilityProvider.java   
@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;
}
项目:cas-5.1.0    文件:Beans.java   
/**
 * 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());
    }
}
项目:springboot-shiro-cas-mybatis    文件:WiringTests.java   
@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();
}
项目:springboot-shiro-cas-mybatis    文件:WiringTests.java   
@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();
}
项目:springboot-shiro-cas-mybatis    文件:RegisteredServiceThemeBasedViewResolverTests.java   
@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());
}
项目:springboot-shiro-cas-mybatis    文件:WiringTests.java   
@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();
}
项目:secrets-proxy    文件:KeywhizKeyStore.java   
/**
 * 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;
    }
}
项目:alfresco-repository    文件:ImporterComponent.java   
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);
    }
}
项目:cas4.0.x-server-wechat    文件:WiringTests.java   
@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();
}
项目:cas4.0.x-server-wechat    文件:WiringTests.java   
@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();
}
项目:microservice    文件:WorkflowProcessDefinitionService.java   
/**
 * 部署单个流程定义
 *
 * @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);
        }
    }
}
项目:cas-server-4.2.1    文件:WiringTests.java   
@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();
}
项目:spring-cloud-dashboard    文件:AppRegistry.java   
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;
}
项目:spring-cloud-skipper    文件:SkipperServerConfiguration.java   
@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);
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:lams    文件:LocalSessionFactoryBuilder.java   
/**
 * 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);
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:ImageService.java   
public ImageService(ResourceLoader resourceLoader,
                    ImageRepository imageRepository,
                    MeterRegistry meterRegistry) {

    this.resourceLoader = resourceLoader;
    this.imageRepository = imageRepository;
    this.meterRegistry = meterRegistry;
}
项目:cas-5.1.0    文件:SamlUtils.java   
/**
 * Build signature validation filter if needed.
 *
 * @param resourceLoader            the resource loader
 * @param signatureResourceLocation the signature resource location
 * @return the metadata filter
 * @throws Exception the exception
 */
public static SignatureValidationFilter buildSignatureValidationFilter(final ResourceLoader resourceLoader,
                                                                       final String signatureResourceLocation) throws Exception {
    try {
        final Resource resource = resourceLoader.getResource(signatureResourceLocation);
        return buildSignatureValidationFilter(resource);
    } catch (final Exception e){
        LOGGER.debug(e.getMessage(), e);
    }
    return null;
}
项目:simple-openid-provider    文件:OAuth2Configuration.java   
public OAuth2Configuration(ResourceLoader resourceLoader, OpenIdProviderProperties properties,
        ObjectProvider<JdbcOperations> jdbcOperations, ObjectProvider<AuthenticationManager> authenticationManager,
        ObjectProvider<HazelcastInstance> hazelcastInstance) {
    this.resourceLoader = resourceLoader;
    this.properties = properties;
    this.jdbcOperations = jdbcOperations.getObject();
    this.authenticationManager = authenticationManager.getObject();
    this.hazelcastInstance = hazelcastInstance.getObject();
}
项目:xm-commons    文件:XmLepResourceService.java   
public XmLepResourceService(String appName,
                            TenantScriptStorage tenantScriptStorage,
                            ResourceLoader routerResourceLoader) {
    this.appName = Objects.requireNonNull(appName, "appName can't be null");
    this.tenantScriptStorage = Objects.requireNonNull(tenantScriptStorage,
                                                      "tenantScriptStorage can't be null");
    this.routerResourceLoader = routerResourceLoader;
}
项目:xm-commons    文件:RouterResourceLoader.java   
@Override
public Resource getResource(String location) {
    String urlPrefix = getUrlPrefix(location);
    if (urlPrefix == null) {
        throw new IllegalStateException("Can't detect URL prefix for location: " + location);
    }

    ResourceLoader resourceLoader = urlPrefixToResourceLoader.get(urlPrefix);
    if (resourceLoader == null) {
        throw new IllegalStateException("Unsupported resource URL prefix: " + urlPrefix);
    }

    return resourceLoader.getResource(location);
}
项目:spring-cloud-dashboard    文件:AppRegistration.java   
/**
 * Construct an {@code AppRegistration} object.
 *
 * @param name app name
 * @param type app type
 * @param uri URI for the app resource
 * @param loader the {@link ResourceLoader} that loads the {@link Resource} for this app
 */
public AppRegistration(String name, String type, URI uri, ResourceLoader loader) {
    Assert.hasText(name, "name is required");
    Assert.notNull(type, "type is required");
    Assert.notNull(uri, "uri is required");
    Assert.notNull(loader, "ResourceLoader must not be null");
    this.name = name;
    this.type = type;
    this.uri = uri;
    this.loader = loader;
}
项目:xm-commons    文件:XmLepResourceServiceFileUnitTest.java   
@Before
public void before() throws IOException {
    oldUserHome = System.getProperty(USER_HOME);

    // init temp folder
    testScriptDir = folder.newFolder("home", "xm-online", "config", "tenants",
                                     TENANT_KEY_VALUE.toUpperCase(), APP_NAME,
                                     "lep", "resource", "service");


    // init system property
    File userHomeDir = Paths.get(folder.getRoot().toPath().toString(), "home").toFile();
    System.setProperty(USER_HOME, userHomeDir.getAbsolutePath());

    // copy script from classpath to file system tmp folder
    File scriptFile = Paths.get(testScriptDir.getAbsolutePath(), "Script$$before.groovy").toFile();
    if (!scriptFile.createNewFile()) {
        throw new IllegalStateException("Can't create file: " + scriptFile.getAbsolutePath());
    }
    InputStream scriptIn = resourceLoader.getResource(SCRIPT_CLASSPATH_URL).getInputStream();
    Files.copy(scriptIn, scriptFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    scriptIn.close();

    // init resource service
    Map<String, ResourceLoader> urlPrefixToResourceLoader = new HashMap<>();
    urlPrefixToResourceLoader.put("file:", new FileSystemResourceLoader());
    RouterResourceLoader routerResourceLoader = new RouterResourceLoader(urlPrefixToResourceLoader);
    resourceService = new XmLepResourceService(APP_NAME, FILE, routerResourceLoader);
}
项目:syndesis    文件:DataManager.java   
@Autowired
public DataManager(CacheManager caches,
                   List<DataAccessObject<?>> dataAccessObjects,
                   EventBus eventBus,
                   EncryptionComponent encryptionComponent,
                   ResourceLoader resourceLoader) {
    this.caches = caches;
    this.eventBus = eventBus;
    this.encryptionComponent = encryptionComponent;
    this.resourceLoader = resourceLoader;
    if (dataAccessObjects != null) {
        this.dataAccessObjects.addAll(dataAccessObjects);
    }
}
项目:syndesis    文件:DataManagerTest.java   
@Before
public void setup() {
    cacheManager = new LRUCacheManager(100);

    EncryptionComponent encryptionComponent = new EncryptionComponent(null);
    ResourceLoader resourceLoader = new DefaultResourceLoader();

    //Create Data Manager
    dataManager = new DataManager(cacheManager, Collections.emptyList(), null, encryptionComponent, resourceLoader);
    dataManager.init();
    dataManager.resetDeploymentData();
}
项目:mylion-mvn    文件:MydogTemplateLoader.java   
public MydogTemplateLoader(ResourceLoader resourceLoader, String templateLoaderPath ) {
    this.resourceLoader = resourceLoader;
    if (!templateLoaderPath.endsWith("/")) {
        templateLoaderPath += "/";
    }
    this.templateLoaderPath = templateLoaderPath;

    this.outputDirectory = new File(XmlConfigLoader.getConfigLoader().getOutputDirectory(), "target/classes/");
}
项目:gemini.blueprint    文件:ClassUtilsTest.java   
public void testInterfacesHierarchy() {
       //Closeable.class,
    Class<?>[] clazz = ClassUtils.getAllInterfaces(DelegatedExecutionOsgiBundleApplicationContext.class);
    Class<?>[] expected =
            { ConfigurableOsgiBundleApplicationContext.class, ConfigurableApplicationContext.class,
                    ApplicationContext.class, Lifecycle.class, Closeable.class, EnvironmentCapable.class, ListableBeanFactory.class,
                    HierarchicalBeanFactory.class, MessageSource.class, ApplicationEventPublisher.class,
                    ResourcePatternResolver.class, BeanFactory.class, ResourceLoader.class, AutoCloseable.class };

    assertTrue(compareArrays(expected, clazz));
}
项目:lams    文件:SpringTemplateLoader.java   
/**
 * Create a new SpringTemplateLoader.
 * @param resourceLoader the Spring ResourceLoader to use
 * @param templateLoaderPath the template loader path to use
 */
public SpringTemplateLoader(ResourceLoader resourceLoader, String templateLoaderPath) {
    this.resourceLoader = resourceLoader;
    if (!templateLoaderPath.endsWith("/")) {
        templateLoaderPath += "/";
    }
    this.templateLoaderPath = templateLoaderPath;
    if (logger.isInfoEnabled()) {
        logger.info("SpringTemplateLoader for FreeMarker: using resource loader [" + this.resourceLoader +
                "] and template loader path [" + this.templateLoaderPath + "]");
    }
}
项目:gemini.blueprint    文件:OsgiBundleResourcePatternResolver.java   
public OsgiBundleResourcePatternResolver(ResourceLoader resourceLoader) {
    super(resourceLoader);
    if (resourceLoader instanceof OsgiBundleResourceLoader) {
        this.bundle = ((OsgiBundleResourceLoader) resourceLoader).getBundle();
    } else {
        this.bundle = null;
    }

    this.bundleContext = (bundle != null ? OsgiUtils.getBundleContext(this.bundle) : null);
    this.resolver = (bundleContext != null ? new PackageAdminResolver(bundleContext) : null);
}
项目:mylion-mvn    文件:MydogTemplateLoader.java   
public MydogTemplateLoader(ResourceLoader resourceLoader, String templateLoaderPath ) {
    this.resourceLoader = resourceLoader;
    if (!templateLoaderPath.endsWith("/")) {
        templateLoaderPath += "/";
    }
    this.templateLoaderPath = templateLoaderPath;

    this.outputDirectory = new File(XmlConfigLoader.getConfigLoader().getOutputDirectory(), "target/classes/");
}
项目:gemini.blueprint    文件:OsgiBundleResource.java   
/**
 * 
 * Constructs a new <code>OsgiBundleResource</code> instance.
 * 
 * @param bundle OSGi bundle used by this resource
 * @param path resource path inside the bundle.
 */
public OsgiBundleResource(Bundle bundle, String path) {
    Assert.notNull(bundle, "Bundle must not be null");
    this.bundle = bundle;

    // check path
    Assert.notNull(path, "Path must not be null");

    this.path = StringUtils.cleanPath(path);

    this.searchType = OsgiResourceUtils.getSearchType(this.path);

    switch (this.searchType) {
        case OsgiResourceUtils.PREFIX_TYPE_NOT_SPECIFIED:
            pathWithoutPrefix = path;
            break;
        case OsgiResourceUtils.PREFIX_TYPE_BUNDLE_SPACE:
            pathWithoutPrefix = path.substring(BUNDLE_URL_PREFIX.length());
            break;
        case OsgiResourceUtils.PREFIX_TYPE_BUNDLE_JAR:
            pathWithoutPrefix = path.substring(BUNDLE_JAR_URL_PREFIX.length());
            break;
        case OsgiResourceUtils.PREFIX_TYPE_CLASS_SPACE:
            pathWithoutPrefix = path.substring(ResourceLoader.CLASSPATH_URL_PREFIX.length());
            break;
        // prefix unknown so the path will be resolved outside the context
        default:
            pathWithoutPrefix = null;
    }
}
项目:gemini.blueprint    文件:OsgiBundleResourcePatternResolverTest.java   
/**
 * Test method for
 * {@link org.springframework.osgi.context.OsgiBundleResourcePatternResolver#OsgiBundleResourcePatternResolver(org.osgi.framework.Bundle)}.
 */
public void testOsgiBundleResourcePatternResolverBundle() {
    ResourceLoader res = resolver.getResourceLoader();
    assertTrue(res instanceof OsgiBundleResourceLoader);
    Resource resource = res.getResource("foo");
    assertSame(bundle, ((OsgiBundleResource) resource).getBundle());
    assertEquals(res.getResource("foo"), resolver.getResource("foo"));
}
项目:gemini.blueprint    文件:OsgiBundleResourcePatternResolverTest.java   
/**
 * Test method for
 * {@link org.springframework.osgi.context.OsgiBundleResourcePatternResolver#OsgiBundleResourcePatternResolver(org.springframework.core.io.ResourceLoader)}.
 */
public void testOsgiBundleResourcePatternResolverResourceLoader() {
    ResourceLoader resLoader = new DefaultResourceLoader();
    resolver = new OsgiBundleResourcePatternResolver(resLoader);
    ResourceLoader res = resolver.getResourceLoader();

    assertSame(resLoader, res);
    assertEquals(resLoader.getResource("foo"), resolver.getResource("foo"));
}
项目:mapper-boot-starter    文件:MapperAutoConfiguration.java   
public MapperAutoConfiguration(MybatisProperties properties,
                               ObjectProvider<Interceptor[]> interceptorsProvider,
                               ResourceLoader resourceLoader,
                               ObjectProvider<DatabaseIdProvider> databaseIdProvider,
                               ObjectProvider<List<ConfigurationCustomizer>> configurationCustomizersProvider) {
    this.properties = properties;
    this.interceptors = interceptorsProvider.getIfAvailable();
    this.resourceLoader = resourceLoader;
    this.databaseIdProvider = databaseIdProvider.getIfAvailable();
    this.configurationCustomizers = configurationCustomizersProvider.getIfAvailable();
}
项目:didi-eureka-server    文件:EurekaServerAutoConfiguration.java   
/**
 * Construct a Jersey {@link javax.ws.rs.core.Application} with all the resources
 * required by the Eureka server.
 */
@Bean
public javax.ws.rs.core.Application jerseyApplication(Environment environment,
        ResourceLoader resourceLoader) {

    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
            false, environment);

    // Filter to include only classes that have a particular annotation.
    //
    provider.addIncludeFilter(new AnnotationTypeFilter(Path.class));
    provider.addIncludeFilter(new AnnotationTypeFilter(Provider.class));

    // Find classes in Eureka packages (or subpackages)
    //
    Set<Class<?>> classes = new HashSet<Class<?>>();
    for (String basePackage : EUREKA_PACKAGES) {
        Set<BeanDefinition> beans = provider.findCandidateComponents(basePackage);
        for (BeanDefinition bd : beans) {
            Class<?> cls = ClassUtils.resolveClassName(bd.getBeanClassName(),
                    resourceLoader.getClassLoader());
            classes.add(cls);
        }
    }

    // Construct the Jersey ResourceConfig
    //
    Map<String, Object> propsAndFeatures = new HashMap<String, Object>();
    propsAndFeatures.put(
            // Skip static content used by the webapp
            ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX,
            EurekaConstants.DEFAULT_PREFIX + "/(fonts|images|css|js)/.*");

    DefaultResourceConfig rc = new DefaultResourceConfig(classes);
    rc.setPropertiesAndFeatures(propsAndFeatures);

    return rc;
}