Configuration Admin issue when sharing a config file for Spring beans/Camel routes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Configuration Admin issue when sharing a config file for Spring beans/Camel routes

catshout
Hi everyone,

I've written a bean that is leveraging a configuration file through Configuration Admin, see below the bean.xml file content

<?xml version="1.0" encoding="UTF-8"?>

<beans 
    xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
    xmlns:ctx="http://www.springframework.org/schema/context"
    xmlns:beans="http://www.springframework.org/schema/beans"
   	xmlns:jaxws="http://cxf.apache.org/jaxws"
	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
						http://www.springframework.org/schema/osgi
						http://www.springframework.org/schema/osgi/spring-osgi.xsd
						http://www.springframework.org/schema/osgi-compendium
						http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd">

	<bean id="Configuration" class="de.ag.cas.sib.eventprocessor.Configuration">
		<osgix:managed-properties persistent-id="sib" update-strategy="container-managed" />
		<property name="sib_event_topic" value="" />
	</bean>
</beans>

Furthermore I've created a blueprint route that is leveraging the same configuration file, see below the blueprint xml

<?xml version="1.0" encoding="UTF-8"?>

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
                               http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <cm:property-placeholder id="cmProps" persistent-id="sib">
        <cm:default-properties>
            <cm:property name="sib_event_url" value="" />
        </cm:default-properties>
    </cm:property-placeholder>

	<bean id="eventRetriever" class="de.ag.cas.sib.eventprocessor.EventRetriever" />

	<camelContext id="events" xmlns="http://camel.apache.org/schema/blueprint">

		<route id="StoreEvents">
			<from uri="eventadmin:de/ag/cas/sib" />
			<transacted id="StoreEvents_TX"/>
			<bean ref="eventRetriever" method="retrieve" />
			<setHeader headerName="CamelHttpMethod">
				<constant>POST</constant>
			</setHeader>
			<setHeader headerName="Content-Type">
				<constant>application/json</constant>
			</setHeader>
			<to uri="{{sib_event_url}}" />
			<log message="Route for event retrieval executed" />
		</route>

	</camelContext>

</blueprint>

Everythings works so far, but when I'm gonna to update the config file sip.properties in etc folder I'm getting this error

2015-08-16 17:25:43,179 | ERROR | Update: pid=sib) | configadmin                      | 6 - org.apache.felix.configadmin - 1.8.4 | Cannot use configuration sib for [org.osgi.service.cm.ManagedService, id=991, bundle=384/blueprint:file:/home/wbimb/apache-servicemix-6.0.0/deploy/SIBevents.xml]: No visibility to configuration bound to file:/home/wbimb/apache-servicemix-6.0.0/deploy/SIBEventProcessor.jar

The SIBEventProcessor.jar is the bean I've mentioned above.

For the error I've found this explanation

https://www.mail-archive.com/users@felix.apache.org/msg14351.html

But how can I realize this in my case as everything works declarative through setter/getter injection?

Any help is really appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Configuration Admin issue when sharing a config file for Spring beans/Camel routes

Achim Nierbeck
Hi,

a configuration via config admin can only be bound to one single service.
So what you are trying to achieve can actually not be done this way.
You'll need a service which is configured via config admin service and that
service you'll need to reference in your route.
You might use mvel scripting for it, for example.

regards, Achim

2015-08-16 17:34 GMT+02:00 catshout <[hidden email]>:

> Hi everyone,
>
> I've written a bean that is leveraging a configuration file through
> Configuration Admin, see below the bean.xml file content
>
>
>
> Furthermore I've created a blueprint route that is leveraging the same
> configuration file, see below the blueprint xml
>
>
>
> Everythings works so far, but when I'm gonna to update the config file
> sip.properties in etc folder I'm getting this error
>
> 2015-08-16 17:25:43,179 | ERROR | Update: pid=sib) | configadmin
> | 6 - org.apache.felix.configadmin - 1.8.4 | Cannot use configuration sib
> for [org.osgi.service.cm.ManagedService, id=991,
>
> bundle=384/blueprint:file:/home/wbimb/apache-servicemix-6.0.0/deploy/SIBevents.xml]:
> No visibility to configuration bound to
> file:/home/wbimb/apache-servicemix-6.0.0/deploy/SIBEventProcessor.jar
>
> The SIBEventProcessor.jar is the bean I've mentioned above.
>
> For the error I've found this explanation
>
> https://www.mail-archive.com/users@.../msg14351.html
> <https://www.mail-archive.com/users@.../msg14351.html>
>
> But how can I realize this in my case as everything works declarative
> through setter/getter injection?
>
> Any help is really appreciated.
>
>
>
> --
> View this message in context:
> http://servicemix.396122.n5.nabble.com/Configuration-Admin-issue-when-sharing-a-config-file-for-Spring-beans-Camel-routes-tp5722877.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master
Reply | Threaded
Open this post in threaded view
|

Re: Configuration Admin issue when sharing a config file for Spring beans/Camel routes

catshout
Many thanks, Achim.

I've created a configuration service in Java. The configuration variables within this service are dynamically updated with injection/setter methods. Accessing the configuration values from other beans/routes is now possible with service getter methods.

Anyway, adding a new configuration parameter requires always a Java code change.

Would it be possible so far to define all properties in one blueprint xml like

<?xml version="1.0" encoding="UTF-8"?>

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
                               http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <cm:property-placeholder id="cmProps" persistent-id="sib">
        <cm:default-properties>
            <cm:property name="sib_event_url" value="" />
        </cm:default-properties>
    </cm:property-placeholder>

</blueprint>

and access these properties from an other blueprint xml?

Best
- Gerald
Reply | Threaded
Open this post in threaded view
|

Re: Configuration Admin issue when sharing a config file for Spring beans/Camel routes

Achim Nierbeck
Hi Gerald,

afaik this isn't possible as you need a service.
But you always can access the configuration file itself via blueprint,
though the automatic update doesn't work for those anylonger.

regards, Achim


2015-08-17 12:51 GMT+02:00 catshout <[hidden email]>:

> Many thanks, Achim.
>
> I've created a configuration service in Java. The configuration variables
> within this service are dynamically updated with injection/setter methods.
> Accessing the configuration values from other beans/routes is now possible
> with service getter methods.
>
> Anyway, adding a new configuration parameter requires always a Java code
> change.
>
> Would it be possible so far to define all properties in one blueprint xml
> like
>
>
>
> and access these properties from an other blueprint xml?
>
> Best
> - Gerald
>
>
>
> --
> View this message in context:
> http://servicemix.396122.n5.nabble.com/Configuration-Admin-issue-when-sharing-a-config-file-for-Spring-beans-Camel-routes-tp5722877p5722882.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>



--

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master