-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
ToDynamicDefinition.java
157 lines (132 loc) · 4.83 KB
/
ToDynamicDefinition.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.camel.ExchangePattern;
import org.apache.camel.spi.Metadata;
/**
* Sends the message to a dynamic endpoint
* <p/>
* You can specify multiple languages in the uri separated by the plus sign, such as <tt>mock:+language:xpath:/order/@uri</tt>
* where <tt>mock:</tt> would be a prefix to a xpath expression.
* <p/>
* For more dynamic behavior use <a href="http://camel.apache.org/recipient-list.html">Recipient List</a> or
* <a href="http://camel.apache.org/dynamic-router.html">Dynamic Router</a> EIP instead.
*/
@Metadata(label = "eip,endpoint,routing")
@XmlRootElement(name = "toD")
@XmlAccessorType(XmlAccessType.FIELD)
public class ToDynamicDefinition extends NoOutputDefinition<ToDynamicDefinition> {
@XmlAttribute @Metadata(required = true)
private String uri;
@XmlAttribute
private ExchangePattern pattern;
@XmlAttribute
private Integer cacheSize;
@XmlAttribute
private Boolean ignoreInvalidEndpoint;
@XmlAttribute @Metadata(defaultValue = "true")
private Boolean allowOptimisedComponents;
public ToDynamicDefinition() {
}
public ToDynamicDefinition(String uri) {
this.uri = uri;
}
@Override
public String getShortName() {
return "toD";
}
@Override
public String toString() {
return "DynamicTo[" + getLabel() + "]";
}
// Fluent API
// -------------------------------------------------------------------------
/**
* Sets the optional {@link ExchangePattern} used to invoke this endpoint
*/
public ToDynamicDefinition pattern(ExchangePattern pattern) {
setPattern(pattern);
return this;
}
/**
* Sets the maximum size used by the {@link org.apache.camel.spi.ConsumerCache} which is used to cache and reuse producers.
*
* @param cacheSize the cache size, use <tt>0</tt> for default cache size, or <tt>-1</tt> to turn cache off.
* @return the builder
*/
public ToDynamicDefinition cacheSize(int cacheSize) {
setCacheSize(cacheSize);
return this;
}
/**
* Ignore the invalidate endpoint exception when try to create a producer with that endpoint
*
* @return the builder
*/
public ToDynamicDefinition ignoreInvalidEndpoint() {
setIgnoreInvalidEndpoint(true);
return this;
}
/**
* Whether to allow components to optimise toD if they are {@link org.apache.camel.spi.SendDynamicAware}.
*
* @return the builder
*/
public ToDynamicDefinition allowOptimisedComponents(boolean allowOptimisedComponents) {
setAllowOptimisedComponents(allowOptimisedComponents);
return this;
}
// Properties
// -------------------------------------------------------------------------
public String getUri() {
return uri;
}
/**
* The uri of the endpoint to send to. The uri can be dynamic computed using the {@link org.apache.camel.language.simple.SimpleLanguage} expression.
*/
public void setUri(String uri) {
this.uri = uri;
}
public ExchangePattern getPattern() {
return pattern;
}
public void setPattern(ExchangePattern pattern) {
this.pattern = pattern;
}
public Integer getCacheSize() {
return cacheSize;
}
public void setCacheSize(Integer cacheSize) {
this.cacheSize = cacheSize;
}
public Boolean getIgnoreInvalidEndpoint() {
return ignoreInvalidEndpoint;
}
public void setIgnoreInvalidEndpoint(Boolean ignoreInvalidEndpoint) {
this.ignoreInvalidEndpoint = ignoreInvalidEndpoint;
}
public Boolean getAllowOptimisedComponents() {
return allowOptimisedComponents;
}
public void setAllowOptimisedComponents(Boolean allowOptimisedComponents) {
this.allowOptimisedComponents = allowOptimisedComponents;
}
}