Commits

NIG authored bab81953e0b Merge
Merge remote-tracking branch 'origin/develop' into feature/cbs-cache-invalidator
No tags

cbs-datafetcher/src/main/java/dk/sundhedsdatastyrelsen/cbs/datafetcher/config/DataFetcherNasConfig.java

Added
1 +/*
2 + * The MIT License
3 + *
4 + * Original work sponsored and donated by The Danish Health Data Authority (http://www.sundhedsdatastyrelsen.dk)
5 + *
6 + * Copyright (C) 2021 The Danish Health Data Authority (http://www.sundhedsdatastyrelsen.dk)
7 + *
8 + *
9 + * Permission is hereby granted, free of charge, to any person obtaining a copy of
10 + * this software and associated documentation files (the "Software"), to deal in
11 + * the Software without restriction, including without limitation the rights to
12 + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 + * of the Software, and to permit persons to whom the Software is furnished to do
14 + * so, subject to the following conditions:
15 + *
16 + *
17 + * The above copyright notice and this permission notice shall be included in all
18 + * copies or substantial portions of the Software.
19 + *
20 + *
21 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 + * SOFTWARE.
28 + */
29 +package dk.sundhedsdatastyrelsen.cbs.datafetcher.config;
30 +
31 +import dk.sundhedsdatastyrelsen.cbs.nas.facade.NasPublisher;
32 +import dk.sundhedsdatastyrelsen.cbs.nas.facade.NasPublisherImpl;
33 +import org.apache.commons.lang3.StringUtils;
34 +import org.oasis_open.docs.wsn.bw_2.NotificationBrokerService;
35 +import org.oasis_open.docs.wsn.bw_2.NotificationConsumer;
36 +import org.springframework.beans.factory.annotation.Value;
37 +import org.springframework.context.annotation.Bean;
38 +import org.springframework.context.annotation.Configuration;
39 +
40 +import javax.xml.ws.BindingProvider;
41 +
42 +@Configuration
43 +public class DataFetcherNasConfig {
44 +
45 + @Bean
46 + public NasPublisher nasPublisher(@Value("${nas.topic}") String nasTopic,
47 + @Value("${nas.endpoint}") String nasEndpoint,
48 + @Value("${nas.connection-timeout-millis}") String nasConnectionTimeoutMillis,
49 + @Value("${nas.receive-timeout-millis}") String nasReceiveTimeoutMillis) {
50 + NotificationConsumer notificationConsumer = new NotificationBrokerService().getSoap();
51 + ((BindingProvider) notificationConsumer).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, nasEndpoint);
52 + if (StringUtils.isNotBlank(nasConnectionTimeoutMillis)) {
53 + //vendor/jdk specific (not sure which one is needed, so setting both)
54 + ((BindingProvider) notificationConsumer).getRequestContext().put("javax.xml.ws.client.connectionTimeout", nasConnectionTimeoutMillis);
55 + ((BindingProvider) notificationConsumer).getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", nasConnectionTimeoutMillis);
56 + }
57 + if (StringUtils.isNotBlank(nasReceiveTimeoutMillis)) {
58 + //vendor/jdk specific (not sure which one is needed, so setting both)
59 + ((BindingProvider) notificationConsumer).getRequestContext().put("javax.xml.ws.client.receiveTimeout", nasReceiveTimeoutMillis);
60 + ((BindingProvider) notificationConsumer).getRequestContext().put("com.sun.xml.internal.ws.request.timeout", nasReceiveTimeoutMillis);
61 + }
62 + return new NasPublisherImpl(notificationConsumer, nasTopic);
63 + }
64 +}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut