Search in sources :

Example 1 with PropertiesComponent

use of org.apache.camel.spi.PropertiesComponent in project wildfly-camel by wildfly-extras.

the class DigitalOceanIntegrationTest method createCamelContext.

private CamelContext createCamelContext(String oauthToken) {
    CamelContext camelctx = new DefaultCamelContext();
    PropertiesComponent pc = camelctx.getPropertiesComponent();
    Properties properties = new Properties();
    properties.setProperty("oAuthToken", oauthToken);
    pc.setOverrideProperties(properties);
    return camelctx;
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) Properties(java.util.Properties) PropertiesComponent(org.apache.camel.spi.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 2 with PropertiesComponent

use of org.apache.camel.spi.PropertiesComponent in project camel-quarkus by apache.

the class FastCamelContext method createPropertiesComponent.

@Override
protected PropertiesComponent createPropertiesComponent() {
    org.apache.camel.component.properties.PropertiesComponent pc = new org.apache.camel.component.properties.PropertiesComponent();
    pc.setAutoDiscoverPropertiesSources(false);
    pc.addPropertiesSource(new CamelMicroProfilePropertiesSource());
    return pc;
}
Also used : CamelMicroProfilePropertiesSource(org.apache.camel.component.microprofile.config.CamelMicroProfilePropertiesSource) PropertiesComponent(org.apache.camel.spi.PropertiesComponent)

Example 3 with PropertiesComponent

use of org.apache.camel.spi.PropertiesComponent in project camel-spring-boot by apache.

the class JsonPathTransformONielPlaceholderTest method contextConfiguration.

@Bean
CamelContextConfiguration contextConfiguration() {
    return new CamelContextConfiguration() {

        @Override
        public void beforeApplicationStart(CamelContext context) {
            PropertiesComponent pc = context.getPropertiesComponent();
            Properties props = new Properties();
            props.put("who", "John O'Niel");
            props.put("search", "Sword's of Honour");
            pc.setInitialProperties(props);
        }

        @Override
        public void afterApplicationStart(CamelContext camelContext) {
        // do nothing here
        }
    };
}
Also used : CamelContext(org.apache.camel.CamelContext) CamelContextConfiguration(org.apache.camel.spring.boot.CamelContextConfiguration) Properties(java.util.Properties) PropertiesComponent(org.apache.camel.spi.PropertiesComponent) Bean(org.springframework.context.annotation.Bean)

Example 4 with PropertiesComponent

use of org.apache.camel.spi.PropertiesComponent in project camel-k-runtime by apache.

the class PropertiesSupport method bindProperties.

public static <T> T bindProperties(CamelContext context, T target, Predicate<String> filter, String prefix, boolean stripPrefix) {
    final PropertiesComponent component = context.getPropertiesComponent();
    final Properties propertiesWithPrefix = component.loadProperties(filter);
    final Map<String, Object> properties = new HashMap<>();
    propertiesWithPrefix.stringPropertyNames().forEach(name -> properties.put(stripPrefix ? name.substring(prefix.length()) : name, propertiesWithPrefix.getProperty(name)));
    PropertyConfigurer configurer = null;
    if (target instanceof Component) {
        // the component needs to be initialized to have the configurer ready
        ServiceHelper.initService(target);
        configurer = ((Component) target).getComponentPropertyConfigurer();
    }
    if (configurer == null) {
        String name = target.getClass().getName();
        if (target instanceof ExtendedCamelContext) {
            // special for camel context itself as we have an extended configurer
            name = ExtendedCamelContext.class.getName();
        }
        // see if there is a configurer for it
        configurer = context.adapt(ExtendedCamelContext.class).getConfigurerResolver().resolvePropertyConfigurer(name, context);
    }
    PropertyBindingSupport.build().withIgnoreCase(true).withCamelContext(context).withTarget(target).withProperties(properties).withRemoveParameters(true).withOptionPrefix(stripPrefix ? null : prefix).withConfigurer(configurer).bind();
    return target;
}
Also used : HashMap(java.util.HashMap) ExtendedCamelContext(org.apache.camel.ExtendedCamelContext) PropertyConfigurer(org.apache.camel.spi.PropertyConfigurer) Properties(java.util.Properties) PropertiesComponent(org.apache.camel.spi.PropertiesComponent) Component(org.apache.camel.Component) PropertiesComponent(org.apache.camel.spi.PropertiesComponent)

Example 5 with PropertiesComponent

use of org.apache.camel.spi.PropertiesComponent in project syndesis by syndesisio.

the class RestSwaggerConnectorIntegrationTest method createRouteBuilder.

private RouteBuilder createRouteBuilder() {
    return new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class)) {

        {
            setContext(createContext());
        }

        @Override
        public void configure() throws Exception {
            errorHandler(defaultErrorHandler().maximumRedeliveries(1));
            super.configure();
        }

        private ModelCamelContext createContext() {
            final Properties properties = new Properties();
            properties.put("flow-3.rest-openapi-1.password", "supersecret");
            properties.put("flow-4.rest-openapi-1.accessToken", "access-token");
            properties.put("flow-6.rest-openapi-1.clientSecret", "client-secret");
            properties.put("flow-6.rest-openapi-1.accessToken", "access-token");
            properties.put("flow-6.rest-openapi-1.refreshToken", "refresh-token");
            properties.put("flow-7.rest-openapi-1.clientSecret", "client-secret");
            properties.put("flow-7.rest-openapi-1.accessToken", "access-token");
            properties.put("flow-7.rest-openapi-1.refreshToken", "refresh-token");
            properties.put("flow-8.rest-openapi-1.authenticationParameterValue", "supersecret");
            properties.put("flow-9.rest-openapi-1.authenticationParameterValue", "supersecret");
            properties.put("flow-10.rest-openapi-1.authenticationParameterValue", "supersecret");
            final ModelCamelContext leanContext = new DefaultCamelContext();
            final PropertiesComponent propertiesComponent = leanContext.getPropertiesComponent();
            propertiesComponent.setInitialProperties(properties);
            leanContext.disableJMX();
            return leanContext;
        }

        @Override
        protected Integration loadIntegration() {
            return createIntegration();
        }
    };
}
Also used : IntegrationStepHandler(io.syndesis.integration.runtime.IntegrationStepHandler) Properties(java.util.Properties) PropertiesComponent(org.apache.camel.spi.PropertiesComponent) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) IntegrationRouteBuilder(io.syndesis.integration.runtime.IntegrationRouteBuilder) ModelCamelContext(org.apache.camel.model.ModelCamelContext)

Aggregations

PropertiesComponent (org.apache.camel.spi.PropertiesComponent)5 Properties (java.util.Properties)4 CamelContext (org.apache.camel.CamelContext)2 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)2 IntegrationRouteBuilder (io.syndesis.integration.runtime.IntegrationRouteBuilder)1 IntegrationStepHandler (io.syndesis.integration.runtime.IntegrationStepHandler)1 HashMap (java.util.HashMap)1 Component (org.apache.camel.Component)1 ExtendedCamelContext (org.apache.camel.ExtendedCamelContext)1 CamelMicroProfilePropertiesSource (org.apache.camel.component.microprofile.config.CamelMicroProfilePropertiesSource)1 ModelCamelContext (org.apache.camel.model.ModelCamelContext)1 PropertyConfigurer (org.apache.camel.spi.PropertyConfigurer)1 CamelContextConfiguration (org.apache.camel.spring.boot.CamelContextConfiguration)1 Bean (org.springframework.context.annotation.Bean)1