001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.spi;
018
019import java.util.Properties;
020
021import org.apache.camel.Component;
022
023public interface PropertiesComponent extends Component {
024
025    /**
026     * The default prefix token.
027     */
028    String DEFAULT_PREFIX_TOKEN = "{{";
029
030    /**
031     * The default suffix token.
032     */
033    String DEFAULT_SUFFIX_TOKEN = "}}";
034
035    /**
036     * Has the component been created as a default by {@link org.apache.camel.CamelContext} during starting up Camel.
037     */
038    String DEFAULT_CREATED = "PropertiesComponentDefaultCreated";
039
040    String getPrefixToken();
041
042    String getSuffixToken();
043
044    /**
045     * Parses the input text and resolve all property placeholders.
046     *
047     * @param uri  input text
048     * @return text with resolved property placeholders
049     * @throws Exception is thrown if error during parsing
050     */
051    String parseUri(String uri) throws Exception;
052
053    /**
054     * Parses the input text and resolve all property placeholders.
055     *
056     * @param uri  input text
057     * @param locations locations to load as properties (will not use the default locations)
058     * @return text with resolved property placeholders
059     * @throws Exception is thrown if error during parsing
060     */
061    String parseUri(String uri, String... locations) throws Exception;
062
063    /**
064     * Loads the properties from the default locations.
065     *
066     * @return the properties loaded.
067     * @throws Exception is thrown if error loading properties
068     */
069    Properties loadProperties() throws Exception;
070
071    /**
072     * Loads the properties from the given locations
073     *
074     * @param locations locations to load as properties (will not use the default locations)
075     * @return the properties loaded.
076     * @throws Exception is thrown if error loading properties
077     */
078    Properties loadProperties(String... locations) throws Exception;
079
080    /**
081     * A list of locations to load properties. You can use comma to separate multiple locations.
082     * This option will override any default locations and only use the locations from this option.
083     */
084    void setLocation(String location);
085
086    /**
087     * Adds the list of locations to the current locations, where to load properties.
088     * You can use comma to separate multiple locations.
089     * This option will override any default locations and only use the locations from this option.
090     */
091    void addLocation(String location);
092
093    /**
094     * Whether to silently ignore if a location cannot be located, such as a properties file not found.
095     */
096    void setIgnoreMissingLocation(boolean ignoreMissingLocation);
097
098    /**
099     * Sets initial properties which will be added before any property locations are loaded.
100     */
101    void setInitialProperties(Properties initialProperties);
102
103    /**
104     * Sets a special list of override properties that take precedence
105     * and will use first, if a property exist.
106     */
107    void setOverrideProperties(Properties overrideProperties);
108
109}