private WordpressComponentConfiguration copyComponentProperties() throws Exception { Map<String, Object> componentProperties = new HashMap<>(); IntrospectionSupport.getProperties(configuration, componentProperties, null, false); // create endpoint configuration with component properties WordpressComponentConfiguration config = new WordpressComponentConfiguration(); IntrospectionSupport.setProperties(config, componentProperties); return config; } }
private FacebookEndpointConfiguration copyComponentProperties() throws Exception { Map<String, Object> componentProperties = new HashMap<>(); IntrospectionSupport.getProperties(configuration, componentProperties, null, false); // create endpoint configuration with component properties FacebookEndpointConfiguration config = new FacebookEndpointConfiguration(); IntrospectionSupport.setProperties(config, componentProperties); return config; }
@Bean(name = HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID) @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(name = HystrixConstants.DEFAULT_HYSTRIX_CONFIGURATION_ID) public HystrixConfigurationDefinition defaultHystrixConfigurationDefinition() throws Exception { Map<String, Object> properties = new HashMap<>(); IntrospectionSupport.getProperties(config, properties, null, false); HystrixConfigurationDefinition definition = new HystrixConfigurationDefinition(); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties); return definition; }
@Bean(name = "zookeeper-service-registry") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public ZooKeeperServiceRegistry zookeeperServiceRegistry(ZooKeeperServiceRegistryConfiguration configuration) throws Exception { ZooKeeperServiceRegistry service = new ZooKeeperServiceRegistry(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; } }
@Bean(name = "jgroups-lock-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService zookeeperClusterService() throws Exception { JGroupsLockClusterService service = new JGroupsLockClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; } }
@Bean(name = "zookeeper-cluster-service") @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) public CamelClusterService zookeeperClusterService() throws Exception { ZooKeeperClusterService service = new ZooKeeperClusterService(); IntrospectionSupport.setProperties( service, IntrospectionSupport.getNonNullProperties(configuration) ); return service; } }
@Lazy @Bean(name = "ribbon-load-balancer") @ConditionalOnClass(CamelContext.class) public ServiceLoadBalancer configureLoadBalancerFactory() throws Exception { RibbonServiceLoadBalancerFactory factory = new RibbonServiceLoadBalancerFactory(); IntrospectionSupport.setProperties( camelContext, camelContext.getTypeConverter(), factory, IntrospectionSupport.getNonNullProperties(configuration)); return factory.newInstance(camelContext); }
@PostConstruct public void postConstruct() { if (beanFactory != null) { Map<String, Object> parameters = new HashMap<>(); for (Map.Entry<String, RibbonServiceCallServiceLoadBalancerConfigurationCommon> entry : configuration.getConfigurations().entrySet()) { // clean up params parameters.clear(); // The instance factory RibbonServiceLoadBalancerFactory factory = new RibbonServiceLoadBalancerFactory(); try { IntrospectionSupport.getProperties(entry.getValue(), parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), factory, parameters); beanFactory.registerSingleton(entry.getKey(), factory.newInstance(camelContext)); } catch (Exception e) { throw new BeanCreationException(entry.getKey(), e.getMessage(), e); } } } }
@Lazy @Bean(name = "dns-service-discovery") @ConditionalOnClass(CamelContext.class) public ServiceDiscovery configureServiceDiscoveryFactory() throws Exception { DnsServiceDiscoveryFactory factory = new DnsServiceDiscoveryFactory(); IntrospectionSupport.setProperties( camelContext, camelContext.getTypeConverter(), factory, IntrospectionSupport.getNonNullProperties(configuration)); return factory.newInstance(camelContext); }
@PostConstruct public void postConstruct() { if (beanFactory == null) { return; } Map<String, Object> properties = new HashMap<>(); for (Map.Entry<String, HystrixConfigurationDefinitionCommon> entry : config.getConfigurations().entrySet()) { // clear the properties map for reuse properties.clear(); // extract properties IntrospectionSupport.getProperties(entry.getValue(), properties, null, false); try { HystrixConfigurationDefinition definition = new HystrixConfigurationDefinition(); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties); // Registry the definition beanFactory.registerSingleton(entry.getKey(), definition); } catch (Exception e) { throw new BeanCreationException(entry.getKey(), e); } } } }
null, false); Object nestedProperty = nestedClass.newInstance(); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component;
/** * Initializes the property placeholders by registering the {@link PropertiesComponent} with * the configuration from the given init parameters. */ private void initPropertyPlaceholder(ServletCamelContext camelContext, Map<String, Object> parameters) throws Exception { // setup property placeholder first Map<String, Object> properties = IntrospectionSupport.extractProperties(parameters, "propertyPlaceholder."); if (properties != null && !properties.isEmpty()) { PropertiesComponent pc = new PropertiesComponent(); IntrospectionSupport.setProperties(pc, properties); // validate we could set all parameters if (!properties.isEmpty()) { throw new IllegalArgumentException("Error setting propertyPlaceholder parameters on CamelContext." + " There are " + properties.size() + " unknown parameters. [" + properties + "]"); } // register the properties component camelContext.addComponent("properties", pc); } }
@PostConstruct public void postConstruct() { if (beanFactory != null) { Map<String, Object> parameters = new HashMap<>(); for (Map.Entry<String, DnsServiceCallServiceDiscoveryConfigurationCommon> entry : configuration.getConfigurations().entrySet()) { // clean up params parameters.clear(); // The instance factory DnsServiceDiscoveryFactory factory = new DnsServiceDiscoveryFactory(); try { IntrospectionSupport.getProperties(entry.getValue(), parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), factory, parameters); beanFactory.registerSingleton(entry.getKey(), factory.newInstance(camelContext)); } catch (Exception e) { throw new BeanCreationException(entry.getKey(), e.getMessage(), e); } } } }
null, false); Object nestedProperty = nestedClass.newInstance(); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component;
@Lazy @Bean @ConditionalOnMissingBean @ConditionalOnClass(CamelContext.class) public CamelReactiveStreamsService camelReactiveStreamsService() throws Exception { ReactiveStreamsEngineConfiguration engineConfiguration = new ReactiveStreamsEngineConfiguration(); if (configuration.getInternalEngineConfiguration() != null) { Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration.getInternalEngineConfiguration(), parameters, null, false); IntrospectionSupport.setProperties(context, context.getTypeConverter(), engineConfiguration, parameters); } return ReactiveStreamsHelper.resolveReactiveStreamsService(context, configuration.getServiceType(), engineConfiguration); }
@Override public void configureProperties(Map<String, Object> options) { super.configureProperties(options); // set configuration properties first try { if (config == null) { config = new WordpressComponentConfiguration(); } EndpointHelper.setReferenceProperties(getCamelContext(), config, options); EndpointHelper.setProperties(getCamelContext(), config, options); if (config.getSearchCriteria() == null) { final SearchCriteria searchCriteria = WordpressOperationType.valueOf(operation).getCriteriaType().newInstance(); Map<String, Object> criteriaOptions = IntrospectionSupport.extractProperties(options, "criteria."); // any property that has a "," should be a List criteriaOptions = criteriaOptions.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> { if (e != null && e.toString().indexOf(",") > -1) { return Arrays.asList(e.toString().split(",")); } return e.getValue(); })); IntrospectionSupport.setProperties(searchCriteria, criteriaOptions); config.setSearchCriteria(searchCriteria); } } catch (Exception e) { throw new IllegalArgumentException(e.getMessage(), e); } // validate configuration config.validate(); this.initServiceProvider(); }
@Override public Optional<ProcessorDefinition> handle(Extension step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) { final CamelContext context = routeBuilder.getContext(); final TypeConverter converter = context.getTypeConverter(); final String target = step.getName(); if (!Strings.isEmpty(target)) { try { final Class<SyndesisStepExtension> clazz = context.getClassResolver().resolveMandatoryClass(target, SyndesisStepExtension.class); final SyndesisStepExtension stepExtension = context.getInjector().newInstance(clazz); final Map<String, Object> props = new HashMap<>(step.getProperties()); try { IntrospectionSupport.setProperties(context, converter, stepExtension, props); } catch (Exception e) { throw new IllegalStateException(e); } return stepExtension.configure(context, route, props); } catch (ClassNotFoundException e) { throw new IllegalStateException(e); } } return Optional.of(route); } }
LOG.info("JMXAgent enabled"); DefaultManagementAgent agent = new DefaultManagementAgent(camelContext); IntrospectionSupport.setProperties(agent, properties);
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { NettyConfiguration config; if (configuration != null) { config = configuration.copy(); } else { config = new NettyConfiguration(); } config = parseConfiguration(config, remaining, parameters); // merge any custom bootstrap configuration on the config NettyServerBootstrapConfiguration bootstrapConfiguration = resolveAndRemoveReferenceParameter(parameters, "bootstrapConfiguration", NettyServerBootstrapConfiguration.class); if (bootstrapConfiguration != null) { Map<String, Object> options = new HashMap<>(); if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) { IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), config, options); } } if (config.getSslContextParameters() == null) { config.setSslContextParameters(retrieveGlobalSslContextParameters()); } // validate config config.validateConfiguration(); NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config); setProperties(nettyEndpoint.getConfiguration(), parameters); return nettyEndpoint; }
@Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { NettyConfiguration config; if (configuration != null) { config = configuration.copy(); } else { config = new NettyConfiguration(); } config = parseConfiguration(config, remaining, parameters); // merge any custom bootstrap configuration on the config NettyServerBootstrapConfiguration bootstrapConfiguration = resolveAndRemoveReferenceParameter(parameters, "bootstrapConfiguration", NettyServerBootstrapConfiguration.class); if (bootstrapConfiguration != null) { Map<String, Object> options = new HashMap<>(); if (IntrospectionSupport.getProperties(bootstrapConfiguration, options, null, false)) { IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), config, options); } } if (config.getSslContextParameters() == null) { config.setSslContextParameters(retrieveGlobalSslContextParameters()); } // validate config config.validateConfiguration(); NettyEndpoint nettyEndpoint = new NettyEndpoint(remaining, this, config); nettyEndpoint.setTimer(getTimer()); setProperties(nettyEndpoint.getConfiguration(), parameters); return nettyEndpoint; }