本文整理匯總了Java中org.apache.camel.CamelContext類的典型用法代碼示例。如果您正苦於以下問題:Java CamelContext類的具體用法?Java CamelContext怎麽用?Java CamelContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CamelContext類屬於org.apache.camel包,在下文中一共展示了CamelContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFlowBeginProcessor
import org.apache.camel.CamelContext; //導入依賴的package包/類
private static FlowBeginProcessor createFlowBeginProcessor(RouteContext routeContext) {
CamelContext camelContext = routeContext.getCamelContext();
// Try to obtain a FlowBeginProcessor bean (its definition is optional)
FlowBeginProcessor processor = ContextUtils.beanOrNull(FlowBeginProcessor.class, camelContext);
if (processor != null) {
return processor;
}
// No FlowBeginProcessor bean found so let's create one. We need a
// - reference to a ReplayStrategyRegistry
// - reference to a FlowManager
processor = new FlowBeginProcessor();
processor.setCamelContext(camelContext);
processor.setFlowManager(ContextUtils.bean(FlowManager.class, camelContext));
processor.setRegistry(ContextUtils.bean(ReplayStrategyRegistry.class, camelContext));
return processor;
}
示例2: shouldMetadata
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Test
public void shouldMetadata() throws Exception {
final CamelContext context = new DefaultCamelContext();
context.addComponent("petstore", new PetstoreComponent(PAYLOAD));
try {
context.start();
final PetstoreAdapter adapter = new PetstoreAdapter(PAYLOAD, PROPERTIES, INPUT, OUTPUT);
final ActionDefinitionEndpoint endpoint = new ActionDefinitionEndpoint(context, "petstore", adapter);
final SyndesisMetadata<?> metadata = endpoint.definition("dog-food", Collections.emptyMap());
assertThat(metadata.properties).isSameAs(PROPERTIES);
assertThat(metadata.inputSchema).isSameAs(INPUT);
assertThat(metadata.outputSchema).isSameAs(OUTPUT);
} finally {
context.stop();
}
}
示例3: handle
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Override
public Optional<ProcessorDefinition> handle(Choice step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
final CamelContext context = routeBuilder.getContext();
final ChoiceDefinition choice = route.choice();
List<Filter> filters = ObjectHelper.supplyIfEmpty(step.getFilters(), Collections::<Filter>emptyList);
for (Filter filter : filters) {
Predicate predicate = JsonSimpleHelpers.getMandatorySimplePredicate(context, filter, filter.getExpression());
ChoiceDefinition when = choice.when(predicate);
routeBuilder.addSteps(when, filter.getSteps());
}
Otherwise otherwiseStep = step.getOtherwise();
if (otherwiseStep != null) {
List<Step> otherwiseSteps = ObjectHelper.supplyIfEmpty(otherwiseStep.getSteps(), Collections::<Step>emptyList);
if (!otherwiseSteps.isEmpty()) {
routeBuilder.addSteps(choice.otherwise(), otherwiseSteps);
}
}
return Optional.empty();
}
示例4: shouldWrapIntegersIntoCamelBodies
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Test
public void shouldWrapIntegersIntoCamelBodies(TestContext context) throws Exception {
Async async = context.async();
CamelSink<Integer> sink = new CamelSink<>(
new JsonObject().put("endpoint", "direct:test")
);
CamelContext camelContext = sink.camelContext();
camelContext.addRoutes(new RouteBuilder() {
@Override public void configure() throws Exception {
from("direct:test").process(event -> {
if (event.getIn().getBody(Integer.class) == 10) {
context.assertEquals(event.getIn().getBody(Integer.class), 10);
async.complete();
}
});
}
});
Source.from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).to(sink);
}
示例5: createCamelContext
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
// set up the component so the data source is built using
// test properties
SqlStoredStartConnectorComponent component = new SqlStoredStartConnectorComponent();
component.addOption("user", properties.getProperty("sql-connector.user"));
component.addOption("password", properties.getProperty("sql-connector.password"));
component.addOption("url", properties.getProperty("sql-connector.url"));
// bind the component to the camel context
context.addComponent("sql-stored-start-connector", component);
return context;
}
示例6: ping
import org.apache.camel.CamelContext; //導入依賴的package包/類
public void ping() throws Exception {
// need to create Camel
CamelContext camel = new DefaultCamelContext();
// get the connector to use
Component mention = camel.getComponent("salesforce-upsert-contact-connector");
Optional<ComponentVerifierExtension> ext = mention.getExtension(ComponentVerifierExtension.class);
// the connector must support ping check if its verifiable
if (ext.isPresent()) {
ComponentVerifierExtension verifier = ext.get();
Map<String, Object> parameters = loadParameters();
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
System.out.println("=============================================");
System.out.println("");
System.out.println("Ping check result: " + result.getStatus());
System.out.println("");
System.out.println("=============================================");
} else {
System.out.println("Component does not support ping check");
}
}
示例7: ping
import org.apache.camel.CamelContext; //導入依賴的package包/類
public void ping() throws Exception {
// need to create Camel
CamelContext camel = new DefaultCamelContext();
// get the connector to use
Component mention = camel.getComponent("twitter-mention-connector");
Optional<ComponentVerifierExtension> ext = mention.getExtension(ComponentVerifierExtension.class);
// the connector must support ping check if its verifiable
if (ext.isPresent()) {
ComponentVerifierExtension verifier = ext.get();
Map<String, Object> parameters = loadParameters();
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
System.out.println("=============================================");
System.out.println("");
System.out.println("Ping check result: " + result.getStatus());
System.out.println("");
System.out.println("=============================================");
} else {
System.out.println("Component does not support ping check");
}
}
示例8: ping
import org.apache.camel.CamelContext; //導入依賴的package包/類
public void ping() throws Exception {
// need to create Camel
CamelContext camel = new DefaultCamelContext();
// get the connector to use
Component get = camel.getComponent("http-get-connector");
Optional<ComponentVerifierExtension> ext = get.getExtension(ComponentVerifierExtension.class);
// the connector must support ping check if its verifiable
if (ext.isPresent()) {
ComponentVerifierExtension verifier = ext.get();
Map<String, Object> parameters = loadParameters();
ComponentVerifierExtension.Result result = verifier.verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters);
System.out.println("=============================================");
System.out.println("");
System.out.println("Ping check result: " + result.getStatus());
System.out.println("");
System.out.println("=============================================");
} else {
System.out.println("Component does not support ping check");
}
}
示例9: addClientSentTracing
import org.apache.camel.CamelContext; //導入依賴的package包/類
public static void addClientSentTracing(CamelContext ctx,
IDrinkWaterService service,
Method method,
Object body) {
if (service.getConfiguration().getIsTraceEnabled()) {
ctx.createProducerTemplate()
.sendBodyAndHeader(ROUTE_clientSentEvent, body,
BeanOperationName, Operation.of(method));
}
}
示例10: configureSalesforceGetSObjectComponent
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Lazy
@Bean(name = "salesforce-get-sobject-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
public SalesforceGetSObjectComponent configureSalesforceGetSObjectComponent()
throws Exception {
SalesforceGetSObjectComponent connector = new SalesforceGetSObjectComponent();
connector.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null,
false);
CamelPropertiesHelper.setCamelProperties(camelContext, connector,
parameters, false);
connector.setOptions(parameters);
if (ObjectHelper.isNotEmpty(customizers)) {
for (ConnectorCustomizer<SalesforceGetSObjectComponent> customizer : customizers) {
boolean useCustomizer = (customizer instanceof HasId)
? HierarchicalPropertiesEvaluator
.evaluate(
applicationContext.getEnvironment(),
"camel.connector.customizer",
"camel.connector.salesforce-get-sobject.customizer",
((HasId) customizer).getId())
: HierarchicalPropertiesEvaluator
.evaluate(applicationContext.getEnvironment(),
"camel.connector.customizer",
"camel.connector.salesforce-get-sobject.customizer");
if (useCustomizer) {
LOGGER.debug("Configure connector {}, with customizer {}",
connector, customizer);
customizer.customize(connector);
}
}
}
return connector;
}
示例11: createFlowEndProcessor
import org.apache.camel.CamelContext; //導入依賴的package包/類
private static FlowEndProcessor createFlowEndProcessor(RouteContext routeContext) {
CamelContext camelContext = routeContext.getCamelContext();
FlowEndProcessor processor = beanOrNull(FlowEndProcessor.class, camelContext);
if (processor != null) {
return processor;
}
processor = new FlowEndProcessor();
processor.setCamelContext(camelContext);
processor.setFlowManager(ContextUtils.bean(FlowManager.class, camelContext));
return processor;
}
示例12: verifierContext
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Bean(name = "verifier-context", initMethod = "start", destroyMethod = "stop")
public static CamelContext verifierContext() {
CamelContext context = new DefaultCamelContext();
context.setNameStrategy(new ExplicitCamelContextNameStrategy("verifier-context"));
context.disableJMX();
return context;
}
示例13: handle
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Override
public Optional<ProcessorDefinition> handle(Filter step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
CamelContext context = routeBuilder.getContext();
Predicate predicate = JsonSimpleHelpers.getMandatorySimplePredicate(context, step, step.getExpression());
FilterDefinition filter = route.filter(predicate);
routeBuilder.addSteps(filter, step.getSteps());
return Optional.empty();
}
示例14: handle
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Override
public Optional<ProcessorDefinition> handle(Split step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
CamelContext context = routeBuilder.getContext();
Expression expression = JsonSimpleHelpers.getMandatoryExpression(context, step, step.getExpression());
ProcessorDefinition split = route.split(expression).marshal().json(JsonLibrary.Jackson);
routeBuilder.addSteps(split, step.getSteps());
return Optional.empty();
}
示例15: handle
import org.apache.camel.CamelContext; //導入依賴的package包/類
@Override
public Optional<ProcessorDefinition> handle(Function step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
final CamelContext context = routeBuilder.getContext();
final TypeConverter converter = context.getTypeConverter();
String method = null;
String function = step.getName();
String options = null;
if (ObjectHelper.isEmpty(function)) {
return Optional.empty();
}
int idx = function.indexOf("::");
if (idx > 0 && !function.endsWith("::")) {
method = function.substring(idx + 2);
function = function.substring(0, idx);
}
Map<String, Object> headers = step.getProperties();
if (ObjectHelper.isNotEmpty(headers)) {
options = headers.entrySet().stream()
.filter(entry -> Objects.nonNull(entry.getValue()))
.map(entry -> asBeanParameter(converter, entry))
.collect(Collectors.joining("&"));
}
String uri = "class:" + function;
if (method != null) {
uri += "?method=" + method;
if (options != null){
uri += "&" + options;
}
} else if (options != null){
uri += "?" + options;
}
return Optional.of(route.to(uri));
}