Java Code Examples for org.springframework.core.io.support.SpringFactoriesLoader#loadFactories()
The following examples show how to use
org.springframework.core.io.support.SpringFactoriesLoader#loadFactories() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StubRepository.java From spring-cloud-contract with Apache License 2.0 | 6 votes |
StubRepository(File repository, List<HttpServerStub> httpServerStubs, StubRunnerOptions options) { if (!repository.isDirectory()) { throw new IllegalArgumentException( "Missing descriptor repository under path [" + repository + "]"); } this.contractConverters = SpringFactoriesLoader .loadFactories(ContractConverter.class, null); if (log.isTraceEnabled()) { log.trace( "Found the following contract converters " + this.contractConverters); } this.httpServerStubs = httpServerStubs; this.path = repository; this.options = options; this.stubs = stubs(); this.contracts = contracts(); if (log.isTraceEnabled()) { log.trace("Found the following contracts " + this.contracts); } }
Example 2
Source File: Target_SpringApplication.java From spring-graalvm-native with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Substitute private <T> Collection<T> getSpringFactoriesInstances(Class<T> type, Class<?>[] parameterTypes, Object... args) { List<T> instances; if (type.equals(SpringApplicationRunListener.class)) { instances = (List<T>) Arrays.asList(new EventPublishingRunListener((SpringApplication)(Object)this, new String[0])); // TODO convert args // Error when using it, and we probably should do that at build time //AnnotationAwareOrderComparator.sort(instances); } else if (type.equals(SpringBootExceptionReporter.class)) { instances = (List<T>) Arrays.asList(DiagnosticsProvider.getFailureAnalyzers((ConfigurableApplicationContext) args[0])); // Package private // Error when using it, and we probably should do that at build time //AnnotationAwareOrderComparator.sort(instances); } else { instances = SpringFactoriesLoader.loadFactories(type, null); } return instances; }
Example 3
Source File: DefaultConfigListener.java From mPaaS with Apache License 2.0 | 5 votes |
@Override public void starting() { if (executed.compareAndSet(false, true)) { List<DefaultConfigFactory> defaultConfigs = SpringFactoriesLoader.loadFactories(DefaultConfigFactory.class, this.getClass().getClassLoader()); Map<String, Object> defaultConfig = new Hashtable<>(1); for (DefaultConfigFactory defaultConfigFactory : defaultConfigs) { defaultConfig.putAll(defaultConfigFactory.defaultConfig()); } springApplication.setDefaultProperties(defaultConfig); } }
Example 4
Source File: FlowableDefaultPropertiesEnvironmentPostProcessor.java From flowable-engine with Apache License 2.0 | 5 votes |
Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) { this.environment = environment; this.resourceLoader = resourceLoader == null ? new DefaultResourceLoader() : resourceLoader; this.propertySourceLoaders = SpringFactoriesLoader.loadFactories( PropertySourceLoader.class, getClass().getClassLoader()); }
Example 5
Source File: WireMockHttpServerStub.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
private Extension[] responseTransformers() { List<WireMockExtensions> wireMockExtensions = SpringFactoriesLoader .loadFactories(WireMockExtensions.class, null); List<Extension> extensions = new ArrayList<>(); if (!wireMockExtensions.isEmpty()) { for (WireMockExtensions wireMockExtension : wireMockExtensions) { extensions.addAll(wireMockExtension.extensions()); } } else { extensions.add(new DefaultResponseTransformer(false, helpers())); } return extensions.toArray(new Extension[extensions.size()]); }
Example 6
Source File: StubRunner.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
public StubRunner(StubRunnerOptions stubRunnerOptions, String repositoryPath, StubConfiguration stubsConfiguration, MessageVerifier<?> contractVerifierMessaging) { this.stubsConfiguration = stubsConfiguration; this.stubRunnerOptions = stubRunnerOptions; List<HttpServerStub> serverStubs = SpringFactoriesLoader .loadFactories(HttpServerStub.class, null); this.stubRepository = new StubRepository(new File(repositoryPath), serverStubs, this.stubRunnerOptions); AvailablePortScanner portScanner = new AvailablePortScanner( stubRunnerOptions.getMinPortValue(), stubRunnerOptions.getMaxPortValue()); this.localStubRunner = new StubRunnerExecutor(portScanner, contractVerifierMessaging, serverStubs); }
Example 7
Source File: BootstrapConfigTest.java From apollo with Apache License 2.0 | 5 votes |
@Test public void test() { List<EnvironmentPostProcessor> processorList = SpringFactoriesLoader.loadFactories(EnvironmentPostProcessor.class, getClass().getClassLoader()); Boolean containsApollo = !Collections2.filter(processorList, new Predicate<EnvironmentPostProcessor>() { @Override public boolean apply(EnvironmentPostProcessor input) { return input instanceof ApolloApplicationContextInitializer; } }).isEmpty(); Assert.assertTrue(containsApollo); }
Example 8
Source File: AccessLimitFilter.java From jim-framework with Apache License 2.0 | 5 votes |
@Override public Object invoke(RpcInvoker invoker, RpcInvocation invocation) { logger.info("before acquire,"+new Date()); List<AccessLimitService> accessLimitServiceLoader = SpringFactoriesLoader.loadFactories(AccessLimitService.class, null); if(!CollectionUtils.isEmpty(accessLimitServiceLoader)){ AccessLimitService accessLimitService=accessLimitServiceLoader.get(0); accessLimitService.acquire(invocation); } Object rpcResponse=invoker.invoke(invocation); logger.info("after acquire,"+new Date()); return rpcResponse; }
Example 9
Source File: SpringSPITest.java From spi-imp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void sayHello() throws Exception { List<OrderService> services = SpringFactoriesLoader.loadFactories(OrderService.class, null); for (OrderService service : services) { service.getOrder("worder."); } }
Example 10
Source File: AdminEndpointApplicationRunListener.java From Moss with Apache License 2.0 | 5 votes |
@Override public void environmentPrepared(ConfigurableEnvironment env) { if("bootstrap".equals(env.getProperty("spring.config.name"))) { List<EnvironmentCustomizer> environmentCustomizers = SpringFactoriesLoader.loadFactories(EnvironmentCustomizer.class, AdminEndpointApplicationRunListener.class.getClassLoader()); if(CollectionUtils.isEmpty(environmentCustomizers)) return; for(EnvironmentCustomizer customizer: environmentCustomizers) { customizer.customize(env); } } }
Example 11
Source File: AdminEndpointApplicationRunListener.java From Moss with Apache License 2.0 | 5 votes |
@Override public void environmentPrepared(ConfigurableEnvironment env) { if("bootstrap".equals(env.getProperty("spring.config.name"))) { List<EnvironmentCustomizer> environmentCustomizers = SpringFactoriesLoader.loadFactories(EnvironmentCustomizer.class, AdminEndpointApplicationRunListener.class.getClassLoader()); if(CollectionUtils.isEmpty(environmentCustomizers)) return; for(EnvironmentCustomizer customizer: environmentCustomizers) { customizer.customize(env); } } }
Example 12
Source File: DefaultConfigListener.java From mPass with Apache License 2.0 | 5 votes |
@Override public void starting() { if (executed.compareAndSet(false, true)) { List<DefaultConfigFactory> defaultConfigs = SpringFactoriesLoader.loadFactories(DefaultConfigFactory.class, this.getClass().getClassLoader()); Map<String, Object> defaultConfig = new Hashtable<>(1); for (DefaultConfigFactory defaultConfigFactory : defaultConfigs) { defaultConfig.putAll(defaultConfigFactory.defaultConfig()); } springApplication.setDefaultProperties(defaultConfig); } }
Example 13
Source File: BootIntegrationTest.java From java-cfenv with Apache License 2.0 | 4 votes |
@Test public void test() { // Should not throw exception SpringFactoriesLoader.loadFactories(CfEnvProcessor.class, getClass().getClassLoader()); }
Example 14
Source File: MagicPropertySourcePostProcessor.java From magic-starter with GNU Lesser General Public License v3.0 | 4 votes |
public MagicPropertySourcePostProcessor() { this.resourceLoader = new DefaultResourceLoader(); this.propertySourceLoaders = SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, getClass().getClassLoader()); }
Example 15
Source File: EncryptablePropertySourceBeanFactoryPostProcessor.java From jasypt-spring-boot with MIT License | 4 votes |
private List<PropertySourceLoader> initPropertyLoaders() { return SpringFactoriesLoader.loadFactories(PropertySourceLoader.class, getClass().getClassLoader()); }
Example 16
Source File: AbstractTestContextBootstrapper.java From java-technology-stack with MIT License | 2 votes |
/** * Get the {@link ContextCustomizerFactory} instances for this bootstrapper. * <p>The default implementation uses the {@link SpringFactoriesLoader} mechanism * for loading factories configured in all {@code META-INF/spring.factories} * files on the classpath. * @since 4.3 * @see SpringFactoriesLoader#loadFactories */ protected List<ContextCustomizerFactory> getContextCustomizerFactories() { return SpringFactoriesLoader.loadFactories(ContextCustomizerFactory.class, getClass().getClassLoader()); }
Example 17
Source File: AbstractTestContextBootstrapper.java From spring-analysis-note with MIT License | 2 votes |
/** * Get the {@link ContextCustomizerFactory} instances for this bootstrapper. * <p>The default implementation uses the {@link SpringFactoriesLoader} mechanism * for loading factories configured in all {@code META-INF/spring.factories} * files on the classpath. * @since 4.3 * @see SpringFactoriesLoader#loadFactories */ protected List<ContextCustomizerFactory> getContextCustomizerFactories() { return SpringFactoriesLoader.loadFactories(ContextCustomizerFactory.class, getClass().getClassLoader()); }