1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.core.model;
17
18 import org.apache.camel.spi.Metadata;
19 import org.apache.camel.spi.RouteContext;
20 import org.openehealth.ipf.commons.core.modules.api.Parser;
21 import org.openehealth.ipf.platform.camel.core.adapter.ParserAdapter;
22 import org.openehealth.ipf.platform.camel.core.adapter.ProcessorAdapter;
23
24 import javax.xml.bind.annotation.*;
25
26
27
28
29 @Metadata(label = "ipf,eip,transformation")
30 @XmlRootElement(name = "parse")
31 @XmlAccessorType(XmlAccessType.FIELD)
32 public class ParserAdapterDefinition extends ProcessorAdapterDefinition {
33
34 @XmlTransient
35 private Parser parser;
36 @XmlAttribute
37 private String parserBean;
38
39 public ParserAdapterDefinition() {
40 }
41
42 public ParserAdapterDefinition(Parser parser) {
43 this.parser = parser;
44 }
45
46 public ParserAdapterDefinition(String parserBean) {
47 this.parserBean = parserBean;
48 }
49
50 @Override
51 public String toString() {
52 return "ParserAdapter[" + getOutputs() + "]";
53 }
54
55 @Override
56 public String getShortName() {
57 return "parserAdapter";
58 }
59
60 @Override
61 protected ProcessorAdapter doCreateProcessor(RouteContext routeContext) {
62 if (parserBean != null) {
63 parser = routeContext.lookup(parserBean, Parser.class);
64 }
65 return new ParserAdapter(parser);
66 }
67
68 }