org.apache.camel.spi.Language Java Examples
The following examples show how to use
org.apache.camel.spi.Language.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonSimplePredicate.java From syndesis with Apache License 2.0 | 6 votes |
public JsonSimplePredicate(final String expression, final CamelContext context) { final Language language = ObjectHelper.notNull(context.resolveLanguage("simple"), "simple language"); final String ognlExpression = convertSimpleToOGNLForMaps(expression); predicate = language.createPredicate(expression); ognlPredicate = language.createPredicate(ognlExpression); final Registry registry = context.getRegistry(); final Set<ObjectMapper> mappers = registry.findByType(ObjectMapper.class); if (mappers.size() != 1) { mapper = MAPPER; } else { mapper = mappers.iterator().next(); } }
Example #2
Source File: CamelRegistryTest.java From camel-quarkus with Apache License 2.0 | 5 votes |
@Test public void testLookupCustomServices() { assertThat(registry.lookupByNameAndType("my-df", DataFormat.class)).isNotNull(); assertThat(registry.lookupByNameAndType("my-language", Language.class)).isNotNull(); assertThat(registry.lookupByNameAndType("my-component", Component.class)).isNotNull(); assertThat(registry.lookupByNameAndType("my-predicate", Predicate.class)).isNotNull(); assertThat(registry.lookupByNameAndType("my-processor", Processor.class)).isNotNull(); }
Example #3
Source File: LanguageTestCommand.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Override public Boolean executeTest(ITestConfig config, String language) throws Exception { logger.info("Getting Camel language: {}", language); Language lan = context.resolveLanguage(language); assertNotNull("Cannot get language with name: " + language, lan); logger.info("Found Camel language: {} instance: {} with className: {}", language, lan, lan.getClass()); return true; }
Example #4
Source File: CamelCloudServiceCallConfigurationAutoConfiguration.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Lazy @Bean(name = ServiceCallDefinitionConstants.DEFAULT_SERVICE_CALL_CONFIG_ID) @ConditionalOnMissingBean(name = ServiceCallDefinitionConstants.DEFAULT_SERVICE_CALL_CONFIG_ID) public ServiceCallConfigurationDefinition serviceCallConfiguration() throws Exception { final ServiceCallConfigurationDefinition definition = new ServiceCallConfigurationDefinition(); final CamelCloudConfigurationProperties.ServiceCall serviceCall = configurationProperties.getServiceCall(); ObjectHelper.ifNotEmpty(serviceCall.getComponent(), definition::setComponent); ObjectHelper.ifNotEmpty(serviceCall.getUri(), definition::setUri); ObjectHelper.ifNotEmpty(serviceCall.getServiceDiscovery(), definition::setServiceDiscoveryRef); ObjectHelper.ifNotEmpty(serviceCall.getServiceFilter(), definition::setServiceFilterRef); ObjectHelper.ifNotEmpty(serviceCall.getServiceChooser(), definition::setServiceChooserRef); ObjectHelper.ifNotEmpty(serviceCall.getLoadBalancer(), definition::setLoadBalancerRef); if (serviceCall.getLoadBalancer() == null && serviceCall.isDefaultLoadBalancer()) { definition.defaultLoadBalancer(); } final String expression = serviceCall.getExpression(); final String expressionLanguage = serviceCall.getExpressionLanguage(); if (ObjectHelper.isNotEmpty(expression) && ObjectHelper.isNotEmpty(expressionLanguage)) { Language language = camelContext.resolveLanguage(expressionLanguage); if (language == null) { throw new IllegalArgumentException("Unable to resolve language: " + expressionLanguage); } definition.setExpression(language.createExpression(expression)); } return definition; }
Example #5
Source File: SplitAction.java From syndesis-extensions with Apache License 2.0 | 5 votes |
@Override public Optional<ProcessorDefinition<?>> configure(CamelContext context, ProcessorDefinition<?> route, Map<String, Object> parameters) { String languageName = language; String expressionDefinition = expression; if (ObjectHelper.isEmpty(languageName) && ObjectHelper.isEmpty(expressionDefinition)) { route = route.split(Builder.body()); } else if (ObjectHelper.isNotEmpty(expressionDefinition)) { if (ObjectHelper.isEmpty(languageName)) { languageName = "simple"; } // A small hack until https://issues.apache.org/jira/browse/CAMEL-12079 // gets fixed so we can support the 'bean::method' annotation as done by // Function step definition if ("bean".equals(languageName) && expressionDefinition.contains("::")) { expressionDefinition = expressionDefinition.replace("::", "?method="); } final Language splitLanguage = context.resolveLanguage(languageName); final Expression splitExpression = splitLanguage.createExpression(expressionDefinition); route = route.split(splitExpression).aggregationStrategy(new UseOriginalAggregationStrategy(null, false)); } return Optional.of(route); }
Example #6
Source File: SplitStepHandler.java From syndesis with Apache License 2.0 | 5 votes |
@SuppressWarnings({"PMD.AvoidReassigningParameters", "PMD.AvoidDeeplyNestedIfStmts"}) @Override public Optional<ProcessorDefinition<?>> handle(Step step, ProcessorDefinition<?> route, IntegrationRouteBuilder builder, String flowIndex, String stepIndex) { ObjectHelper.notNull(route, "route"); SplitExpression splitExpression; String languageName = step.getConfiguredProperties().get("language"); String expressionDefinition = step.getConfiguredProperties().get("expression"); if (step.hasUnifiedJsonSchemaOutputShape()) { // we have to split the nested unified body property by default. splitExpression = new SplitExpression(new UnifiedJsonBodyExpression(Builder.body())); } else if (ObjectHelper.isNotEmpty(expressionDefinition)) { if (ObjectHelper.isEmpty(languageName)) { languageName = "simple"; } // A small hack until https://issues.apache.org/jira/browse/CAMEL-12079 // gets fixed so we can support the 'bean::method' annotation as done by // Function step definition if ("bean".equals(languageName) && expressionDefinition.contains("::")) { expressionDefinition = expressionDefinition.replace("::", "?method="); } final Language language = builder.getContext().resolveLanguage(languageName); splitExpression = new SplitExpression(language.createExpression(expressionDefinition)); } else { splitExpression = new SplitExpression(Builder.body()); } AggregateStepHandler.AggregationOption aggregation = Optional.ofNullable(step.getConfiguredProperties().get("aggregationStrategy")) .map(AggregateStepHandler.AggregationOption::valueOf) .orElse(AggregateStepHandler.AggregationOption.body); route = route.split(splitExpression).aggregationStrategy(aggregation.getStrategy(step.getConfiguredProperties())); return Optional.of(route); }
Example #7
Source File: FunktionRouteBuilder.java From funktion-connectors with Apache License 2.0 | 5 votes |
protected Predicate getMandatoryPredicate(Step step, String expression, String language) { Objects.requireNonNull(expression, "No expression specified for step " + step); Language jsonpath = getLanguage(language); Predicate answer = jsonpath.createPredicate(expression); Objects.requireNonNull(answer, "No predicate created from: " + expression); return answer; }
Example #8
Source File: FunktionRouteBuilder.java From funktion-connectors with Apache License 2.0 | 5 votes |
protected Expression getMandatoryExpression(Step step, String expression, String language) { Objects.requireNonNull(expression, "No expression specified for step " + step); Language jsonpath = getLanguage(language); Expression answer = jsonpath.createExpression(expression); Objects.requireNonNull(answer, "No expression created from: " + expression); return answer; }
Example #9
Source File: FunktionRouteBuilder.java From funktion-connectors with Apache License 2.0 | 5 votes |
protected Language getLanguage(String language) { // use jsonpath as default String languageName = language != null && !language.isEmpty() ? language : "jsonpath"; Language answer = getContext().resolveLanguage(languageName); Objects.requireNonNull(answer, "The language `" + languageName + "` cound not be resolved!"); return answer; }
Example #10
Source File: CoreMainResource.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Path("/main/describe") @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject describeMain() { final ExtendedCamelContext camelContext = main.getCamelContext().adapt(ExtendedCamelContext.class); JsonArrayBuilder listeners = Json.createArrayBuilder(); main.getMainListeners().forEach(listener -> listeners.add(listener.getClass().getName())); JsonArrayBuilder routeBuilders = Json.createArrayBuilder(); main.configure().getRoutesBuilders().forEach(builder -> routeBuilders.add(builder.getClass().getName())); JsonArrayBuilder routes = Json.createArrayBuilder(); camelContext.getRoutes().forEach(route -> routes.add(route.getId())); JsonObjectBuilder collector = Json.createObjectBuilder(); collector.add("type", main.getRoutesCollector().getClass().getName()); if (main.getRoutesCollector() instanceof CamelMainRoutesCollector) { CamelMainRoutesCollector crc = (CamelMainRoutesCollector) main.getRoutesCollector(); collector.add("type-registry", crc.getRegistryRoutesLoader().getClass().getName()); collector.add("type-xml", crc.getXmlRoutesLoader().getClass().getName()); } JsonObjectBuilder dataformatsInRegistry = Json.createObjectBuilder(); camelContext.getRegistry().findByTypeWithName(DataFormat.class) .forEach((name, value) -> dataformatsInRegistry.add(name, value.getClass().getName())); JsonObjectBuilder languagesInRegistry = Json.createObjectBuilder(); camelContext.getRegistry().findByTypeWithName(Language.class) .forEach((name, value) -> languagesInRegistry.add(name, value.getClass().getName())); JsonObjectBuilder componentsInRegistry = Json.createObjectBuilder(); camelContext.getRegistry().findByTypeWithName(Component.class) .forEach((name, value) -> componentsInRegistry.add(name, value.getClass().getName())); JsonObjectBuilder factoryClassMap = Json.createObjectBuilder(); FactoryFinderResolver factoryFinderResolver = camelContext.getFactoryFinderResolver(); if (factoryFinderResolver instanceof FastFactoryFinderResolver) { ((FastFactoryFinderResolver) factoryFinderResolver).getClassMap().forEach((k, v) -> { factoryClassMap.add(k, v.getName()); }); } return Json.createObjectBuilder() .add("xml-loader", camelContext.getXMLRoutesDefinitionLoader().getClass().getName()) .add("xml-model-dumper", camelContext.getModelToXMLDumper().getClass().getName()) .add("routes-collector", collector) .add("listeners", listeners) .add("routeBuilders", routeBuilders) .add("routes", routes) .add("lru-cache-factory", LRUCacheFactory.getInstance().getClass().getName()) .add("autoConfigurationLogSummary", main.getMainConfigurationProperties().isAutoConfigurationLogSummary()) .add("config", Json.createObjectBuilder() .add("rest-port", camelContext.getRestConfiguration().getPort()) .add("resilience4j-sliding-window-size", camelContext.adapt(ModelCamelContext.class) .getResilience4jConfiguration(null) .getSlidingWindowSize())) .add("registry", Json.createObjectBuilder() .add("components", componentsInRegistry) .add("dataformats", dataformatsInRegistry) .add("languages", languagesInRegistry)) .add("factory-finder", Json.createObjectBuilder() .add("class-map", factoryClassMap)) .build(); }