Java Code Examples for org.apache.camel.util.ObjectHelper

The following examples show how to use org.apache.camel.util.ObjectHelper. These examples are extracted from open source projects. 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 Project: camel-spring-boot   Author: apache   File: CamelCloudServiceFilterAutoConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
private CamelCloudServiceFilter createServiceFilter(CamelCloudConfigurationProperties.ServiceFilterConfiguration configuration) {
    BlacklistServiceFilter blacklist = new BlacklistServiceFilter();

    Map<String, List<String>> services = configuration.getBlacklist();
    for (Map.Entry<String, List<String>> entry : services.entrySet()) {
        for (String part : entry.getValue()) {
            String host = StringHelper.before(part, ":");
            String port = StringHelper.after(part, ":");

            if (ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port)) {
                blacklist.addServer(
                    DefaultServiceDefinition.builder()
                        .withName(entry.getKey())
                        .withHost(host)
                        .withPort(Integer.parseInt(port))
                        .build()
                );
            }
        }
    }

    return new CamelCloudServiceFilter(Arrays.asList(new HealthyServiceFilter(), blacklist));
}
 
Example #2
Source Project: camelinaction2   Author: camelinaction   File: FtpServerBean.java    License: Apache License 2.0 6 votes vote down vote up
public void initFtpServer() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();

    // setup user management to read our users.properties and use clear text passwords
    URL url = ObjectHelper.loadResourceAsURL("users.properties");
    UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), url, "admin");

    serverFactory.setUserManager(uman);

    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);
    serverFactory.setFileSystem(fsf);

    ListenerFactory factory = new ListenerFactory();
    factory.setPort(port);
    serverFactory.addListener("default", factory.createListener());

    ftpServer = serverFactory.createServer();
}
 
Example #3
Source Project: gumtree-spoon-ast-diff   Author: SpoonLabs   File: file_t.java    License: Apache License 2.0 6 votes vote down vote up
public void run() {
    LOG.trace("Aggregate on the fly task started for exchangeId: {}", original.getExchangeId());

    try {
        aggregateOnTheFly();
    } catch (Throwable e) {
        if (e instanceof Exception) {
            executionException.set((Exception) e);
        } else {
            executionException.set(ObjectHelper.wrapRuntimeCamelException(e));
        }
    } finally {
        // must signal we are done so the latch can open and let the other thread continue processing
        LOG.debug("Signaling we are done aggregating on the fly for exchangeId: {}", original.getExchangeId());
        LOG.trace("Aggregate on the fly task done for exchangeId: {}", original.getExchangeId());
        aggregationOnTheFlyDone.countDown();
    }
}
 
Example #4
Source Project: gumtree-spoon-ast-diff   Author: SpoonLabs   File: file_s.java    License: Apache License 2.0 6 votes vote down vote up
public void run() {
    LOG.trace("Aggregate on the fly task started for exchangeId: {}", original.getExchangeId());

    try {
        aggregateOnTheFly();
    } catch (Throwable e) {
        if (e instanceof Exception) {
            executionException.set((Exception) e);
        } else {
            executionException.set(ObjectHelper.wrapRuntimeCamelException(e));
        }
    } finally {
        // must signal we are done so the latch can open and let the other thread continue processing
        LOG.debug("Signaling we are done aggregating on the fly for exchangeId: {}", original.getExchangeId());
        LOG.trace("Aggregate on the fly task done for exchangeId: {}", original.getExchangeId());
        aggregationOnTheFlyDone.countDown();
    }
}
 
Example #5
Source Project: camelinaction2   Author: camelinaction   File: FtpServerBean.java    License: Apache License 2.0 6 votes vote down vote up
public static void initFtpServer() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();

    // setup user management to read our users.properties and use clear text passwords
    URL url = ObjectHelper.loadResourceAsURL("users.properties");
    UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), url, "admin");

    serverFactory.setUserManager(uman);

    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);
    serverFactory.setFileSystem(fsf);

    ListenerFactory factory = new ListenerFactory();
    factory.setPort(port);
    serverFactory.addListener("default", factory.createListener());

    ftpServer = serverFactory.createServer();
}
 
