View Javadoc
1   /*
2    * Copyright 2010 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.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.hl7v3.audit.Hl7v3AuditDataset;
23  import org.openehealth.ipf.commons.ihe.ws.JaxWsAsyncResponseServiceFactory;
24  import org.openehealth.ipf.commons.ihe.ws.correlation.AsynchronyCorrelator;
25  import org.openehealth.ipf.commons.ihe.ws.cxf.databinding.plainxml.PlainXmlDataBinding;
26  import org.openehealth.ipf.commons.ihe.ws.cxf.payload.InNamespaceMergeInterceptor;
27  import org.openehealth.ipf.commons.ihe.ws.cxf.payload.InPayloadExtractorInterceptor;
28  import org.openehealth.ipf.commons.ihe.ws.cxf.payload.InPayloadInjectorInterceptor;
29  
30  import static org.openehealth.ipf.commons.ihe.ws.cxf.payload.StringPayloadHolder.PayloadType.SOAP_BODY;
31  
32  /**
33   * Service factory for receivers of asynchronous XCPD responses.
34   * @author Dmytro Rud
35   */
36  public class Hl7v3AsyncResponseServiceFactory extends JaxWsAsyncResponseServiceFactory<Hl7v3AuditDataset> {
37  
38      /**
39       * Constructs the factory.
40       * @param wsTransactionConfiguration
41       *          the info about the service to produce.
42       * @param auditStrategy
43       *          the auditing strategy to use.
44       * @param serviceAddress
45       *          the address of the service that it should be published with.
46       * @param correlator
47       *          correlator for asynchronous interactions.
48       * @param customInterceptors
49       *          user-defined custom CXF interceptors.
50       */
51      public Hl7v3AsyncResponseServiceFactory(
52              Hl7v3WsTransactionConfiguration wsTransactionConfiguration,
53              String serviceAddress,
54              AuditStrategy<Hl7v3AuditDataset> auditStrategy,
55              AuditContext auditContext,
56              AsynchronyCorrelator<Hl7v3AuditDataset> correlator,
57              InterceptorProvider customInterceptors)
58      {
59          super(wsTransactionConfiguration, serviceAddress, auditStrategy, auditContext, customInterceptors, correlator);
60      }
61  
62      @Override
63      protected void configureInterceptors(ServerFactoryBean svrFactory) {
64          super.configureInterceptors(svrFactory);
65          svrFactory.getInInterceptors().add(new InPayloadExtractorInterceptor(SOAP_BODY));
66          svrFactory.getInInterceptors().add(new InNamespaceMergeInterceptor());
67          svrFactory.getInInterceptors().add(new InPayloadInjectorInterceptor(0));
68          svrFactory.setDataBinding(new PlainXmlDataBinding());
69      }
70  
71  }