/** * Parses the event type if the key matches the given prefix which is stripped off and * the configuration and remaining text is returned */ protected Pair<EventTypeConfiguration, String> parseEventType(String key, String prefix) { if (key.startsWith(prefix)) { String next = key.substring(prefix.length()); // now lets parse the next eventType int idx = next.indexOf('.'); if (idx > 0) { String eventText = next.substring(0, idx); String remaining = next.substring(idx + 1); EventType eventType = EventType.simpleNames.get(eventText); if (eventType == null) { LOG.warn("Invalid EventType: " + eventText + " when parsing " + key); } else { EventTypeConfiguration config = getConfig(eventType); if (config == null) { LOG.warn("Could not find an EventTypeConfiguration for eventType: " + eventType); } else { return new Pair<EventTypeConfiguration, String>(config, remaining); } } } } return null; }
if (configAndRemaining != null) { if (matchesCamelContextService(camelContextService, configAndRemaining.getSecond())) { configAndRemaining.getFirst().configureEventFlag(value); if (configAndRemaining != null) { Pair<Predicate, String> languageAndRemaining = parsePredicateAndRemaining(camelContextService, configAndRemaining.getSecond(), value); if (languageAndRemaining != null) { if (matchesCamelContextService(camelContextService, languageAndRemaining.getSecond())) { configAndRemaining.getFirst().addFilter(languageAndRemaining.getFirst()); if (matchesCamelContextService(camelContextService, configAndRemaining.getSecond())) { configAndRemaining.getFirst().addEndpointIncludeRegexp(value);
/** * Parses a string of the form "languageName.remaining = expression" returning the Predicate and the remaining text */ protected Pair<Predicate, String> parsePredicateAndRemaining(CamelContextService camelContextService, String key, String expression) { // lets assume no dots in language names int idx = key.indexOf('.'); if (idx > 0) { String languageName = key.substring(0, idx); String remaining = key.substring(idx + 1); Language language = camelContextService.getCamelContext().resolveLanguage(languageName); if (languageName == null) { LOG.error("Could not resolve language '" + languageName + "' with expression '" + expression + "'"); } else { try { Predicate predicate = language.createPredicate(expression); if (predicate == null) { LOG.error("Could not create predicate for language " + language + " and expression '" + expression + "'"); } else { return new Pair<Predicate, String>(predicate, remaining); } } catch (Exception e) { LOG.error("Failed to parse " + language + " expression '" + expression + "'. Reason: " + e); } } } return null; }