You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Michele Olsen <mi...@gmail.com> on 2021/03/19 00:03:41 UTC

How to load all properties from CamelContext

Hi,
These 2 lines of code were working for me with Camel 2.22.0 to retrieve all
properties from a CamelContext:
PropertiesComponent p = (PropertiesComponent)
context.getComponent("properties",false)
return
p.getPropertiesResolver().resolveProperties(context,false,pro.getLocations())
After upgrading to Camel 3.8, I changed the PropertiesComponent import from
org.apache.camel.component.properties to org.apache.camel.spi, and I
changed those 2 lines of code to be
PropertiesComponent p = context.getPropertiesComponent()
return p.loadProperties()
However, this isnt working. p.loadProperties() is empty. I debugged into
the loadProperties function and I see that it has 3 sources, 2 are
BridgePropertyPlaceholderConfigurer and 1 is ClasspathPropertiesSource. The
2 BridgePropertyPlaceholderConfigurer have properties and
the ClasspathPropertiesSource doesn't. However when it goes to the line of
code that says
if(ps instanceof LoadablePropertiesSource), this isn't true
for BridgePropertyPlaceholderConfigurer so it skips those and does not load
those properties.
Does anyone have suggestions on how to load the properties using version
3.8.0?
If it helps, I didn't change my spring file when i did the upgrade from
2.22.0 to 3.8.0, it has
<bean id="propertyPlaceholder"
class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="locations">
<list>
..
</list>
</property>
</bean>
Thanks!

Re: How to load all properties from CamelContext

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah I took a look and yeah we should make that loadable. I created a ticket
https://issues.apache.org/jira/browse/CAMEL-16384

On Mon, Mar 22, 2021 at 3:59 PM Claus Ibsen <cl...@gmail.com> wrote:
>
> Hi
>
> BridgePropertyPlaceholderConfigurer is bridging to Spring, which has
> its own way of loading properties.
> Camel doesn't really know how Spring does that.
>
> So you can look at the spring api if and how you can get spring to
> return all its loaded properties.
>
>
>
> On Fri, Mar 19, 2021 at 1:04 AM Michele Olsen
> <mi...@gmail.com> wrote:
> >
> > Hi,
> > These 2 lines of code were working for me with Camel 2.22.0 to retrieve all
> > properties from a CamelContext:
> > PropertiesComponent p = (PropertiesComponent)
> > context.getComponent("properties",false)
> > return
> > p.getPropertiesResolver().resolveProperties(context,false,pro.getLocations())
> > After upgrading to Camel 3.8, I changed the PropertiesComponent import from
> > org.apache.camel.component.properties to org.apache.camel.spi, and I
> > changed those 2 lines of code to be
> > PropertiesComponent p = context.getPropertiesComponent()
> > return p.loadProperties()
> > However, this isnt working. p.loadProperties() is empty. I debugged into
> > the loadProperties function and I see that it has 3 sources, 2 are
> > BridgePropertyPlaceholderConfigurer and 1 is ClasspathPropertiesSource. The
> > 2 BridgePropertyPlaceholderConfigurer have properties and
> > the ClasspathPropertiesSource doesn't. However when it goes to the line of
> > code that says
> > if(ps instanceof LoadablePropertiesSource), this isn't true
> > for BridgePropertyPlaceholderConfigurer so it skips those and does not load
> > those properties.
> > Does anyone have suggestions on how to load the properties using version
> > 3.8.0?
> > If it helps, I didn't change my spring file when i did the upgrade from
> > 2.22.0 to 3.8.0, it has
> > <bean id="propertyPlaceholder"
> > class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
> > <property name="locations">
> > <list>
> > ..
> > </list>
> > </property>
> > </bean>
> > Thanks!
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: How to load all properties from CamelContext

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

BridgePropertyPlaceholderConfigurer is bridging to Spring, which has
its own way of loading properties.
Camel doesn't really know how Spring does that.

So you can look at the spring api if and how you can get spring to
return all its loaded properties.



On Fri, Mar 19, 2021 at 1:04 AM Michele Olsen
<mi...@gmail.com> wrote:
>
> Hi,
> These 2 lines of code were working for me with Camel 2.22.0 to retrieve all
> properties from a CamelContext:
> PropertiesComponent p = (PropertiesComponent)
> context.getComponent("properties",false)
> return
> p.getPropertiesResolver().resolveProperties(context,false,pro.getLocations())
> After upgrading to Camel 3.8, I changed the PropertiesComponent import from
> org.apache.camel.component.properties to org.apache.camel.spi, and I
> changed those 2 lines of code to be
> PropertiesComponent p = context.getPropertiesComponent()
> return p.loadProperties()
> However, this isnt working. p.loadProperties() is empty. I debugged into
> the loadProperties function and I see that it has 3 sources, 2 are
> BridgePropertyPlaceholderConfigurer and 1 is ClasspathPropertiesSource. The
> 2 BridgePropertyPlaceholderConfigurer have properties and
> the ClasspathPropertiesSource doesn't. However when it goes to the line of
> code that says
> if(ps instanceof LoadablePropertiesSource), this isn't true
> for BridgePropertyPlaceholderConfigurer so it skips those and does not load
> those properties.
> Does anyone have suggestions on how to load the properties using version
> 3.8.0?
> If it helps, I didn't change my spring file when i did the upgrade from
> 2.22.0 to 3.8.0, it has
> <bean id="propertyPlaceholder"
> class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
> <property name="locations">
> <list>
> ..
> </list>
> </property>
> </bean>
> Thanks!



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2