use of org.springframework.core.io.ResourceLoader in project spring-cloud-deployer by spring-cloud.
the class DelegatingResourceLoader method getResource.
@Override
public Resource getResource(String location) {
try {
URI uri = new URI(location);
String scheme = uri.getScheme();
Assert.notNull(scheme, "a scheme (prefix) is required");
ResourceLoader loader = this.loaders.get(scheme);
if (loader == null) {
if (scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("https")) {
loader = new DownloadingUrlResourceLoader();
} else {
loader = this.defaultResourceLoader;
}
}
return loader.getResource(location);
} catch (Exception e) {
throw new ResourceNotResolvedException(e.getMessage(), e);
}
}
use of org.springframework.core.io.ResourceLoader in project java-function-invoker by projectriff.
the class FunctionConfiguration method delegatingResourceLoader.
@Bean
@ConditionalOnMissingBean(DelegatingResourceLoader.class)
public DelegatingResourceLoader delegatingResourceLoader(MavenProperties mavenProperties) {
Map<String, ResourceLoader> loaders = new HashMap<>();
loaders.put(MavenResource.URI_SCHEME, new MavenResourceLoader(mavenProperties));
return new DelegatingResourceLoader(loaders);
}
use of org.springframework.core.io.ResourceLoader in project core by craftercms.
the class FileSystemContentStoreAdapterTest method setUpTestStoreAdapter.
private void setUpTestStoreAdapter() throws IOException {
ResourceLoader resourceLoader = mock(ResourceLoader.class);
when(resourceLoader.getResource(CLASSPATH_STORE_ROOT_FOLDER_PATH)).thenReturn(new ClassPathResource(CLASSPATH_STORE_ROOT_FOLDER_PATH));
storeAdapter = new FileSystemContentStoreAdapter();
storeAdapter.setCacheTemplate(cacheTemplate);
storeAdapter.setResourceLoader(resourceLoader);
storeAdapter.setDescriptorFileExtension(DESCRIPTOR_FILE_EXTENSION);
storeAdapter.setMetadataFileExtension(METADATA_FILE_EXTENSION);
storeAdapter.setPathValidator(new SecurePathValidator("path"));
}
use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.
the class AudioMetadataExtractionHelperTest method testGetDurationInMillisecondsWAV.
@Test
public void testGetDurationInMillisecondsWAV() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(AudioMetadataExtractionHelper.class);
Resource resource = resourceLoader.getResource("fourteen.wav");
File audioFile = resource.getFile();
logger.debug("audioFile: " + audioFile);
Long durationMs = AudioMetadataExtractionHelper.getDurationInMilliseconds(audioFile);
assertThat(durationMs, not(nullValue()));
// 1s
assertThat(durationMs, is(1000L));
}
use of org.springframework.core.io.ResourceLoader in project webapp by elimu-ai.
the class AudioMetadataExtractionHelperTest method testGetDurationInMillisecondsMP3.
@Test
public void testGetDurationInMillisecondsMP3() throws IOException {
ResourceLoader resourceLoader = new ClassRelativeResourceLoader(AudioMetadataExtractionHelper.class);
Resource resource = resourceLoader.getResource("fourteen.mp3");
File audioFile = resource.getFile();
logger.debug("audioFile: " + audioFile);
Long durationMs = AudioMetadataExtractionHelper.getDurationInMilliseconds(audioFile);
assertThat(durationMs, not(nullValue()));
// 1s
assertThat(durationMs, is(1000L));
}
Aggregations