本文整理汇总了Java中org.springframework.core.io.DefaultResourceLoader类的典型用法代码示例。如果您正苦于以下问题:Java DefaultResourceLoader类的具体用法?Java DefaultResourceLoader怎么用?Java DefaultResourceLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultResourceLoader类属于org.springframework.core.io包,在下文中一共展示了DefaultResourceLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newCredentialSelectionPredicate
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的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());
}
}
示例2: setUp
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
final ProtectionDomain empty = new ProtectionDomain(null,
new Permissions());
provider = new SecurityContextProvider() {
private final AccessControlContext acc = new AccessControlContext(
new ProtectionDomain[] { empty });
@Override
public AccessControlContext getAccessControlContext() {
return acc;
}
};
DefaultResourceLoader drl = new DefaultResourceLoader();
Resource config = drl
.getResource("/org/springframework/beans/factory/support/security/callbacks.xml");
beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(config);
beanFactory.setSecurityContextProvider(provider);
}
示例3: afterPropertiesSet
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception
{
// load the document conversion configuration
if (documentFormatsConfiguration != null)
{
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
try
{
InputStream is = resourceLoader.getResource(this.documentFormatsConfiguration).getInputStream();
formatRegistry = new JsonDocumentFormatRegistry(is);
// We do not need to explicitly close this InputStream as it is closed for us within the XmlDocumentFormatRegistry
}
catch (IOException e)
{
throw new AlfrescoRuntimeException(
"Unable to load document formats configuration file: "
+ this.documentFormatsConfiguration);
}
}
else
{
formatRegistry = new DefaultDocumentFormatRegistry();
}
}
示例4: importStream
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的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);
}
}
示例5: testAppContextClassHierarchy
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
public void testAppContextClassHierarchy() {
Class<?>[] clazz =
ClassUtils.getClassHierarchy(OsgiBundleXmlApplicationContext.class, ClassUtils.ClassSet.ALL_CLASSES);
//Closeable.class,
Class<?>[] expected =
new Class<?>[] { OsgiBundleXmlApplicationContext.class,
AbstractDelegatedExecutionApplicationContext.class, AbstractOsgiBundleApplicationContext.class,
AbstractRefreshableApplicationContext.class, AbstractApplicationContext.class,
DefaultResourceLoader.class, ResourceLoader.class,
AutoCloseable.class,
DelegatedExecutionOsgiBundleApplicationContext.class,
ConfigurableOsgiBundleApplicationContext.class, ConfigurableApplicationContext.class,
ApplicationContext.class, Lifecycle.class, Closeable.class, EnvironmentCapable.class, ListableBeanFactory.class,
HierarchicalBeanFactory.class, ApplicationEventPublisher.class, ResourcePatternResolver.class,
MessageSource.class, BeanFactory.class, DisposableBean.class };
assertTrue(compareArrays(expected, clazz));
}
示例6: dynamicSqlSessionFactory
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
/**
* Dynamic sql session factory sql session factory.
*
* @param dynamicDataSource the dynamic data source
* @param properties the properties
* @return the sql session factory
*/
@Bean
@ConfigurationProperties(prefix = MybatisProperties.MYBATIS_PREFIX)
public SqlSessionFactory dynamicSqlSessionFactory(
@Qualifier("dynamicDataSource") DataSource dynamicDataSource,
MybatisProperties properties) {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dynamicDataSource);
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(properties.getConfigLocation()));
sessionFactory.setMapperLocations(properties.resolveMapperLocations());
try {
return sessionFactory.getObject();
} catch (Exception e) {
throw new SystemException(e);
}
}
示例7: getProjectPath
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
/**
* 获取工程路径
* @return
*/
public static String getProjectPath(){
String projectPath = "";
try {
File file = new DefaultResourceLoader().getResource("").getFile();
if (file != null){
while(true){
File f = new File(file.getPath() + File.separator + "src" + File.separator + "main");
if (f == null || f.exists()){
break;
}
if (file.getParentFile() != null){
file = file.getParentFile();
}else{
break;
}
}
projectPath = file.toString();
}
} catch (IOException e) {
e.printStackTrace();
}
return projectPath;
}
示例8: setup
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
@Before
public void setup() {
SAMLSSOProperties properties = mock(SAMLSSOProperties.class);
keyManagerProperties = mock(KeyManagerProperties.class);
when(properties.getKeyManager()).thenReturn(keyManagerProperties);
// when(keyManagerProperties.getDefaultKey()).thenReturn("default");
// when(keyManagerProperties.getKeyPasswords()).thenReturn(Collections.singletonMap("default", "password"));
// when(keyManagerProperties.getPrivateKeyDerLocation()).thenReturn("classpath:localhost:key.der");
// when(keyManagerProperties.getPublicKeyPemLocation()).thenReturn("classpath:localhost.cert");
// when(keyManagerProperties.getStoreLocation()).thenReturn("classpath:KeyStore.jks");
// when(keyManagerProperties.getStorePass()).thenReturn("storePass");
builder = mock(ServiceProviderBuilder.class);
when(builder.getSharedObject(KeyManager.class)).thenReturn(null);
when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties);
when(builder.getSharedObject(ResourceLoader.class)).thenReturn(new DefaultResourceLoader());
}
示例9: testArguments_keystore
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
@Test
public void testArguments_keystore() throws Exception {
KeyManagerConfigurer configurer = new KeyManagerConfigurer();
configurer
.keyStore(new KeystoreFactory(new DefaultResourceLoader()).createEmptyKeystore());
configurer.init(builder);
configurer.configure(builder);
ArgumentCaptor<KeyManager> providerCaptor = ArgumentCaptor.forClass(KeyManager.class);
verify(builder).setSharedObject(eq(KeyManager.class), providerCaptor.capture());
verify(keyManagerProperties).getDefaultKey();
verify(keyManagerProperties).getKeyPasswords();
verify(keyManagerProperties).getPrivateKeyDerLocation();
verify(keyManagerProperties).getPublicKeyPemLocation();
verify(keyManagerProperties).getStoreLocation();
verify(keyManagerProperties).getStorePass();
assertThat(providerCaptor.getValue()).isNotNull();
KeyManager keyManager = providerCaptor.getValue();
assertThat(keyManager.getAvailableCredentials()).isEmpty();
}
示例10: setup
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
@Before
public void setup() {
properties = mock(SAMLSSOProperties.class);
metadataManagerProperties = spy(new MetadataManagerProperties());
extendedMetadataDelegateProperties = spy(new ExtendedMetadataDelegateProperties());
idpConfiguration = spy(new IdentityProvidersProperties());
extendedMetadata = spy(new ExtendedMetadata());
when(properties.getMetadataManager()).thenReturn(metadataManagerProperties);
when(properties.getExtendedDelegate()).thenReturn(extendedMetadataDelegateProperties);
when(properties.getIdp()).thenReturn(idpConfiguration);
builder = mock(ServiceProviderBuilder.class);
when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties);
when(builder.getSharedObject(ExtendedMetadata.class)).thenReturn(extendedMetadata);
resourceLoader = new DefaultResourceLoader();
when(builder.getSharedObject(ResourceLoader.class)).thenReturn(resourceLoader);
parserPool = mock(ParserPool.class);
when(builder.getSharedObject(ParserPool.class)).thenReturn(parserPool);
}
示例11: printBanner
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
private Banner printBanner(ConfigurableEnvironment environment) {
if (this.bannerMode == Banner.Mode.OFF) {
return null;
}
if (printBannerViaDeprecatedMethod(environment)) {
return null;
}
ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader
: new DefaultResourceLoader(getClassLoader());
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(
resourceLoader, this.banner);
if (this.bannerMode == Mode.LOG) {
return bannerPrinter.print(environment, this.mainApplicationClass, logger);
}
return bannerPrinter.print(environment, this.mainApplicationClass, System.out);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:SpringApplication.java
示例12: postProcessApplicationContext
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
/**
* Apply any relevant post processing the {@link ApplicationContext}. Subclasses can
* apply additional processing as required.
* @param context the application context
*/
protected void postProcessApplicationContext(ConfigurableApplicationContext context) {
if (this.beanNameGenerator != null) {
context.getBeanFactory().registerSingleton(
AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR,
this.beanNameGenerator);
}
if (this.resourceLoader != null) {
if (context instanceof GenericApplicationContext) {
((GenericApplicationContext) context)
.setResourceLoader(this.resourceLoader);
}
if (context instanceof DefaultResourceLoader) {
((DefaultResourceLoader) context)
.setClassLoader(this.resourceLoader.getClassLoader());
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:SpringApplication.java
示例13: multipleScriptsAppliedInLexicalOrder
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
@Test
public void multipleScriptsAppliedInLexicalOrder() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.datasource.initialize:true",
"spring.datasource.schema:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "lexical-schema-*.sql"),
"spring.datasource.data:" + ClassUtils
.addResourcePathToPackagePath(getClass(), "data.sql"));
this.context.register(DataSourceAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
ReverseOrderResourceLoader resourceLoader = new ReverseOrderResourceLoader(
new DefaultResourceLoader());
this.context.setResourceLoader(resourceLoader);
this.context.refresh();
DataSource dataSource = this.context.getBean(DataSource.class);
assertThat(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource).isTrue();
assertThat(dataSource).isNotNull();
JdbcOperations template = new JdbcTemplate(dataSource);
assertThat(template.queryForObject("SELECT COUNT(*) from FOO", Integer.class))
.isEqualTo(1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:DataSourceInitializerTests.java
示例14: getDummyFileResource
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
protected Resource getDummyFileResource(final String mimetype)
{
final String extension = this.mimetypeService.getExtension(mimetype);
Resource resource = null;
final List<String> pathsToSearch = new ArrayList<>(this.dummyFilePaths);
Collections.reverse(pathsToSearch);
final DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
for (final String path : pathsToSearch)
{
resource = resourceLoader.getResource(path + "/dummy." + extension);
if (resource != null)
{
if (resource.exists())
{
break;
}
// nope'd
resource = null;
}
}
LOGGER.trace("Found dummy file resource {} for extension {}", resource, extension);
return resource;
}
示例15: postProcessApplicationContext
import org.springframework.core.io.DefaultResourceLoader; //导入依赖的package包/类
/**
* Apply any relevant post processing the {@link ApplicationContext}. Subclasses can
* apply additional processing as required.
* @param context the application context
*/
protected void postProcessApplicationContext(ConfigurableApplicationContext context) {
if (this.webEnvironment) {
if (context instanceof ConfigurableWebApplicationContext) {
ConfigurableWebApplicationContext configurableContext = (ConfigurableWebApplicationContext) context;
if (this.beanNameGenerator != null) {
configurableContext.getBeanFactory().registerSingleton(
AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR,
this.beanNameGenerator);
}
}
}
if (this.resourceLoader != null) {
if (context instanceof GenericApplicationContext) {
((GenericApplicationContext) context)
.setResourceLoader(this.resourceLoader);
}
if (context instanceof DefaultResourceLoader) {
((DefaultResourceLoader) context)
.setClassLoader(this.resourceLoader.getClassLoader());
}
}
}