当前位置: 首页>>代码示例>>Java>>正文


Java IntrospectionSupport.setProperty方法代码示例

本文整理汇总了Java中org.apache.camel.util.IntrospectionSupport.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java IntrospectionSupport.setProperty方法的具体用法?Java IntrospectionSupport.setProperty怎么用?Java IntrospectionSupport.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.IntrospectionSupport的用法示例。


在下文中一共展示了IntrospectionSupport.setProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNewBaseComponent

import org.apache.camel.util.IntrospectionSupport; //导入方法依赖的package包/类
/**
 * Create the endpoint instance which either happens with a new base component
 * which has been pre-configured for this connector or we fallback and use
 * the default component in the camel context
 */
private Optional<Component> createNewBaseComponent() throws Exception {
    final String componentClass = definition.getComponent().getJavaType();
    final CamelContext context = getCamelContext();

    if (componentClass != null) {
        // configure component with extra options
        if (!options.isEmpty()) {
            // Get the list of options from the connector catalog that
            // are configured to target the endpoint
            Collection<String> endpointOptions = definition.getEndpointProperties().keySet();

            // Check if any of the option applies to the component, if not
            // there's no need to create a dedicated component.
            Collection<Map.Entry<String, Object>> entries = options.entrySet().stream()
                .filter(e -> !endpointOptions.contains(e.getKey()))
                .collect(Collectors.toList());

            if (!entries.isEmpty()) {
                // create a new instance of this base component
                final Class<Component> type = context.getClassResolver().resolveClass(componentClass, Component.class);
                final Component component = context.getInjector().newInstance(type);

                component.setCamelContext(context);

                for (Map.Entry<String, Object> entry : entries) {
                    String key = entry.getKey();
                    Object val = entry.getValue();

                    LOGGER.debug("Using component option: {}={}", key, val);

                    if (val instanceof String) {
                        val = getCamelContext().resolvePropertyPlaceholders((String) val);
                    }

                    IntrospectionSupport.setProperty(context, component, key, val);
                }

                return Optional.of(component);
            }
        }
    }

    return Optional.empty();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:50,代码来源:ComponentProxyComponent.java


注:本文中的org.apache.camel.util.IntrospectionSupport.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。