本文整理汇总了Java中org.springframework.core.io.AbstractResource类的典型用法代码示例。如果您正苦于以下问题:Java AbstractResource类的具体用法?Java AbstractResource怎么用?Java AbstractResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractResource类属于org.springframework.core.io包,在下文中一共展示了AbstractResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveMetadataFromResource
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
/**
* Resolve metadata from resource.
*
* @param service the service
* @param metadataResolvers the metadata resolvers
* @throws Exception the io exception
*/
protected void resolveMetadataFromResource(final SamlRegisteredService service,
final List<MetadataResolver> metadataResolvers) throws Exception {
final String metadataLocation = service.getMetadataLocation();
LOGGER.info("Loading SAML metadata from [{}]", metadataLocation);
final AbstractResource metadataResource = ResourceUtils.getResourceFrom(metadataLocation);
if (metadataResource instanceof FileSystemResource) {
resolveFileSystemBasedMetadataResource(service, metadataResolvers, metadataResource);
}
if (metadataResource instanceof UrlResource) {
resolveUrlBasedMetadataResource(service, metadataResolvers, metadataResource);
}
if (metadataResource instanceof ClassPathResource) {
resolveClasspathBasedMetadataResource(service, metadataResolvers, metadataLocation, metadataResource);
}
}
示例2: resolveUrlBasedMetadataResource
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
private void resolveUrlBasedMetadataResource(final SamlRegisteredService service,
final List<MetadataResolver> metadataResolvers,
final AbstractResource metadataResource) throws Exception {
final SamlIdPProperties.Metadata md = casProperties.getAuthn().getSamlIdp().getMetadata();
final File backupDirectory = new File(md.getLocation().getFile(), "metadata-backups");
final File backupFile = new File(backupDirectory, metadataResource.getFilename());
LOGGER.debug("Metadata backup directory is designated to be [{}]", backupDirectory.getCanonicalPath());
FileUtils.forceMkdir(backupDirectory);
LOGGER.debug("Metadata backup file will be at [{}]", backupFile.getCanonicalPath());
FileUtils.forceMkdirParent(backupFile);
final HttpClientMultithreadedDownloader downloader =
new HttpClientMultithreadedDownloader(metadataResource, backupFile);
final FileBackedHTTPMetadataResolver metadataProvider = new FileBackedHTTPMetadataResolver(
this.httpClient.getWrappedHttpClient(), metadataResource.getURL().toExternalForm(),
backupFile.getCanonicalPath());
buildSingleMetadataResolver(metadataProvider, service);
metadataResolvers.add(metadataProvider);
}
示例3: resolveClasspathBasedMetadataResource
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
private void resolveClasspathBasedMetadataResource(final SamlRegisteredService service,
final List<MetadataResolver> metadataResolvers,
final String metadataLocation,
final AbstractResource metadataResource) {
try (InputStream in = metadataResource.getInputStream()) {
LOGGER.debug("Parsing metadata from [{}]", metadataLocation);
final Document document = this.configBean.getParserPool().parse(in);
final Element metadataRoot = document.getDocumentElement();
final DOMMetadataResolver metadataProvider = new DOMMetadataResolver(metadataRoot);
buildSingleMetadataResolver(metadataProvider, service);
metadataResolvers.add(metadataProvider);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
示例4: testFirstFound
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
@Test
public void testFirstFound() throws Exception {
this.factory.setResolutionMethod(YamlProcessor.ResolutionMethod.FIRST_FOUND);
this.factory.setResources(new AbstractResource() {
@Override
public String getDescription() {
return "non-existent";
}
@Override
public InputStream getInputStream() throws IOException {
throw new IOException("planned");
}
}, new ByteArrayResource("foo:\n spam: bar".getBytes()));
assertEquals(1, this.factory.getObject().size());
}
示例5: AuthenticationManager
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
public AuthenticationManager(AbstractResource properties,
AbstractResource configuration) throws RemoteException {
try {
BeanUtils utils = new BeanUtils(configuration, properties);
this.auth = utils.getAuthenticationProvider();
Set<QName> set = this.auth.getSupportedAuthenticationProfiles();
if ((set == null) || (set.size() < 1)) {
throw new Exception(
"The authentication provider must support at least 1 valid authentication profile.");
} else if (!AuthenticationProfile.isValid(set)) {
throw new Exception(
"The authentication provider supports an unknown authentication profile.");
}
} catch (Exception ex) {
throw new RemoteException(
"Error instantiating AuthenticationProvider: "
+ ex.getMessage(), ex);
}
}
示例6: resolveFileSystemBasedMetadataResource
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
private void resolveFileSystemBasedMetadataResource(final SamlRegisteredService service,
final List<MetadataResolver> metadataResolvers,
final AbstractResource metadataResource) throws Exception {
final File metadataFile = metadataResource.getFile();
final AbstractMetadataResolver metadataResolver;
if (metadataFile.isDirectory()) {
metadataResolver = new LocalDynamicMetadataResolver(new FilesystemLoadSaveManager<>(metadataFile, configBean.getParserPool()));
} else {
metadataResolver = new ResourceBackedMetadataResolver(ResourceHelper.of(metadataResource));
}
buildSingleMetadataResolver(metadataResolver, service);
metadataResolvers.add(metadataResolver);
}
示例7: getResourceFrom
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
/**
* Gets resource from a String location.
*
* @param location the metadata location
* @return the resource from
* @throws IOException the exception
*/
public static AbstractResource getResourceFrom(final String location) throws IOException {
final AbstractResource metadataLocationResource = getRawResourceFrom(location);
if (!metadataLocationResource.exists() || !metadataLocationResource.isReadable()) {
throw new FileNotFoundException("Resource " + location + " does not exist or is unreadable");
}
return metadataLocationResource;
}
示例8: CompensablePropertySource
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
public CompensablePropertySource(String name, EncodedResource source) {
super(name, source);
EncodedResource encoded = (EncodedResource) this.getSource();
AbstractResource resource = (AbstractResource) encoded.getResource();
String path = resource.getFilename();
if (StringUtils.isBlank(path)) {
return;
}
String[] values = path.split(":");
if (values.length != 2) {
return;
}
String protocol = values[0];
String resName = values[1];
if ("bytetcc".equalsIgnoreCase(protocol) == false) {
return;
} else if ("loadbalancer.config".equalsIgnoreCase(resName) == false) {
return;
}
this.enabled = true;
}
示例9: setPropertyMergedProperties
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
/**
* Intelligently sets the property to the merged set of properties.
* <p>
* The key "MANAGER.PROPERTIES" can be used in a properties file to refer to
* the entire set of merged properties. This is normally what you want to pass
* into other systems (such as Spring) that need a set of properties.
*
* @param bean the bean, not null
* @param mp the property, not null
* @throws Exception allowing throwing of a checked exception
*/
protected void setPropertyMergedProperties(Bean bean, MetaProperty<?> mp) throws Exception {
final String desc = MANAGER_PROPERTIES + " for " + mp;
final ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
Properties props = new Properties();
props.putAll(getProperties().toMap());
props.store(out, desc);
out.close();
Resource resource = new AbstractResource() {
@Override
public String getDescription() {
return MANAGER_PROPERTIES;
}
@Override
public String getFilename() throws IllegalStateException {
return MANAGER_PROPERTIES + ".properties";
}
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(out.toByteArray());
}
@Override
public String toString() {
return desc;
}
};
mp.set(bean, resource);
}
示例10: TransactionPropertySource
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
public TransactionPropertySource(String name, EncodedResource source) {
super(name, source);
EncodedResource encoded = (EncodedResource) this.getSource();
AbstractResource resource = (AbstractResource) encoded.getResource();
String path = resource.getFilename();
if (StringUtils.isBlank(path)) {
return;
}
String[] values = path.split(":");
if (values.length != 2) {
return;
}
String protocol = values[0];
String resName = values[1];
if ("bytejta".equalsIgnoreCase(protocol) == false) {
return;
} else if ("loadbalancer.config".equalsIgnoreCase(resName) == false) {
return;
}
this.enabled = true;
}
示例11: addFile
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
private void addFile(int executionId, String uid, AbstractResource resource) {
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
map.add("file", resource);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<LinkedMultiValueMap<String, Object>>(
map, headers);
template.exchange(base.toString() + "executions/" + executionId + "/details/" + uid + "/file/", HttpMethod.POST,
requestEntity, Void.class);
}
示例12: render
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
private String render(AbstractResource resource, Map<String, Object> model, Locale locale, TemplateOutput templateOutput) {
try {
ModelAndView mv = new ModelAndView((String) null, model);
mv.addObject("format-date", MustacheCustomTagInterceptor.FORMAT_DATE);
mv.addObject(MustacheLocalizationMessageInterceptor.DEFAULT_MODEL_KEY, new CustomLocalizationMessageInterceptor(locale, messageSource).createTranslator());
return compile(resource, templateOutput).execute(mv.getModel());
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例13: compile
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
private Template compile(AbstractResource resource, TemplateOutput templateOutput) {
try (InputStreamReader tmpl = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
return compilers.get(templateOutput).compile(tmpl);
} catch (IOException ioe) {
throw new IllegalStateException(ioe);
}
}
示例14: Keystore
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
/**
* Use this if the keystore also contains keys. Left side is the alias, right side is the key password. The key
* password can be the same as that of the keystore itself.
*/
@SafeVarargs
public Keystore(AbstractResource keystore, String keystorePassword, Pair<String, String>... keyAliasPasswords) {
this.keystore = keystore;
this.keystorePassword = keystorePassword;
this.keyAliasPasswords = Arrays.asList(keyAliasPasswords);
}
示例15: BeanUtils
import org.springframework.core.io.AbstractResource; //导入依赖的package包/类
public BeanUtils(AbstractResource conf,
AbstractResource properties) throws Exception {
this.factory = new XmlBeanFactory(conf);
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(properties);
cfg.postProcessBeanFactory(factory);
}