| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.model; |
| 18 |
|
|
| 19 |
|
import javax.xml.bind.annotation.XmlAccessType; |
| 20 |
|
import javax.xml.bind.annotation.XmlAccessorType; |
| 21 |
|
import javax.xml.bind.annotation.XmlAttribute; |
| 22 |
|
import javax.xml.bind.annotation.XmlRootElement; |
| 23 |
|
import javax.xml.bind.annotation.XmlTransient; |
| 24 |
|
|
| 25 |
|
import org.apache.camel.Endpoint; |
| 26 |
|
import org.apache.camel.impl.RouteContext; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@XmlRootElement(name = "from") |
| 34 |
|
@XmlAccessorType(XmlAccessType.FIELD) |
| 35 |
|
public class FromType { |
| 36 |
|
@XmlAttribute |
| 37 |
|
private String uri; |
| 38 |
|
@XmlAttribute |
| 39 |
|
private String ref; |
| 40 |
|
@XmlTransient |
| 41 |
|
private Endpoint endpoint; |
| 42 |
|
|
| 43 |
33 |
public FromType() { |
| 44 |
33 |
} |
| 45 |
|
|
| 46 |
273 |
public FromType(String uri) { |
| 47 |
273 |
setUri(uri); |
| 48 |
273 |
} |
| 49 |
|
|
| 50 |
0 |
public FromType(Endpoint endpoint) { |
| 51 |
0 |
this.endpoint = endpoint; |
| 52 |
0 |
} |
| 53 |
|
|
| 54 |
|
@Override |
| 55 |
|
public String toString() { |
| 56 |
132 |
return "From[" + description(getUri(), getRef(), getEndpoint()) + "]"; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
public Endpoint resolveEndpoint(RouteContext context) { |
| 60 |
267 |
if (endpoint == null) { |
| 61 |
267 |
endpoint = context.resolveEndpoint(getUri(), getRef()); |
| 62 |
|
} |
| 63 |
267 |
return endpoint; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
public String getUri() { |
| 69 |
432 |
return uri; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
public void setUri(String uri) { |
| 78 |
273 |
this.uri = uri; |
| 79 |
273 |
} |
| 80 |
|
|
| 81 |
|
public String getRef() { |
| 82 |
399 |
return ref; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
public void setRef(String ref) { |
| 92 |
0 |
this.ref = ref; |
| 93 |
0 |
} |
| 94 |
|
|
| 95 |
|
public Endpoint getEndpoint() { |
| 96 |
132 |
return endpoint; |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
public void setEndpoint(Endpoint endpoint) { |
| 100 |
0 |
this.endpoint = endpoint; |
| 101 |
0 |
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
protected static String description(String uri, String ref, Endpoint endpoint) { |
| 106 |
327 |
if (endpoint != null) { |
| 107 |
0 |
return endpoint.getEndpointUri(); |
| 108 |
327 |
} else if (uri != null) { |
| 109 |
327 |
return uri; |
| 110 |
0 |
} else if (ref != null) { |
| 111 |
0 |
return "ref:" + ref; |
| 112 |
|
} else { |
| 113 |
0 |
return "no uri or ref supplied!"; |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
} |