* @return A {@link PropertiesComponent Camel Component}.
*/
@SuppressWarnings("rawtypes")
private static PropertiesComponent camelProperties(final ApplicationContext applicationContext) {
ConfigurableEnvironment env = (ConfigurableEnvironment) applicationContext.getEnvironment();
final MutablePropertySources propertySources = env.getPropertySources();
List<String> names = new ArrayList<String>();
for (PropertySource<?> propertySource : propertySources) {
names.add(propertySource.getName());
}
PropertiesComponent properties = new PropertiesComponent(
names.toArray(new String[names.size()]));
properties.setPropertiesResolver(new PropertiesResolver() {
@Override
public Properties resolveProperties(final CamelContext context,
final boolean ignoreMissingLocation,
final String... names) throws Exception {
Properties properties = new Properties();
// Add in reverse order to preserve precedence.
for (int i = names.length - 1; i >= 0; i--) {
PropertySource<?> propertySource = propertySources.get(names[i]);
if (propertySource instanceof EnumerablePropertySource) {
String[] propertyNames = ((EnumerablePropertySource) propertySource).getPropertyNames();
for (String propertyName : propertyNames) {
properties.put(propertyName, propertySource.getProperty(propertyName));
}