Example #6
Source Project: syndesis   Author: syndesisio   File: GoogleSheetsAddPivotTableCustomizer.java    License: Apache License 2.0 6 votes vote down vote up
private static void addValueGroups(PivotTable pivotTable, GooglePivotTable model) {
    List<PivotValue> values = new ArrayList<>();
    model.getValueGroups().forEach(group -> {
        PivotValue pivotValue = new PivotValue();
        pivotValue.setName(group.getName());

        if (ObjectHelper.isNotEmpty(group.getFormula())) {
            pivotValue.setFormula(group.getFormula());
            pivotValue.setSummarizeFunction("CUSTOM");
        } else {
            pivotValue.setSourceColumnOffset(CellCoordinate.fromCellId(group.getSourceColumn()).getColumnIndex());
            pivotValue.setSummarizeFunction(group.getFunction());
        }

        values.add(pivotValue);
    });

    if (ObjectHelper.isNotEmpty(values)) {
        pivotTable.setValues(values);
    }
}
 
Example #7
Source Project: syndesis   Author: syndesisio   File: HeadersStepHandler.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"PMD.AvoidReassigningParameters", "PMD.AvoidDeeplyNestedIfStmts"})
@Override
public Optional<ProcessorDefinition<?>> handle(Step step, final ProcessorDefinition<?> route, IntegrationRouteBuilder builder, String flowIndex, String stepIndex) {
    ObjectHelper.notNull(route, "route");

    final Map<String, String> props = step.getConfiguredProperties();
    final String action = props.getOrDefault("action", "set");

    if (ObjectHelper.equal(action, "set", true)) {
        props.entrySet().stream()
            .filter(e -> !"action".equalsIgnoreCase(e.getKey()))
            .forEach(e-> route.setHeader(e.getKey()).constant(e.getValue()));
    } else if (ObjectHelper.equal(action, "remove", true)) {
        props.entrySet().stream()
            .filter(e -> !"action".equalsIgnoreCase(e.getKey()))
            .forEach(e-> route.removeHeaders(e.getKey()));
    } else {
        throw new IllegalArgumentException("Unknown action:" + action);
    }

    return Optional.of(route);
}
 
Example #8
Source Project: syndesis   Author: syndesisio   File: GoogleSheetsUpdateSpreadsheetCustomizer.java    License: Apache License 2.0 6 votes vote down vote up
private SpreadsheetProperties getSpreadsheetProperties(List<String> fields) {
    SpreadsheetProperties spreadsheetProperties = new SpreadsheetProperties();

    if (ObjectHelper.isNotEmpty(title)) {
        spreadsheetProperties.setTitle(title);
        fields.add("title");
    }

    if (ObjectHelper.isNotEmpty(timeZone)) {
        spreadsheetProperties.setTimeZone(timeZone);
        fields.add("timeZone");
    }

    if (ObjectHelper.isNotEmpty(locale)) {
        spreadsheetProperties.setLocale(locale);
        fields.add("locale");
    }

    return spreadsheetProperties;
}
 
Example #9
Source Project: camel-k-runtime   Author: apache   File: RuntimeTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
void testLoadMultipleRoutes() throws Exception {
    runtime.addListener(new ContextConfigurer());
    runtime.addListener(RoutesConfigurer.forRoutes("classpath:r1.js", "classpath:r2.mytype?language=js"));
    runtime.addListener(Runtime.Phase.Started, r -> {
        CamelContext context = r.getCamelContext();
        List<Route> routes = context.getRoutes();

        assertThat(routes).hasSize(2);
        assertThat(routes).anyMatch(p -> ObjectHelper.equal("r1", p.getId()));
        assertThat(routes).anyMatch(p -> ObjectHelper.equal("r2", p.getId()));

        runtime.stop();
    });

    runtime.run();
}
 
Example #10
Source Project: syndesis   Author: syndesisio   File: DataMapperStepHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * In case atlas mapping definition contains Json typed source documents we need to make sure to convert those from list to Json array Strings before passing those
 * source documents to the mapper.
 */
private static void addJsonTypeSourceProcessor(ProcessorDefinition<?> route, List<Map<String, Object>> dataSources) {
    List<Map<String, Object>> sourceDocuments = dataSources.stream()
                                        .filter(s -> "SOURCE".equals(s.get("dataSourceType")))
                                        .collect(Collectors.toList());

    List<String> jsonTypeSourceIds = sourceDocuments.stream()
                                        .filter(s -> ATLASMAP_JSON_DATA_SOURCE.equals(s.get("jsonType")))
                                        .filter(s -> ObjectHelper.isNotEmpty(s.get("id")))
                                        .map(s -> s.get("id").toString())
                                        .collect(Collectors.toList());

    if (ObjectHelper.isNotEmpty(jsonTypeSourceIds)) {
        route.process(new JsonTypeSourceProcessor(jsonTypeSourceIds, sourceDocuments.size()));
    }
}
 
Example #11
Source Project: camel-k-runtime   Author: apache   File: SourceLoader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct an instance of {@link Result} for the given {@link RoutesBuilder}.
 */
