View Javadoc
1   /*
2    * Copyright 2014 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.mllp.core;
17  
18  import org.apache.camel.component.mina2.Mina2Endpoint;
19  import org.openehealth.ipf.commons.ihe.hl7v2.audit.MllpAuditDataset;
20  import org.openehealth.ipf.platform.camel.ihe.core.Interceptor;
21  import org.openehealth.ipf.platform.camel.ihe.mllp.core.intercept.consumer.ConsumerDispatchingInterceptor;
22  import org.openehealth.ipf.platform.camel.ihe.mllp.core.intercept.consumer.ConsumerStringProcessingInterceptor;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * MLLP dispatching Camel endpoint.
29   *
30   * @author Dmytro Rud
31   */
32  public class MllpDispatchEndpoint extends MllpEndpoint<MllpDispatchEndpointConfiguration, MllpAuditDataset, MllpDispatchComponent> {
33  
34      public MllpDispatchEndpoint(
35              MllpDispatchComponent mllpComponent,
36              Mina2Endpoint wrappedEndpoint,
37              MllpDispatchEndpointConfiguration config) {
38          super(mllpComponent, wrappedEndpoint, config);
39      }
40  
41      @Override
42      public List<Interceptor> createInitialConsumerInterceptorChain() {
43          List<Interceptor> initialChain = new ArrayList<>();
44          initialChain.add(new ConsumerStringProcessingInterceptor());
45  
46          ConsumerDispatchingInterceptor dispatcher = getConfig().getDispatcher();
47          if (dispatcher != null) {
48              dispatcher.addTransactionRoutes(getConfig().getRoutes());
49          } else {
50              dispatcher = new ConsumerDispatchingInterceptor(getCamelContext(), getConfig().getRoutes());
51          }
52          initialChain.add(dispatcher);
53          return initialChain;
54      }
55  
56  
57      @Override
58      public List<Interceptor> createInitialProducerInterceptorChain() {
59          throw new IllegalStateException("No producer support for MLLP dispatch endpoints.");
60      }
61  
62  }