You can use a flat aries blueprint property placeholder backed with
ConfigAdmin or a file.
Is it what you want ?
Regards
JB
On 16/09/2021 15:46, Andrei Petru Mura wrote:
This definitely isn't a good option as I don't intend to make a difference
by the way in which I reference a variable.
Anyway, property-placeholder doesn't seem to me to be a good option as some
of the variables inside my cfg file are seen, some aren't. For example I
get this:
Error creating bean with name 'ftpClientFactory' defined in URL
[bundle://afa89085-51c4-4cb3-a419-afeccd70a35f_304.0:0/OSGI-INF/blueprint/spring-conf/spring-context.xml]:
Initialization of bean failed; nested exception is
org.springframework.beans.TypeMismatchException: Failed to convert property
value of type 'java.lang.String' to required type 'int' for property
'reconnectRetries'; nested exception is java.lang.NumberFormatException:
For input string: "{{reconnect.retries}}"
In the same spring context, another variable (which is present in the same
configuration file) is well referenced.
Thanks,
Andrei M.
On Thu, Sep 16, 2021 at 4:12 PM John Taylor <jtt77...@gmail.com> wrote:
Hi,
A single property-placeholder is only going to allow one backing
persistent-id.
You can instead create multiple property-placeholders with different ids,
e.g.
<cm:property-placeholder id="propertiesBean" persistent-id=">. . .
<cm:property-placeholder id="edigrid.cluster" persistent-id=" >. . .
see
https://stackoverflow.com/questions/50354932/how-to-use-multiple-property-placeholder-in-jboss-fuse-blueprint
Hope that helps.
-John
On Thu, Sep 16, 2021 at 7:58 AM Andrei Petru Mura <mapand...@gmail.com>
wrote:
Hi all,
I'm trying to migrate my camel routes from an older karaf using Spring-DM
to a newer one using Blueprint. For this, I intend to import my spring
XML
configuration in my blueprint XML file. The camel context is defined in
the
blueprint XML file.
Currently I'm stuck with a placeholder issue. I'm trying to import some
configuration properties from OSGI environment which are stored in a few
files under the ${karaf.home}/etc directory.
I tried many ways according to this documentation page (
https://camel.apache.org/components/2.x/properties-component.html), but
still not getting the functionality which I want.
On short, I want to be able to define in my XML files (blueprint, spring)
some default values for some properties, overriding them with the
configurations found in the configuration files from ${karaf.home}/etc/
and
be able to use them in in both blueprint XML and spring XML files.
Preferable by ${variableName}.
Currently, I did this:
Blueprint XML:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bean="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
xmlns:cm="
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
">
<cm:property-placeholder id="propertiesBean"
persistent-id="edigrid.persistence,edigrid.server.id
,edigrid.cluster,edigrid.ftpconfig,edigrid.reports">
<cm:default-properties>...</cm:default-properties>
</cm:property-placeholder>
...
<camelContext ...>
<route ...>
... accessing ${configVarHere1}
</route>
</camelContext>
</blueprint>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ctx="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<beans>
<bean id="bridgePropertyPlaceholder"
class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
</bean>
...accessing ${configVarHere2}
</beans>
</beans>
I get this kind of error (because of spring XML):
Failed to convert property value of type 'java.lang.String' to required
type 'int' for property 'configPropName'; nested exception is
java.lang.NumberFormatException: For input string: "${configProprName}"
after I get a few messages like:
The property placeholder processor for ${, } in bundle
bundleName/BundleVersion found an immutable Constructor Argument at
location Bean named beanName->Argument index -1 and value type null->.
This
may prevent properties, beans, or other items referenced by this
component
from being properly processed.
Any idea how I can solve my issue?
Thanks,
Mura Andrei