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.platform.camel.ihe.hl7v3;
17  
18  import org.openehealth.ipf.commons.ihe.hl7v3.Hl7v3AsyncResponseServiceFactory;
19  import org.openehealth.ipf.commons.ihe.hl7v3.audit.Hl7v3AuditDataset;
20  import org.openehealth.ipf.commons.ihe.hl7v3.Hl7v3DeferredResponderFactory;
21  import org.openehealth.ipf.commons.ihe.hl7v3.Hl7v3WsTransactionConfiguration;
22  import org.openehealth.ipf.commons.ihe.ws.JaxWsClientFactory;
23  import org.openehealth.ipf.commons.ihe.ws.JaxWsServiceFactory;
24  import org.openehealth.ipf.commons.ihe.ws.WsInteractionId;
25  import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWebService;
26  import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsComponent;
27  import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsEndpoint;
28  import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsProducer;
29  
30  import java.util.Map;
31  
32  /**
33   * Camel endpoint implementation for asynchronous response
34   * receivers of HL7v3-based IHE components.
35   * @author Dmytro Rud
36   */
37  public class Hl7v3AsyncResponseEndpoint<ConfigType extends Hl7v3WsTransactionConfiguration>
38          extends AbstractWsEndpoint<Hl7v3AuditDataset, ConfigType> {
39  
40      public Hl7v3AsyncResponseEndpoint(
41              String endpointUri,
42              String address,
43              AbstractWsComponent<Hl7v3AuditDataset, ConfigType, ? extends WsInteractionId<ConfigType>> component,
44              Map<String, Object> parameters,
45              Class<? extends AbstractWebService> serviceClass) {
46          super(endpointUri, address, component, parameters, serviceClass);
47      }
48  
49      // currently is used for deferred response receivers only!
50      @Override
51      public JaxWsClientFactory<Hl7v3AuditDataset> getJaxWsClientFactory() {
52          return new Hl7v3DeferredResponderFactory(
53                  getComponent().getWsTransactionConfiguration(),
54                  getServiceUrl(),
55                  isAudit() ? getComponent().getServerAuditStrategy() : null,
56                  getAuditContext(),
57                  getCustomInterceptors(),
58                  getFeatures(),
59                  getProperties());
60      }
61  
62  
63      @Override
64      public JaxWsServiceFactory<Hl7v3AuditDataset> getJaxWsServiceFactory() {
65          return new Hl7v3AsyncResponseServiceFactory(
66                  getComponent().getWsTransactionConfiguration(),
67                  getServiceAddress(),
68                  isAudit() ? getComponent().getServerAuditStrategy() : null,
69                  getAuditContext(),
70                  getCorrelator(),
71                  getCustomInterceptors());
72      }
73  
74      @Override
75      public AbstractWsProducer<Hl7v3AuditDataset, ConfigType, ?, ?> getProducer(AbstractWsEndpoint<Hl7v3AuditDataset, ConfigType> endpoint,
76                                            JaxWsClientFactory<Hl7v3AuditDataset> clientFactory) {
77          throw new IllegalStateException("No producer support for asynchronous response endpoints");
78      }
79  }