Package org.apache.camel.component.properties

Examples of org.apache.camel.component.properties.PropertiesComponent


        if (component == null) {
            // then fallback to lookup the component
            component = getRegistry().lookup("properties", Component.class);
        }
       
        PropertiesComponent pc = null;
        // Ensure that we don't create one if one is not really available.
        if (component != null) {
            // force component to be created and registered as a component
            pc = getComponent("properties", PropertiesComponent.class);
        }
View Full Code Here


            if (component == null) {
                throw new IllegalArgumentException("PropertiesComponent with name properties must be defined"
                        + " in CamelContext to support property placeholders.");
            }
            // force component to be created and registered as a component
            PropertiesComponent pc = getComponent("properties", PropertiesComponent.class);
            // the parser will throw exception if property key was not found
            String answer = pc.parseUri(text);
            log.debug("Resolved text: {} -> {}", text, answer);
            return answer;
        }

        // return original text as is
View Full Code Here

    }

    @Override
    protected CamelContext createCamelContext() throws Exception {
        CamelContext context = super.createCamelContext();
        context.addComponent("properties", new PropertiesComponent("ref:prop"));
        return context;
    }
View Full Code Here

        assertMockEndpointsSatisfied();
    }

    protected RouteBuilder createRouteBuilder() {
        // create the properties component
        PropertiesComponent pc = new PropertiesComponent();
        pc.setLocation("classpath:org/apache/camel/itest/osgi/core/properties/myproperties.properties");

        // add properties component to camel context
        context.addComponent("properties", pc);

        return new RouteBuilder() {
View Full Code Here

    @Override
    protected CamelContext createCamelContext() throws Exception {
        CamelContext context = super.createCamelContext();

        PropertiesComponent pc = new PropertiesComponent();
        pc.setLocation("classpath:org/apache/camel/component/properties/myproperties.properties");
        context.addComponent("properties", pc);

        return context;
    }
View Full Code Here

        // no language resolved
        return answer;
    }
   
    public String getPropertyPrefixToken() {
        PropertiesComponent pc = getPropertiesComponent();
       
        if (pc != null) {
            return pc.getPrefixToken();
        } else {
            return null;
        }
    }
View Full Code Here

            return null;
        }
    }
   
    public String getPropertySuffixToken() {
        PropertiesComponent pc = getPropertiesComponent();
       
        if (pc != null) {
            return pc.getSuffixToken();
        } else {
            return null;
        }
    }
View Full Code Here

    public String resolvePropertyPlaceholders(String text) throws Exception {
        // While it is more efficient to only do the lookup if we are sure we need the component,
        // with custom tokens, we cannot know if the URI contains a property or not without having
        // the component.  We also lose fail-fast behavior for the missing component with this change.
        PropertiesComponent pc = getPropertiesComponent();

        // Do not parse uris that are designated for the properties component as it will handle that itself
        if (text != null && !text.startsWith("properties:")) {
            // No component, assume default tokens.
            if (pc == null && text.contains(PropertiesComponent.DEFAULT_PREFIX_TOKEN)) {

                // try to lookup component, as we may be initializing CamelContext itself
                Component existing = lookupPropertiesComponent();
                if (existing != null) {
                    if (existing instanceof PropertiesComponent) {
                        pc = (PropertiesComponent) existing;
                    } else {
                        // properties component must be expected type
                        throw new IllegalArgumentException("Found properties component of type: " + existing.getClass() + " instead of expected: " + PropertiesComponent.class);
                    }
                }

                if (pc != null) {
                    // the parser will throw exception if property key was not found
                    String answer = pc.parseUri(text);
                    log.debug("Resolved text: {} -> {}", text, answer);
                    return answer;
                } else {
                    throw new IllegalArgumentException("PropertiesComponent with name properties must be defined"
                            + " in CamelContext to support property placeholders.");
                }
               
            // Component available, use actual tokens
            } else if (pc != null && text.contains(pc.getPrefixToken())) {
                // the parser will throw exception if property key was not found
                String answer = pc.parseUri(text);
                log.debug("Resolved text: {} -> {}", text, answer);
                return answer;
            }
        }
View Full Code Here

        }
    }

    protected Component lookupPropertiesComponent() {
        // no existing properties component so lookup and add as component if possible
        PropertiesComponent answer = (PropertiesComponent) hasComponent("properties");
        if (answer == null) {
            answer = getRegistry().lookup("properties", PropertiesComponent.class);
            if (answer != null) {
                addComponent("properties", answer);
            }
View Full Code Here

        JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
        // and set the master password
        jasypt.setPassword("secret");

        // create the properties component
        PropertiesComponent pc = new PropertiesComponent();
        pc.setLocation("classpath:org/apache/camel/component/jasypt/myproperties.properties");
        // and use the jasypt properties parser so we can decrypt values
        pc.setPropertiesParser(jasypt);

        // add properties component to camel context
        context.addComponent("properties", pc);
        // END SNIPPET: e1
View Full Code Here

TOP

Related Classes of org.apache.camel.component.properties.PropertiesComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.