org.apache.camel.util.ObjectHelper Java Examples

The following examples show how to use org.apache.camel.util.ObjectHelper. 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: CamelCloudServiceFilterAutoConfiguration.java    From camel-spring-boot with 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 File: GoogleSheetsAddPivotTableCustomizer.java    From syndesis with 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 #3
Source File: AtomixClusterServiceAutoConfiguration.java    From camel-spring-boot with 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 #4
Source File: HeadersStepHandler.java    From syndesis with 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 #5
Source File: GoogleSheetsUpdateSpreadsheetCustomizer.java    From syndesis with 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 #6
Source File: RuntimeTest.java    From camel-k-runtime with 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 #7
Source File: FtpServerBean.java    From camelinaction2 with 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 #8
Source File: SourceLoader.java    From camel-k-runtime with 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 #9
Source File: file_s.java    From gumtree-spoon-ast-diff with 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 #10
Source File: file_t.java    From gumtree-spoon-ast-diff with 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 #11
Source File: DataMapperStepHandler.java    From syndesis with 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 #12
Source File: SourceLoader.java    From camel-k-runtime with 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 #13
Source File: FtpServerBean.java    From camelinaction2 with 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 #14
Source File: ActiveMQUtil.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static ActiveMQSslConnectionFactory createTlsConnectionFactory(String brokerUrl, String username, String password) {
    final ActiveMQSslConnectionFactory connectionFactory = new ActiveMQSslConnectionFactory(brokerUrl);
    if (! ObjectHelper.isEmpty(username)) {
        connectionFactory.setUserName(username);
        connectionFactory.setPassword(password);
    }
    return connectionFactory;
}
 
