1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.ws;
17
18 import org.apache.cxf.frontend.ServerFactoryBean;
19 import org.apache.cxf.interceptor.InterceptorProvider;
20 import org.openehealth.ipf.commons.audit.AuditContext;
21 import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
22 import org.openehealth.ipf.commons.ihe.ws.correlation.AsynchronyCorrelator;
23 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditResponseInterceptor;
24 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.WsAuditDataset;
25 import org.openehealth.ipf.commons.ihe.ws.cxf.payload.InPayloadExtractorInterceptor;
26
27 import static java.util.Objects.requireNonNull;
28 import static org.openehealth.ipf.commons.ihe.ws.cxf.payload.StringPayloadHolder.PayloadType.SOAP_BODY;
29
30
31
32
33 public class JaxWsAsyncResponseServiceFactory<AuditDatasetType extends WsAuditDataset> extends JaxWsServiceFactory<AuditDatasetType> {
34
35 protected final AsynchronyCorrelator<AuditDatasetType> correlator;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public JaxWsAsyncResponseServiceFactory(
51 WsTransactionConfiguration<AuditDatasetType> wsTransactionConfiguration,
52 String serviceAddress,
53 AuditStrategy<AuditDatasetType> auditStrategy,
54 AuditContext auditContext,
55 InterceptorProvider customInterceptors,
56 AsynchronyCorrelator<AuditDatasetType> correlator)
57 {
58 super(wsTransactionConfiguration, serviceAddress, auditStrategy, auditContext,
59 customInterceptors, null);
60
61 requireNonNull(correlator, "Correlator for asynchronous processing must be set.");
62 this.correlator = correlator;
63 }
64
65 @Override
66 protected void configureInterceptors(ServerFactoryBean svrFactory) {
67 super.configureInterceptors(svrFactory);
68
69
70 if (auditStrategy != null) {
71 if (wsTransactionConfiguration.isAuditRequestPayload()) {
72 svrFactory.getInInterceptors().add(new InPayloadExtractorInterceptor(SOAP_BODY));
73 }
74
75 AuditResponseInterceptor<AuditDatasetType> auditInterceptor =
76 new AuditResponseInterceptor<>(auditStrategy, auditContext,false, correlator, true);
77 svrFactory.getInInterceptors().add(auditInterceptor);
78 svrFactory.getInFaultInterceptors().add(auditInterceptor);
79 }
80 }
81 }