Camel
  1. Camel
  2. CAMEL-3547

Custom "absorbing" PropertyPlaceholderConfigurer

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.0
    • Fix Version/s: 2.10.0
    • Component/s: camel-spring
    • Labels:
      None

      Description

      I find Camel's property placeholder support clumsy. I already use Spring's PropertyPlaceholderConfigurer, and I feel like Camel should be able to harness that. I realize Spring doesn't make it easy to access those properties, but I have come up with a way to enable Camel to use them...

      By simply extending PropertyPlaceholderConfigurer, we will be able to intercept and absorb the properties that Spring has access to:

      {{
      import java.util.Properties;
      import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
      import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

      public class CamelPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
      private final Properties properties = new Properties();

      @Override
      protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)

      { super.processProperties(beanFactory, props); // "Absorb" all properties that pass through so we can expose them later properties.putAll(props); }

      /** Expose all absorbed properties */
      public final Properties getProperties()

      { return properties; }

      }
      }}

      It means users who want to take advantage of this would need to instantiate this instead of the stock PropertyPlaceholderConfigurer, but that's no problem:

      <bean class="org.apache.camel.impl.CamelPropertyPlaceholderConfigurer">
      <p:location="..."/>
      </bean>

      That way, you wouldn't need to declare a "duplicating" <propertyPlaceholer> in the CamelContext. What do you think, is this feasible?

        Activity

        Dan Checkoway created issue -
        Dan Checkoway made changes -
        Field Original Value New Value
        Description I find Camel's property placeholder support clumsy. I already use Spring's PropertyPlaceholderConfigurer, and I feel like Camel should be able to harness that. I realize Spring doesn't make it easy to access those properties, but I have come up with a way to enable Camel to use them...

        By simply extending PropertyPlaceholderConfigurer, we will be able to intercept and absorb the properties that Spring has access to:

        import java.util.Properties;
        import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
        import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

        public class CamelPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
            private final Properties properties = new Properties();
            
            @Override
            protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) {
                super.processProperties(beanFactory, props);
                // "Absorb" all properties that pass through so we can expose them later
                properties.putAll(props);
            }

            /** Expose all absorbed properties */
            public final Properties getProperties() {
                return properties;
            }
        }

        It means users who want to take advantage of this would need to instantiate this instead of the stock PropertyPlaceholderConfigurer, but that's no problem:

          <bean class="org.apache.camel.impl.CamelPropertyPlaceholderConfigurer">
            <p:location="..."/>
          </bean>

        That way, you wouldn't need to declare a "duplicating" <propertyPlaceholer> in the CamelContext. What do you think, is this feasible?
        I find Camel's property placeholder support clumsy. I already use Spring's PropertyPlaceholderConfigurer, and I feel like Camel should be able to harness that. I realize Spring doesn't make it easy to access those properties, but I have come up with a way to enable Camel to use them...

        By simply extending PropertyPlaceholderConfigurer, we will be able to intercept and absorb the properties that Spring has access to:

        {{
        import java.util.Properties;
        import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
        import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

        public class CamelPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
            private final Properties properties = new Properties();
            
            @Override
            protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) {
                super.processProperties(beanFactory, props);
                // "Absorb" all properties that pass through so we can expose them later
                properties.putAll(props);
            }

            /** Expose all absorbed properties */
            public final Properties getProperties() {
                return properties;
            }
        }
        }}

        It means users who want to take advantage of this would need to instantiate this instead of the stock PropertyPlaceholderConfigurer, but that's no problem:

          <bean class="org.apache.camel.impl.CamelPropertyPlaceholderConfigurer">
            <p:location="..."/>
          </bean>

        That way, you wouldn't need to declare a "duplicating" <propertyPlaceholer> in the CamelContext. What do you think, is this feasible?
        Claus Ibsen made changes -
        Issue Type Improvement [ 4 ] New Feature [ 2 ]
        Fix Version/s Future [ 12315692 ]
        Affects Version/s 2.5.0 [ 12315689 ]
        Component/s camel-spring [ 12313939 ]
        Component/s camel-core [ 12313938 ]
        Claus Ibsen made changes -
        Assignee Claus Ibsen [ davsclaus ]
        Claus Ibsen made changes -
        Fix Version/s 2.10.0 [ 12317612 ]
        Fix Version/s Future [ 12315692 ]
        Claus Ibsen made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Dan Checkoway
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development