Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java configuration for spring aws cloud SNS endpoint argument resolver

I am struggling to find spring boot java configuration equivalent to the below xml configuration for my spring aws cloud SNS http endpoint. Could some one please help?.

<mvc:annotation-driven>
        <mvc:argument-resolvers>
            <ref bean="notificationResolver" />
        </mvc:argument-resolvers>
       </mvc:annotation-driven>
     <aws-messaging:notification-argument-resolver id="notificationResolver" />
like image 486
Bill Goldberg Avatar asked Nov 08 '22 18:11

Bill Goldberg


1 Answers

The Java config is in the spring-cloud-aws project here on GitHub

import com.amazonaws.services.sns.AmazonSNS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.aws.context.annotation.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

import static org.springframework.cloud.aws.messaging.endpoint.config.NotificationHandlerMethodArgumentResolverConfigurationUtils.getNotificationHandlerMethodArgumentResolver;

/**
 * @author Agim Emruli
 */
@Configuration
@ConditionalOnClass("org.springframework.web.servlet.config.annotation.WebMvcConfigurer")
public class SnsWebConfiguration extends WebMvcConfigurerAdapter {

    @Autowired
    private AmazonSNS amazonSns;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(getNotificationHandlerMethodArgumentResolver(this.amazonSns));
    }
}
like image 149
ares Avatar answered Nov 15 '22 06:11

ares