本文整理汇总了Java中org.apache.camel.RoutesBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RoutesBuilder类的具体用法?Java RoutesBuilder怎么用?Java RoutesBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RoutesBuilder类属于org.apache.camel包,在下文中一共展示了RoutesBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldDeployDefaultCamelContext
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
private boolean shouldDeployDefaultCamelContext(Set<Bean<?>> beans) {
return beans.stream()
// Is there a Camel bean with the @Default qualifier?
// Excluding internal components...
.filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
.filter(hasType(CamelContextAware.class).or(hasType(Component.class))
.or(hasType(RouteContainer.class).or(hasType(RoutesBuilder.class))))
.map(Bean::getQualifiers)
.flatMap(Set::stream)
.filter(isEqual(DEFAULT))
.findAny()
.isPresent()
// Or a bean with Camel annotations?
|| concat(camelBeans.stream().map(AnnotatedType::getFields),
camelBeans.stream().map(AnnotatedType::getMethods))
.flatMap(Set::stream)
.map(Annotated::getAnnotations)
.flatMap(Set::stream)
.filter(isAnnotationType(Consume.class).and(a -> ((Consume) a).context().isEmpty())
.or(isAnnotationType(BeanInject.class).and(a -> ((BeanInject) a).context().isEmpty()))
.or(isAnnotationType(EndpointInject.class).and(a -> ((EndpointInject) a).context().isEmpty()))
.or(isAnnotationType(Produce.class).and(a -> ((Produce) a).context().isEmpty()))
.or(isAnnotationType(PropertyInject.class).and(a -> ((PropertyInject) a).context().isEmpty())))
.findAny()
.isPresent()
// Or an injection point for Camel primitives?
|| beans.stream()
// Excluding internal components...
.filter(bean -> !bean.getBeanClass().getPackage().equals(getClass().getPackage()))
.map(Bean::getInjectionPoints)
.flatMap(Set::stream)
.filter(ip -> getRawType(ip.getType()).getName().startsWith("org.apache.camel"))
.map(InjectionPoint::getQualifiers)
.flatMap(Set::stream)
.filter(isAnnotationType(Uri.class).or(isAnnotationType(Mock.class)).or(isEqual(DEFAULT)))
.findAny()
.isPresent();
}
示例2: mapBeanRoutes
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
public static RoutesBuilder mapBeanRoutes(ServiceRepository serviceRepository,
Service service) {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
List<Method> methods = javaslang.collection.List.of(service.getConfiguration().getServiceClass().getDeclaredMethods());
// create an instance of the bean
Object beanToUse = service.getConfiguration().getTargetBean();
for (Method m : methods) {
if (Modifier.isPublic(m.getModifiers())) {
from("direct:" + formatBeanMethodRoute(m))
.bean(beanToUse, formatBeanEndpointRoute(m), true);
}
}
}
};
}
示例3: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from(MILO_SERVER_ITEM_1).to(MOCK_TEST_1);
from(MILO_SERVER_ITEM_2).to(MOCK_TEST_2);
from(DIRECT_START_1).to(MILO_CLIENT_ITEM_C1_1);
from(DIRECT_START_2).to(MILO_CLIENT_ITEM_C1_2);
from(DIRECT_START_3).to(MILO_CLIENT_ITEM_C2_1);
from(DIRECT_START_4).to(MILO_CLIENT_ITEM_C2_2);
}
};
}
示例4: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
initProperties();
from("direct:download-sent")
.to("isds:download?username={{isds.fo.login}}&password={{isds.fo.password}}&environment=test")
.log("done");
from("direct:download-received")
.to("isds:download?username={{isds.ovm.login}}&password={{isds.ovm.password}}" +
"&environment=test&downloadListMessages=true")
.log("done");
}
};
}
示例5: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
initProperties();
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("isds:messages?environment=test&username={{isds.ovm.login}}"
+ "&password={{isds.ovm.password}}"
+ "&consumer.delay=1s"
+ "&filter=!read")
.id(ROUTE_ID)
.autoStartup(false)
.log("new message in OVM inbox - id ${body.envelope.messageID}")
.to(mockEndpoint.getEndpointUri());
}
};
}
示例6: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
final Funktion funktion = createFunktion();
if (isDumpFlowYAML()) {
String fileNamePrefix = "target/funktion-tests/" + getClassNameAsPath() + "-" + getTestMethodName();
File file = new File(getBaseDir(), fileNamePrefix + ".yml");
file.getParentFile().mkdirs();
Funktions.saveConfig(funktion, file);
Funktions.saveConfigJSON(funktion, new File(getBaseDir(), fileNamePrefix + ".json"));
}
return new FunktionRouteBuilder() {
@Override
protected Funktion loadFunktion() throws IOException {
return funktion;
}
};
}
示例7: appendBuilders
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
/**
* Appends all the {@link org.apache.camel.builder.RouteBuilder} instances that can be found in the context
*/
public void appendBuilders(List<RoutesBuilder> list) {
Map<String, RoutesBuilder> beans = applicationContext.getBeansOfType(RoutesBuilder.class, includeNonSingletons, true);
for (Entry<String, RoutesBuilder> entry : beans.entrySet()) {
Object bean = entry.getValue();
Object key = entry.getKey();
LOG.trace("Found RouteBuilder with id: {} -> {}", key, bean);
// certain beans should be ignored
if (shouldIgnoreBean(bean)) {
LOG.debug("Ignoring RouteBuilder id: {}", key);
continue;
}
if (!isFilteredClass(bean)) {
LOG.debug("Ignoring filtered RouteBuilder id: {} as class: {}", key, bean.getClass());
continue;
}
LOG.debug("Adding instantiated RouteBuilder id: {} as class: {}", key, bean.getClass());
list.add((RoutesBuilder) bean);
}
}
示例8: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
private RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jetty:" + serviceEndpoint +
"?matchOnUriPrefix=true&optionsEnabled=true")
.routeId(SERVICE_ROUTE_ID)
.process(ex -> {
requestToService.copyFrom(ex.getIn());
if (processFromTest != null) {
processFromTest.process(ex);
} else {
ex.getOut().copyFrom(responseFromService);
}
});
}
};
}
示例9: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(deadLetterChannel("mock:dead"));
from("seda:start")
// the FTP server is not running and therefore we should get an exception
// and use 60s timeout
// and turn on aggregation on exception as we have turned on bridge error handler,
// so we want to run out custom aggregation strategy for exceptions as well
.pollEnrich(uri, 60000, new MyAggregationStrategy(), true)
.to("mock:result");
}
};
}
示例10: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("seda:a").routeId("start");
from("seda:a").routeId("a")
.log("routing at ${routeId}")
.recipientList(constant("seda:b,seda:c"))
.log("End of routing");
from("seda:b").routeId("b")
.log("routing at ${routeId}")
.delay(simple("${random(1000,2000)}"));
from("seda:c").routeId("c")
.log("routing at ${routeId}")
.delay(simple("${random(0,100)}"));
}
};
}
示例11: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("seda:a").routeId("start");
from("seda:a").routeId("a")
.log("routing at ${routeId}")
.multicast()
.to("seda:b")
.to("seda:c")
.end()
.log("End of routing");
from("seda:b").routeId("b")
.log("routing at ${routeId}")
.delay(simple("${random(1000,2000)}"));
from("seda:c").routeId("c")
.log("routing at ${routeId}")
.delay(simple("${random(0,100)}"));
}
};
}
示例12: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("seda:foo?concurrentConsumers=5").routeId("foo")
.log("routing at ${routeId}")
.delay(simple("${random(1000,2000)}"))
.to("seda:bar");
from("seda:bar?concurrentConsumers=5").routeId("bar")
.log("routing at ${routeId}")
.delay(simple("${random(0,500)}"));
}
};
}
示例13: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("seda:cat");
from("seda:cat").routeId("cat")
.log("routing at ${routeId}")
.delay(simple("${random(1000,2000)}"))
.setBody().constant("Cat says hello Dog")
.to("seda:dog");
from("seda:dog").routeId("dog")
.log("routing at ${routeId}")
.delay(simple("${random(0,500)}"))
.setBody().constant("Dog say hello Cat and Camel");
}
};
}
示例14: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("seda:a").routeId("start");
from("seda:a").routeId("a")
.log("routing at ${routeId}")
.to("seda:b")
.delay(2000)
.to("seda:c")
.log("End of routing");
from("seda:b").routeId("b")
.log("routing at ${routeId}")
.delay(simple("${random(1000,2000)}"));
from("seda:c").routeId("c")
.log("routing at ${routeId}")
.delay(simple("${random(0,100)}"));
}
};
}
示例15: createRouteBuilder
import org.apache.camel.RoutesBuilder; //导入依赖的package包/类
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").recipientList(constant("seda:a,seda:b,seda:c")).routeId("start");
from("seda:a").routeId("a")
.log("routing at ${routeId}");
from("seda:b").routeId("b")
.log("routing at ${routeId}")
.delay(simple("${random(1000,2000)}"));
from("seda:c").routeId("c")
.log("routing at ${routeId}")
.delay(simple("${random(0,100)}"));
}
};
}