diff options
Diffstat (limited to 'juick-notifications/src/main/java/com/juick/components/configuration')
4 files changed, 18 insertions, 35 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/APNSConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/APNSConfiguration.java index 43ea3943..fbc17bc9 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/APNSConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/APNSConfiguration.java @@ -1,34 +1,18 @@ package com.juick.components.configuration; -import com.turo.pushy.apns.ApnsClient; -import com.turo.pushy.apns.ApnsClientBuilder; -import com.turo.pushy.apns.auth.ApnsSigningKey; -import org.springframework.beans.factory.annotation.Value; +import com.juick.components.APNSManager; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.io.File; -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - /** * Created by vital on 28.03.2017. */ @Configuration +@ConditionalOnProperty(name = "ios_p8_key") public class APNSConfiguration { - @Value("${ios_p8_key:}") - private String p8key; - @Value("${ios_team_id:}") - private String teamId; - @Value("${ios_key_id:}") - private String keyId; @Bean - public ApnsClient apns() throws NoSuchAlgorithmException, InvalidKeyException, IOException { - return new ApnsClientBuilder() - .setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST) - .setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File(p8key), - teamId, keyId)) - .build(); + public APNSManager apnsManager() { + return new APNSManager(); } } diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java index 27e1af0f..68d9f017 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/GCMConfiguration.java @@ -1,8 +1,7 @@ package com.juick.components.configuration; -import com.google.android.gcm.server.Endpoint; -import com.google.android.gcm.server.Sender; -import org.springframework.beans.factory.annotation.Value; +import com.juick.components.FirebaseManager; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -10,12 +9,11 @@ import org.springframework.context.annotation.Configuration; * Created by vital on 29.03.2017. */ @Configuration +@ConditionalOnProperty(name = "gcm_key") public class GCMConfiguration { - @Value("${gcm_key:}") - private String gcmKey; @Bean - public Sender GCMSender() { - return new Sender(gcmKey, Endpoint.GCM); + public FirebaseManager firebaseManager() { + return new FirebaseManager(); } } diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/JuickServerWebsocketConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/JuickServerWebsocketConfiguration.java index c35dfc7d..deb0cb5b 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/JuickServerWebsocketConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/JuickServerWebsocketConfiguration.java @@ -1,14 +1,13 @@ package com.juick.components.configuration; import com.fasterxml.jackson.databind.ObjectMapper; -import com.juick.components.Notifications; +import com.juick.components.NotificationsManager; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.http.client.ClientHttpRequestInterceptor; @@ -40,7 +39,7 @@ public class JuickServerWebsocketConfiguration { @Inject ObjectMapper jsonMapper; @Inject - private Notifications notifications; + private NotificationsManager notificationsManager; @Bean public RestTemplate rest() { RestTemplate rest = new RestTemplate(); @@ -62,7 +61,7 @@ public class JuickServerWebsocketConfiguration { } String websocketURI = UriComponentsBuilder.fromUriString(baseUri) .queryParam("hash", hash).build().toUriString(); - WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), notifications, websocketURI); + WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), notificationsManager, websocketURI); return manager; } @Bean diff --git a/juick-notifications/src/main/java/com/juick/components/configuration/MPNSConfiguration.java b/juick-notifications/src/main/java/com/juick/components/configuration/MPNSConfiguration.java index f849b159..4235486c 100644 --- a/juick-notifications/src/main/java/com/juick/components/configuration/MPNSConfiguration.java +++ b/juick-notifications/src/main/java/com/juick/components/configuration/MPNSConfiguration.java @@ -1,6 +1,7 @@ package com.juick.components.configuration; -import com.juick.components.MPNSClient; +import com.juick.components.MPNSManager; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -8,9 +9,10 @@ import org.springframework.context.annotation.Configuration; * Created by vital on 29.03.2017. */ @Configuration +@ConditionalOnProperty(name = "wns_application_sip") public class MPNSConfiguration { @Bean - public MPNSClient mpnsClient() { - return new MPNSClient(); + public MPNSManager mpnsClient() { + return new MPNSManager(); } } |