static Result on(RoutesBuilder target) {
    ObjectHelper.notNull(target, "target");

    return new Result() {
        @Override
        public Optional<RoutesBuilder> builder() {
            return Optional.of(target);
        }

        @Override
        public Optional<Object> configuration() {
            return Optional.empty();
        }
    };
}
 
Example #12
Source Project: camel-spring-boot   Author: apache   File: AtomixClusterServiceAutoConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean(name = "atomix-cluster-service")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@ConditionalOnProperty(prefix = "camel.component.atomix.cluster.service", name = "mode", havingValue = "node")
public CamelClusterService atomixClusterService() {
    AtomixClusterService service = new AtomixClusterService();
    service.setNodes(configuration.getNodes().stream().map(Address::new).collect(Collectors.toList()));

    ObjectHelper.ifNotEmpty(configuration.isEphemeral(), service::setEphemeral);
    ObjectHelper.ifNotEmpty(configuration.getId(), service::setId);
    ObjectHelper.ifNotEmpty(configuration.getAddress(), service::setAddress);
    ObjectHelper.ifNotEmpty(configuration.getStoragePath(), service::setStoragePath);
    ObjectHelper.ifNotEmpty(configuration.getStorageLevel(), service::setStorageLevel);
    ObjectHelper.ifNotEmpty(configuration.getConfigurationUri(), service::setConfigurationUri);
    ObjectHelper.ifNotEmpty(configuration.getAttributes(), service::setAttributes);
    ObjectHelper.ifNotEmpty(configuration.getOrder(), service::setOrder);

    return service;
}
 
Example #13
Source Project: camel-k-runtime   Author: apache   File: SourceLoader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct an instance of {@link Result} by determining the type of hte given target object..
 */
static Result on(Object target) {
    ObjectHelper.notNull(target, "target");

    return new Result() {
        @Override
        public Optional<RoutesBuilder> builder() {
            return target instanceof RoutesBuilder
                ? Optional.of((RoutesBuilder)target)
                : Optional.empty();
        }

        @Override
        public Optional<Object> configuration() {
            return target instanceof RoutesBuilder
                ? Optional.empty()
                : Optional.of(target);
        }
    };
}
 
Example #14
Source Project: camel-spring-boot   Author: apache   File: EKS2ComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "aws2-eks-component")
@ConditionalOnMissingBean(EKS2Component.class)
public EKS2Component configureEKS2Component() throws Exception {
    EKS2Component component = new EKS2Component();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<EKS2Component> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws2-eks.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws2-eks.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #15
Source Project: camel-spring-boot   Author: apache   File: MetricsComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "metrics-component")
@ConditionalOnMissingBean(MetricsComponent.class)
public MetricsComponent configureMetricsComponent() throws Exception {
    MetricsComponent component = new MetricsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<MetricsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.metrics.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.metrics.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #16
Source Project: camel-spring-boot   Author: apache   File: Ses2ComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "aws2-ses-component")
@ConditionalOnMissingBean(Ses2Component.class)
public Ses2Component configureSes2Component() throws Exception {
    Ses2Component component = new Ses2Component();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<Ses2Component> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws2-ses.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws2-ses.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #17
@Lazy
@Bean(name = "kubernetes-config-maps-component")
@ConditionalOnMissingBean(KubernetesConfigMapsComponent.class)
public KubernetesConfigMapsComponent configureKubernetesConfigMapsComponent()
        throws Exception {
    KubernetesConfigMapsComponent component = new KubernetesConfigMapsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<KubernetesConfigMapsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.kubernetes-config-maps.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.kubernetes-config-maps.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #18
Source Project: camel-spring-boot   Author: apache   File: SchedulerComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "scheduler-component")
@ConditionalOnMissingBean(SchedulerComponent.class)
public SchedulerComponent configureSchedulerComponent() throws Exception {
    SchedulerComponent component = new SchedulerComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<SchedulerComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.scheduler.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.scheduler.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #19
Source Project: camel-spring-boot   Author: apache   File: MsvComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "msv-component")
@ConditionalOnMissingBean(MsvComponent.class)
public MsvComponent configureMsvComponent() throws Exception {
    MsvComponent component = new MsvComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<MsvComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.msv.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.msv.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #20
Source Project: camel-spring-boot   Author: apache   File: CxfRsComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "cxfrs-component")
@ConditionalOnMissingBean(CxfRsComponent.class)
public CxfRsComponent configureCxfRsComponent() throws Exception {
    CxfRsComponent component = new CxfRsComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<CxfRsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.cxfrs.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.cxfrs.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #21
Source Project: syndesis-extensions   Author: syndesisio   File: JsonMarshalAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
   public Optional<ProcessorDefinition<?>> configure(CamelContext context, ProcessorDefinition<?> route, Map<String, Object> parameters) {
	ObjectHelper.notNull(route, "route");
	ObjectHelper.notNull(kind, "kind");

	return Optional.of(route.marshal().json(JsonLibrary.valueOf(kind.toString())));
}
 
Example #22
Source Project: camel-spring-boot   Author: apache   File: ZooKeeperComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "zookeeper-component")
@ConditionalOnMissingBean(ZooKeeperComponent.class)
public ZooKeeperComponent configureZooKeeperComponent() throws Exception {
    ZooKeeperComponent component = new ZooKeeperComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<ZooKeeperComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.zookeeper.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.zookeeper.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #23
@Lazy
@Bean(name = "kubernetes-namespaces-component")
@ConditionalOnMissingBean(KubernetesNamespacesComponent.class)
public KubernetesNamespacesComponent configureKubernetesNamespacesComponent()
        throws Exception {
    KubernetesNamespacesComponent component = new KubernetesNamespacesComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<KubernetesNamespacesComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.kubernetes-namespaces.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.kubernetes-namespaces.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #24
Source Project: camel-spring-boot   Author: apache   File: TokenizeLanguageAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(name = "tokenize-language")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@ConditionalOnMissingBean(TokenizeLanguage.class)
public TokenizeLanguage configureTokenizeLanguage() throws Exception {
    TokenizeLanguage language = new TokenizeLanguage();
    if (CamelContextAware.class.isAssignableFrom(TokenizeLanguage.class)) {
        CamelContextAware contextAware = CamelContextAware.class
                .cast(language);
        if (contextAware != null) {
            contextAware.setCamelContext(camelContext);
        }
    }
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, language,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (LanguageCustomizer<TokenizeLanguage> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.language.customizer",
                            "camel.language.tokenize.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.language.customizer",
                            "camel.language.tokenize.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure language {}, with customizer {}",
                        language, customizer);
                customizer.customize(language);
            }
        }
    }
    return language;
}
 
