本文整理汇总了Java中org.springframework.core.io.support.SpringFactoriesLoader类的典型用法代码示例。如果您正苦于以下问题:Java SpringFactoriesLoader类的具体用法?Java SpringFactoriesLoader怎么用?Java SpringFactoriesLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpringFactoriesLoader类属于org.springframework.core.io.support包,在下文中一共展示了SpringFactoriesLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMatchOutcome
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
List<TemplateAvailabilityProvider> availabilityProviders = SpringFactoriesLoader
.loadFactories(TemplateAvailabilityProvider.class,
context.getClassLoader());
for (TemplateAvailabilityProvider availabilityProvider : availabilityProviders) {
if (availabilityProvider.isTemplateAvailable("error",
context.getEnvironment(), context.getClassLoader(),
context.getResourceLoader())) {
return ConditionOutcome.noMatch("Template from "
+ availabilityProvider + " found for error view");
}
}
return ConditionOutcome.match("No error template view detected");
}
示例2: buildInitializer
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
protected T buildInitializer(Supplier<T> defaultSupplier, Object ... args) {
List<String> initClassNames = SpringFactoriesLoader.loadFactoryNames(initClass, Thread.currentThread().getContextClassLoader());
if (initClassNames.isEmpty()) {
return defaultSupplier.get();
}
List<Class<?>> initClasses = ClassUtils.convertClassNamesToClasses(initClassNames);
initClasses.sort(AnnotationAwareOrderComparator.INSTANCE);
Class<?> primaryInitClass = initClasses.get(0);
try {
return this.initClass.cast(ConstructorUtils.invokeConstructor(primaryInitClass, args));
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
throw new ApplicationContextException(String.format("Unable to instantiate application initializer (class=%s).", primaryInitClass.getName()), e);
}
}
示例3: init
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
@Override
public void init() {
SdcctBeanDefinitionParser beanDefParser;
for (Class<?> beanDefClass : ClassUtils
.convertClassNamesToClasses(SpringFactoriesLoader.loadFactoryNames(SdcctBeanDefinitionParser.class, this.getClass().getClassLoader()))) {
try {
beanDefParser = ((SdcctBeanDefinitionParser) ConstructorUtils.invokeConstructor(beanDefClass, this));
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
throw new ApplicationContextException(String.format("Unable to instantiate bean definition parser (class=%s).", beanDefClass.getName()), e);
}
for (String beanDefParserElemLocalName : beanDefParser.getElementBeanClasses().keySet()) {
this.beanDefParsers.put(beanDefParserElemLocalName, beanDefParser);
this.registerBeanDefinitionParser(beanDefParserElemLocalName, beanDefParser);
}
}
}
示例4: buildComponent
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
protected static <T> T buildComponent(Class<T> componentClass, Supplier<T> defaultSupplier, Object ... args) {
List<String> componentClassNames = SpringFactoriesLoader.loadFactoryNames(componentClass, AbstractCrigttApplicationRunListener.class.getClassLoader());
if (componentClassNames.isEmpty()) {
return defaultSupplier.get();
}
List<Class<?>> componentClasses = ClassUtils.convertClassNamesToClasses(componentClassNames);
componentClasses.sort(AnnotationAwareOrderComparator.INSTANCE);
Class<?> primaryComponentClass = componentClasses.get(0);
try {
return componentClass.cast(ConstructorUtils.invokeConstructor(primaryComponentClass, args));
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
throw new ApplicationContextException(String.format("Unable to instantiate component (class=%s).", primaryComponentClass.getName()), e);
}
}
示例5: CredentialProviderRegistry
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
CredentialProviderRegistry(final DataManager dataManager) {
this.dataManager = dataManager;
credentialProviderFactories = SpringFactoriesLoader
.loadFactories(CredentialProviderFactory.class, ClassUtils.getDefaultClassLoader()).stream()
.collect(Collectors.toMap(CredentialProviderFactory::id, Function.identity()));
}
示例6: test01
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
@Test
public void test01() {
try {
Enumeration<URL> files = this.getClass().getClassLoader().getResources(SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION);
while(files.hasMoreElements()) {
System.out.println("=== " + files.nextElement());
}
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: test02
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
@Test
public void test02() {
List<String> classes = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, this.getClass().getClassLoader());
classes.forEach(clazz -> {
System.out.println("==== " + clazz);
});
}
示例8: PropertySourcesLoader
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
/**
* Create a new {@link PropertySourceLoader} instance backed by the specified
* {@link MutablePropertySources}.
* @param propertySources the destination property sources
*/
public PropertySourcesLoader(MutablePropertySources propertySources) {
Assert.notNull(propertySources, "PropertySources must not be null");
this.propertySources = propertySources;
this.loaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class,
getClass().getClassLoader());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:PropertySourcesLoader.java
示例9: getSpringFactoriesInstances
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
private <T> Collection<? extends T> getSpringFactoriesInstances(Class<T> type,
Class<?>[] parameterTypes, Object... args) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// Use names and ensure unique to protect against duplicates
Set<String> names = new LinkedHashSet<String>(
SpringFactoriesLoader.loadFactoryNames(type, classLoader));
List<T> instances = createSpringFactoriesInstances(type, parameterTypes,
classLoader, args, names);
AnnotationAwareOrderComparator.sort(instances);
return instances;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:SpringApplication.java
示例10: analyzeAndReport
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
public static boolean analyzeAndReport(Throwable failure, ClassLoader classLoader,
ConfigurableApplicationContext context) {
List<FailureAnalyzer> analyzers = SpringFactoriesLoader
.loadFactories(FailureAnalyzer.class, classLoader);
List<FailureAnalysisReporter> reporters = SpringFactoriesLoader
.loadFactories(FailureAnalysisReporter.class, classLoader);
FailureAnalysis analysis = analyze(failure, analyzers, context);
return report(analysis, reporters);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:FailureAnalyzers.java
示例11: selectImports
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata metadata) {
// Find all possible auto configuration classes, filtering duplicates
List<String> factories = new ArrayList<String>(
new LinkedHashSet<String>(SpringFactoriesLoader.loadFactoryNames(
ManagementContextConfiguration.class, this.classLoader)));
AnnotationAwareOrderComparator.sort(factories);
return factories.toArray(new String[0]);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ManagementContextConfigurationsImportSelector.java
示例12: getConfigurationsForAnnotation
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
private Collection<String> getConfigurationsForAnnotation(Class<?> source,
Annotation annotation) {
String[] value = (String[]) AnnotationUtils
.getAnnotationAttributes(annotation, true).get("value");
if (value.length > 0) {
return Arrays.asList(value);
}
return SpringFactoriesLoader.loadFactoryNames(source,
getClass().getClassLoader());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:ImportAutoConfigurationImportSelector.java
示例13: getCandidateConfigurations
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
/**
* Return the auto-configuration class names that should be considered. By default
* this method will load candidates using {@link SpringFactoriesLoader} with
* {@link #getSpringFactoriesLoaderFactoryClass()}.
* @param metadata the source metadata
* @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
* attributes}
* @return a list of candidate configurations
*/
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
AnnotationAttributes attributes) {
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader());
Assert.notEmpty(configurations,
"No auto configuration classes found in META-INF/spring.factories. If you "
+ "are using a custom packaging, make sure that file is correct.");
return configurations;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:EnableAutoConfigurationImportSelector.java
示例14: importsAreSelected
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
@Test
public void importsAreSelected() {
configureExclusions(new String[0], new String[0], new String[0]);
String[] imports = this.importSelector.selectImports(this.annotationMetadata);
assertThat(imports).hasSameSizeAs(SpringFactoriesLoader.loadFactoryNames(
EnableAutoConfiguration.class, getClass().getClassLoader()));
assertThat(ConditionEvaluationReport.get(this.beanFactory).getExclusions())
.isEmpty();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:EnableAutoConfigurationImportSelectorTests.java
示例15: getCandidateConfigurations
import org.springframework.core.io.support.SpringFactoriesLoader; //导入依赖的package包/类
/**
* Return the HTTP client class names that should be considered. By default
* this method will load candidates using {@link SpringFactoriesLoader} with
* {@link #getSpringFactoriesLoaderFactoryClass()}.
* attributes}
* @return a list of candidate configurations
*/
protected List<String> getCandidateConfigurations() {
List<String> configurations = SpringFactoriesLoader.loadFactoryNames(
getSpringFactoriesLoaderFactoryClass(), this.getClass().getClassLoader());
Assert.notEmpty(configurations,
"No HTTP client classes found in META-INF/spring.factories. If you" +
"are using a custom packaging, make sure that file is correct.");
return configurations;
}