View Javadoc
1   /*
2    * Copyright 2011 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.hl7v3;
17  
18  import org.apache.cxf.endpoint.Client;
19  import org.apache.cxf.feature.AbstractFeature;
20  import org.apache.cxf.interceptor.InterceptorProvider;
21  import org.openehealth.ipf.commons.audit.AuditContext;
22  import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
23  import org.openehealth.ipf.commons.ihe.hl7v3.audit.Hl7v3AuditDataset;
24  import org.openehealth.ipf.commons.ihe.ws.JaxWsClientFactory;
25  import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditResponseInterceptor;
26  import org.openehealth.ipf.commons.ihe.ws.cxf.databinding.plainxml.PlainXmlDataBinding;
27  
28  import java.util.List;
29  import java.util.Map;
30  
31  
32  /**
33   * Special factory for HL7 v3 Deferred Response senders.
34   * @author Dmytro Rud
35   */
36  public class Hl7v3DeferredResponderFactory extends JaxWsClientFactory<Hl7v3AuditDataset> {
37  
38      public Hl7v3DeferredResponderFactory(
39              Hl7v3WsTransactionConfiguration wsTransactionConfiguration,
40              String serviceUrl,
41              AuditStrategy<Hl7v3AuditDataset> auditStrategy,
42              AuditContext auditContext,
43              InterceptorProvider customInterceptors,
44              List<AbstractFeature> features,
45              Map<String, Object> properties)
46      {
47          super(wsTransactionConfiguration, serviceUrl, auditStrategy, auditContext,
48                  customInterceptors, features, properties, null);
49      }
50  
51  
52      @Override
53      protected void configureInterceptors(Client client) {
54          super.configureInterceptors(client);
55          client.getEndpoint().getService().setDataBinding(new PlainXmlDataBinding());
56  
57          if (auditStrategy != null) {
58              AuditResponseInterceptor<Hl7v3AuditDataset> auditInterceptor =
59                  new AuditResponseInterceptor<>(auditStrategy, auditContext, true, null, false);
60              client.getOutInterceptors().add(auditInterceptor);
61              client.getOutFaultInterceptors().add(auditInterceptor);
62          }
63      }
64  }