Example #15
Source File: SqsComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "aws-sqs-component")
@ConditionalOnMissingBean(SqsComponent.class)
public SqsComponent configureSqsComponent() throws Exception {
    SqsComponent component = new SqsComponent();
    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<SqsComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws-sqs.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.aws-sqs.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #16
Source File: IrcComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "irc-component")
@ConditionalOnMissingBean(IrcComponent.class)
public IrcComponent configureIrcComponent() throws Exception {
    IrcComponent component = new IrcComponent();
    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<IrcComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.irc.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.irc.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #17
Source File: UndertowComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "undertow-component")
@ConditionalOnMissingBean(UndertowComponent.class)
public UndertowComponent configureUndertowComponent() throws Exception {
    UndertowComponent component = new UndertowComponent();
    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<UndertowComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.undertow.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.undertow.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #18
Source File: DirectComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "direct-component")
@ConditionalOnMissingBean(DirectComponent.class)
public DirectComponent configureDirectComponent() throws Exception {
    DirectComponent component = new DirectComponent();
    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<DirectComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.direct.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.direct.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #19
Source File: IntegrationRouteBuilder.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private void loadFragments(Step step) {
    if (StepKind.extension != step.getStepKind()) {
        return;
    }

    final StepAction action = step.getActionAs(StepAction.class)
                                  .orElseThrow(() -> new IllegalArgumentException(
                                          String.format("Missing step action on step: %s - %s", step.getId(), step.getName())));

    if (action.getDescriptor().getKind() == StepAction.Kind.ENDPOINT) {
        final ModelCamelContext context = getContext();
        final String resource = action.getDescriptor().getResource();

        if (ObjectHelper.isNotEmpty(resource) && resources.add(resource)) {
            final Object instance = mandatoryLoadResource(context, resource);
            final RoutesDefinition definitions = mandatoryConvertToRoutesDefinition(resource, instance);

            LOGGER.debug("Resolved resource: {} as {}", resource, instance.getClass());

            try {
                context.addRouteDefinitions(definitions.getRoutes());
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        }
    }
}
 
Example #20
Source File: DJLComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "djl-component")
@ConditionalOnMissingBean(DJLComponent.class)
public DJLComponent configureDJLComponent() throws Exception {
    DJLComponent component = new DJLComponent();
    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<DJLComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.djl.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.djl.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #21
Source File: original.java    From gumtree-spoon-ast-diff with Apache License 2.0 5 votes vote down vote up
public boolean process(Exchange exchange, AsyncCallback callback) {
    final AtomicExchange result = new AtomicExchange();
    Iterable<ProcessorExchangePair> pairs = null;

    try {
        boolean sync = true;

        pairs = createProcessorExchangePairs(exchange);

        if (isParallelProcessing()) {
            // ensure an executor is set when running in parallel
            ObjectHelper.notNull(executorService, "executorService", this);
            doProcessParallel(exchange, result, pairs, isStreaming(), callback);
        } else {
            sync = doProcessSequential(exchange, result, pairs, callback);
        }

        if (!sync) {
            // the remainder of the multicast will be completed async
            // so we break out now, then the callback will be invoked which then continue routing from where we left here
            return false;
        }
    } catch (Throwable e) {
        exchange.setException(e);
        // unexpected exception was thrown, maybe from iterator etc. so do not regard as exhausted
        // and do the done work
        doDone(exchange, null, pairs, callback, true, false);
        return true;
    }

    // multicasting was processed successfully
    // and do the done work
    Exchange subExchange = result.get() != null ? result.get() : null;
    doDone(exchange, subExchange, pairs, callback, true, true);
    return true;
}
 
Example #22
Source File: GoogleSheetsMetadataAdapterTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void adaptForMetadataTest() throws IOException {
    CamelContext camelContext = new DefaultCamelContext();
    GoogleSheetsMetaDataExtension ext = new GoogleSheetsMetaDataExtension(camelContext);
    Map<String,Object> parameters = new HashMap<>();

    if (ObjectHelper.isNotEmpty(majorDimension)) {
        parameters.put("majorDimension", majorDimension);
    }

    if (split) {
        parameters.put("splitResults", true);
    }

    if (ObjectHelper.isNotEmpty(columnNames)) {
        parameters.put("columnNames", columnNames);
    }

    parameters.put("range", range);
    Optional<MetaData> metadata = ext.meta(parameters);
    assertTrue(metadata.isPresent());

    GoogleSheetsMetadataRetrieval adapter = new GoogleSheetsMetadataRetrieval();
    SyndesisMetadata syndesisMetaData = adapter.adapt(camelContext, "sheets", actionId, parameters, metadata.get());
    String expectedMetadata = IOUtils.toString(this.getClass().getResource(expectedJson), StandardCharsets.UTF_8).trim();
    ObjectWriter writer = JsonUtils.writer();
    String actualMetadata = writer.with(writer.getConfig().getDefaultPrettyPrinter()).writeValueAsString(syndesisMetaData);
    assertThatJson(actualMetadata).isEqualTo(expectedMetadata);
}
 
Example #23
Source File: WebsocketComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "websocket-component")
@ConditionalOnMissingBean(WebsocketComponent.class)
public WebsocketComponent configureWebsocketComponent() throws Exception {
    WebsocketComponent component = new WebsocketComponent();
    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<WebsocketComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.websocket.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.websocket.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #24
Source File: IPFSComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "ipfs-component")
@ConditionalOnMissingBean(IPFSComponent.class)
public IPFSComponent configureIPFSComponent() throws Exception {
    IPFSComponent component = new IPFSComponent();
    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<IPFSComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ipfs.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ipfs.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #25
Source File: HazelcastReplicatedmapComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "hazelcast-replicatedmap-component")
@ConditionalOnMissingBean(HazelcastReplicatedmapComponent.class)
public HazelcastReplicatedmapComponent configureHazelcastReplicatedmapComponent()
        throws Exception {
    HazelcastReplicatedmapComponent component = new HazelcastReplicatedmapComponent();
    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<HazelcastReplicatedmapComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.hazelcast-replicatedmap.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.hazelcast-replicatedmap.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #26
Source File: CinderComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "openstack-cinder-component")
@ConditionalOnMissingBean(CinderComponent.class)
public CinderComponent configureCinderComponent() throws Exception {
    CinderComponent component = new CinderComponent();
    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<CinderComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.openstack-cinder.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.openstack-cinder.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #27
Source File: GangliaComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "ganglia-component")
@ConditionalOnMissingBean(GangliaComponent.class)
public GangliaComponent configureGangliaComponent() throws Exception {
    GangliaComponent component = new GangliaComponent();
    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<GangliaComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ganglia.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.ganglia.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #28
Source File: GoogleSheetsStreamComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "google-sheets-stream-component")
@ConditionalOnMissingBean(GoogleSheetsStreamComponent.class)
public GoogleSheetsStreamComponent configureGoogleSheetsStreamComponent()
        throws Exception {
    GoogleSheetsStreamComponent component = new GoogleSheetsStreamComponent();
    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<GoogleSheetsStreamComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.google-sheets-stream.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.google-sheets-stream.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #29
Source File: WebsocketComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "atmosphere-websocket-component")
@ConditionalOnMissingBean(WebsocketComponent.class)
public WebsocketComponent configureWebsocketComponent() throws Exception {
    WebsocketComponent component = new WebsocketComponent();
    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<WebsocketComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.atmosphere-websocket.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.atmosphere-websocket.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #30
Source File: CoAPComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean({"coap-component", "coap+tcp-component", "coaps-component", "coaps+tcp-component"})
@ConditionalOnMissingBean(CoAPComponent.class)
public CoAPComponent configureCoAPComponent() throws Exception {
    CoAPComponent component = new CoAPComponent();
    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<CoAPComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.coap.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.coap.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}