本文整理汇总了Java中org.apache.camel.model.RouteDefinition.to方法的典型用法代码示例。如果您正苦于以下问题:Java RouteDefinition.to方法的具体用法?Java RouteDefinition.to怎么用?Java RouteDefinition.to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.model.RouteDefinition
的用法示例。
在下文中一共展示了RouteDefinition.to方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapHttpProxyRoutes
import org.apache.camel.model.RouteDefinition; //导入方法依赖的package包/类
public static RouteBuilder mapHttpProxyRoutes(DrinkWaterApplication app, Service service) {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
boolean useSessionManager = service.safeLookupProperty(Boolean.class, "useSessionManager:false", false);
String sessionManagerOption = useSessionManager? "&sessionSupport=true":"";
String frontEndpoint = service.lookupProperty("proxy.endpoint");
String destinationEndpoint = service.lookupProperty("destination.endpoint");
if (frontEndpoint == null || destinationEndpoint == null) {
throw new RuntimeException("could not find proxy and destination endpoint from config");
}
String handlers = getHandlersForJetty(service);
String handlersConfig = handlers == null ? "":"&handlers="+handlers;
addExceptionTracing(service, Exception.class, this);
RouteDefinition choice =
from("jetty:" + frontEndpoint + "?matchOnUriPrefix=true&enableMultipartFilter=false"
+ handlersConfig + sessionManagerOption);
choice = addServerReceivedTracing(service, choice);
choice = choice.to("jetty:" + destinationEndpoint + "?bridgeEndpoint=true&throwExceptionOnFailure=true");
addServerSentTracing(service, choice);
}
};
}
示例2: asRouteApiDefinition
import org.apache.camel.model.RouteDefinition; //导入方法依赖的package包/类
/**
* Transforms the rest api configuration into a {@link org.apache.camel.model.RouteDefinition} which
* Camel routing engine uses to service the rest api docs.
*/
public static RouteDefinition asRouteApiDefinition(CamelContext camelContext, RestConfiguration configuration) {
RouteDefinition answer = new RouteDefinition();
// create the from endpoint uri which is using the rest-api component
String from = "rest-api:" + configuration.getApiContextPath();
// append options
Map<String, Object> options = new HashMap<String, Object>();
String routeId = configuration.getApiContextRouteId();
if (routeId == null) {
routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
}
options.put("routeId", routeId);
if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
options.put("componentName", configuration.getComponent());
}
if (configuration.getApiContextIdPattern() != null) {
options.put("contextIdPattern", configuration.getApiContextIdPattern());
}
if (!options.isEmpty()) {
String query;
try {
query = URISupport.createQueryString(options);
} catch (URISyntaxException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
}
from = from + "?" + query;
}
// we use the same uri as the producer (so we have a little route for the rest api)
String to = from;
answer.fromRest(from);
answer.id(routeId);
answer.to(to);
return answer;
}
示例3: createRouteBuilder
import org.apache.camel.model.RouteDefinition; //导入方法依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
RouteDefinition route = from("direct:start");
for (int i = 0; i < 1000; i++) {
route = route.to("mock:" + i);
}
}
};
}
示例4: addMethodInvokedEndTrace
import org.apache.camel.model.RouteDefinition; //导入方法依赖的package包/类
public static void addMethodInvokedEndTrace(IDrinkWaterService service,
RouteDefinition routeDefinition){
if (service.getConfiguration().getIsTraceEnabled()) {
routeDefinition.to(ROUTE_MethodInvokedEndEvent);
}
}
示例5: configure
import org.apache.camel.model.RouteDefinition; //导入方法依赖的package包/类
@Override
public void configure() throws Exception {
int flowIndex = 0;
for (Flow flow : loadModel().getFlows()) {
getContext().setStreamCaching(true);
if (flow.isTraceEnabled()) {
getContext().setTracing(true);
}
String name = flow.getName();
if (Strings.isEmpty(name)) {
name = "flow" + (++flowIndex);
flow.setName(name);
}
List<Step> steps = flow.getSteps();
if (steps == null || steps.isEmpty()) {
throw new IllegalStateException("No valid steps! Invalid flow " + flow);
}
RouteDefinition route = null;
for (int i = 0; i < steps.size(); i++) {
Step step = steps.get(i);
if (i == 0 && !Endpoint.class.isInstance(step)) {
throw new IllegalStateException("No endpoint found as first step (found: " + step.getKind() + ")");
} else if (i == 0 && Endpoint.class.isInstance(step)) {
route = from(Endpoint.class.cast(step).getUri());
route.id(name);
} else {
addStep(route, step);
}
}
if (flow.isLogResultEnabled()) {
route.to("log:" + name + "?showStreams=true");
}
if (flow.isSingleMessageModeEnabled()) {
LOG.info("Enabling single message mode so that only one message is consumed for Design Mode");
getContext().addRoutePolicyFactory(new SingleMessageRoutePolicyFactory());
}
}
}
示例6: fromOrTo
import org.apache.camel.model.RouteDefinition; //导入方法依赖的package包/类
protected RouteDefinition fromOrTo(RouteDefinition route, String name, String uri, StringBuilder message) {
if (route == null) {
String trigger = uri;
if (Strings.isEmpty(trigger)) {
trigger = DEFAULT_TRIGGER_URL;
}
message.append(name);
message.append("() ");
if (trigger.equals("http")) {
trigger = DEFAULT_HTTP_ENDPOINT_PREFIX;
} else if (trigger.startsWith("http:") || trigger.startsWith("https:") ||
trigger.startsWith("http://") || trigger.startsWith("https://")) {
String host = getURIHost(trigger);
if (localHosts.contains(host)) {
trigger = DEFAULT_HTTP_ENDPOINT_PREFIX;
} else {
// lets add the HTTP endpoint prefix
// is there any context-path
String path = trigger.startsWith("https:") ? trigger.substring(6) : null;
if (path == null) {
path = trigger.startsWith("http:") ? trigger.substring(5) : null;
}
if (path == null) {
path = trigger.startsWith("https://") ? trigger.substring(8) : null;
}
if (path == null) {
path = trigger.startsWith("http://") ? trigger.substring(7) : null;
}
if (path != null) {
// keep only context path
if (path.contains("/")) {
path = path.substring(path.indexOf('/'));
}
}
if (path != null) {
trigger = path;
}
trigger = DEFAULT_HTTP_ENDPOINT_PREFIX + "/" + trigger;
}
}
route = from(trigger);
route.id(name);
} else {
uri = convertEndpointURI(uri);
message.append(" => ");
route.to(uri);
}
return route;
}