org.springframework.core.io.ProtocolResolver Java Examples

The following examples show how to use org.springframework.core.io.ProtocolResolver. 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: S3ProtocolResolverRegistrar.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * Add the {@link S3ProtocolResolver} to the set of protocol resolvers in the application context. Remove any
 * instances of {@link SimpleStorageProtocolResolver}.
 */
@Override
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
    if (applicationContext instanceof ConfigurableApplicationContext) {
        final ConfigurableApplicationContext configurableApplicationContext
            = (ConfigurableApplicationContext) applicationContext;

        if (configurableApplicationContext instanceof AbstractApplicationContext) {
            final AbstractApplicationContext abstractApplicationContext
                = (AbstractApplicationContext) configurableApplicationContext;

            final Collection<ProtocolResolver> protocolResolvers
                = abstractApplicationContext.getProtocolResolvers();

            final Set<ProtocolResolver> simpleStorageProtocolResolvers = protocolResolvers
                .stream()
                .filter(SimpleStorageProtocolResolver.class::isInstance)
                .collect(Collectors.toSet());

            protocolResolvers.removeAll(simpleStorageProtocolResolvers);
        }

        log.info(
            "Adding instance of {} to the set of protocol resolvers",
            this.s3ProtocolResolver.getClass().getCanonicalName()
        );
        configurableApplicationContext.addProtocolResolver(this.s3ProtocolResolver);
    }
}
 
Example #2
Source File: AwsAutoConfigurationTest.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Test expected context.
 */
@Test
void testExpectedContext() {
    this.contextRunner.run(
        (context) -> {
            Assertions.assertThat(context).hasSingleBean(AwsRegionProvider.class);
            Assertions.assertThat(context).hasSingleBean(S3ClientFactory.class);
            Assertions.assertThat(context).hasSingleBean(AwsS3ResourceLoaderProperties.class);
            Assertions.assertThat(context).hasSingleBean(S3ProtocolResolver.class);
            Assertions.assertThat(context).hasSingleBean(S3ProtocolResolverRegistrar.class);
            Assertions.assertThat(context).hasSingleBean(S3JobArchiverImpl.class);
            Assertions.assertThat(context).hasSingleBean(JobArchiver.class);

            // Verify that Spring Cloud AWS still would try to register their S3 protocol resolver
            Assertions.assertThat(context).hasSingleBean(SimpleStorageProtocolResolverConfigurer.class);

            // And Make sure we ripped out the one from Spring Cloud AWS and put ours in instead
            if (context instanceof AbstractApplicationContext) {
                final AbstractApplicationContext aac = (AbstractApplicationContext) context;
                final Collection<ProtocolResolver> protocolResolvers = aac.getProtocolResolvers();
                Assertions.assertThat(protocolResolvers).contains(context.getBean(S3ProtocolResolver.class));
                Assertions
                    .assertThat(protocolResolvers)
                    .doesNotHaveAnyElementsOfTypes(SimpleStorageProtocolResolver.class);
            }
        }
    );
}
 
Example #3
Source File: ThreadSafeClassPathXmlApplicationContext.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Override
public void addProtocolResolver(ProtocolResolver protocolResolver) {
    this.configurableApplicationContext.addProtocolResolver(protocolResolver);
}
 
Example #4
Source File: MicronautApplicationContext.java    From micronaut-spring with Apache License 2.0 4 votes vote down vote up
@Override
public void addProtocolResolver(ProtocolResolver resolver) {
    beanFactory.getBeanContext().registerSingleton(resolver);
}
 
Example #5
Source File: ConfigurableApplicationContext.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Register the given protocol resolver with this application context,
 * allowing for additional resource protocols to be handled.
 * <p>Any such resolver will be invoked ahead of this context's standard
 * resolution rules. It may therefore also override any default rules.
 * @since 4.3
 */
void addProtocolResolver(ProtocolResolver resolver);
 
Example #6
Source File: ConfigurableApplicationContext.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Register the given protocol resolver with this application context,
 * allowing for additional resource protocols to be handled.
 * <p>Any such resolver will be invoked ahead of this context's standard
 * resolution rules. It may therefore also override any default rules.
 * @since 4.3
 */
void addProtocolResolver(ProtocolResolver resolver);
 
Example #7
Source File: ConfigurableApplicationContext.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Register the given protocol resolver with this application context,
 * allowing for additional resource protocols to be handled.
 * <p>Any such resolver will be invoked ahead of this context's standard
 * resolution rules. It may therefore also override any default rules.
 * @since 4.3
 */
void addProtocolResolver(ProtocolResolver resolver);