Example #25
Source Project: camel-spring-boot   Author: apache   File: AS2ComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "as2-component")
@ConditionalOnMissingBean(AS2Component.class)
public AS2Component configureAS2Component() throws Exception {
    AS2Component component = new AS2Component();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<AS2Component> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.as2.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.as2.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #26
Source Project: syndesis   Author: syndesisio   File: AWSSQSPollMessageCustomizer.java    License: Apache License 2.0 5 votes vote down vote up
public void beforeConsumer(Exchange exchange) throws IOException {
    final Message in = exchange.getIn();
    final SQSMessage message = new SQSMessage();

    if (ObjectHelper.isNotEmpty(in.getBody())) {
        message.setMessage(in.getBody(String.class));
    }
    exchange.getIn().setBody(message);
}
 
Example #27
Source Project: camel-spring-boot   Author: apache   File: GraphqlComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "graphql-component")
@ConditionalOnMissingBean(GraphqlComponent.class)
public GraphqlComponent configureGraphqlComponent() throws Exception {
    GraphqlComponent component = new GraphqlComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<GraphqlComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.graphql.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.graphql.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #28
Source Project: syndesis   Author: syndesisio   File: ODataUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static KeyStore createKeyStore(Map<String, Object> options) throws GeneralSecurityException, IOException {
    String certContent = ConnectorOptions.extractOption(options, SERVER_CERTIFICATE);
    if (ObjectHelper.isEmpty(certContent)) {
        return KeyStoreHelper.defaultKeyStore();
    }

    return KeyStoreHelper.createKeyStoreWithCustomCertificate("odata", certContent);
}
 
Example #29
Source Project: camel-spring-boot   Author: apache   File: JSR356WebSocketComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "websocket-jsr356-component")
@ConditionalOnMissingBean(JSR356WebSocketComponent.class)
public JSR356WebSocketComponent configureJSR356WebSocketComponent()
        throws Exception {
    JSR356WebSocketComponent component = new JSR356WebSocketComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<JSR356WebSocketComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.websocket-jsr356.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.websocket-jsr356.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #30
Source Project: camel-spring-boot   Author: apache   File: StringTemplateComponentAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "string-template-component")
@ConditionalOnMissingBean(StringTemplateComponent.class)
public StringTemplateComponent configureStringTemplateComponent()
        throws Exception {
    StringTemplateComponent component = new StringTemplateComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<StringTemplateComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.string-template.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.string-template.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}