1
1
/*
2
- * Copyright 2016-2023 the original author or authors.
2
+ * Copyright 2016-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -80,6 +80,8 @@ public class SnsInboundChannelAdapter extends HttpRequestHandlingMessagingGatewa
80
80
private final MappingJackson2HttpMessageConverter jackson2HttpMessageConverter =
81
81
new MappingJackson2HttpMessageConverter ();
82
82
83
+ private final String [] path ;
84
+
83
85
private volatile boolean handleNotificationStatus ;
84
86
85
87
private volatile Expression payloadExpression ;
@@ -91,17 +93,10 @@ public SnsInboundChannelAdapter(SnsClient amazonSns, String... path) {
91
93
Assert .notNull (amazonSns , "'amazonSns' must not be null." );
92
94
Assert .notNull (path , "'path' must not be null." );
93
95
Assert .noNullElements (path , "'path' must not contain null elements." );
96
+ this .path = path ;
94
97
this .notificationStatusResolver = new NotificationStatusResolver (amazonSns );
95
- RequestMapping requestMapping = new RequestMapping ();
96
- requestMapping .setMethods (HttpMethod .POST );
97
- requestMapping .setHeaders ("x-amz-sns-message-type" );
98
- requestMapping .setPathPatterns (path );
99
98
this .jackson2HttpMessageConverter
100
99
.setSupportedMediaTypes (Arrays .asList (MediaType .APPLICATION_JSON , MediaType .TEXT_PLAIN ));
101
- super .setRequestMapping (requestMapping );
102
- super .setStatusCodeExpression (new ValueExpression <>(HttpStatus .NO_CONTENT ));
103
- super .setMessageConverters (Collections .singletonList (this .jackson2HttpMessageConverter ));
104
- super .setRequestPayloadTypeClass (HashMap .class );
105
100
}
106
101
107
102
public void setHandleNotificationStatus (boolean handleNotificationStatus ) {
@@ -111,6 +106,14 @@ public void setHandleNotificationStatus(boolean handleNotificationStatus) {
111
106
@ Override
112
107
protected void onInit () {
113
108
super .onInit ();
109
+ RequestMapping requestMapping = new RequestMapping ();
110
+ requestMapping .setMethods (HttpMethod .POST );
111
+ requestMapping .setHeaders ("x-amz-sns-message-type" );
112
+ requestMapping .setPathPatterns (this .path );
113
+ super .setStatusCodeExpression (new ValueExpression <>(HttpStatus .NO_CONTENT ));
114
+ super .setMessageConverters (Collections .singletonList (this .jackson2HttpMessageConverter ));
115
+ super .setRequestPayloadTypeClass (HashMap .class );
116
+ super .setRequestMapping (requestMapping );
114
117
if (this .payloadExpression != null ) {
115
118
this .evaluationContext = createEvaluationContext ();
116
119
}
0 commit comments