當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractResource類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:27,代碼來源:ChainingMetadataResolverCacheLoader.java

示例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);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:24,代碼來源:ChainingMetadataResolverCacheLoader.java

示例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);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:17,代碼來源:ChainingMetadataResolverCacheLoader.java

示例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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:17,代碼來源:YamlMapFactoryBeanTests.java

示例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);
	}
}
 
開發者ID:NCIP,項目名稱:cagrid-core,代碼行數:20,代碼來源:AuthenticationManager.java

示例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);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:14,代碼來源:ChainingMetadataResolverCacheLoader.java

示例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;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:15,代碼來源:ResourceUtils.java

示例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;

}
 
開發者ID:liuyangming,項目名稱:ByteTCC,代碼行數:28,代碼來源:CompensablePropertySource.java

示例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);
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:39,代碼來源:ComponentManager.java

示例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;

}
 
開發者ID:liuyangming,項目名稱:ByteJTA,代碼行數:28,代碼來源:TransactionPropertySource.java

示例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);
}
 
開發者ID:Top-Q,項目名稱:difido-reports,代碼行數:12,代碼來源:DifidoClient.java

示例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);
    }
}
 
開發者ID:alfio-event,項目名稱:alf.io,代碼行數:11,代碼來源:TemplateManager.java

示例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);
    }
}
 
開發者ID:alfio-event,項目名稱:alf.io,代碼行數:8,代碼來源:TemplateManager.java

示例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);
}
 
開發者ID:koen-serneels,項目名稱:ws-proxy,代碼行數:11,代碼來源:Keystore.java

示例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);
}
 
開發者ID:NCIP,項目名稱:cagrid-core,代碼行數:8,代碼來源:BeanUtils.java


注:本文中的org.springframework.core.io.AbstractResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。