karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Achim Nierbeck <bcanh...@googlemail.com>
Subject Re: Managed Properties question
Date Mon, 20 Dec 2010 17:00:22 GMT
OK, another try

<bean id="containerManaged" class="ContainerManagedBean">
   <osgix:managed-properties persistent-id="labX"
update-strategy="container-managed"/>
   <property name="integer" value="23"/>
</bean>

this is the official example :)

I think the property (named integer here) is optional. Usually all
properties which can be read through getter and setter can be set by
the configuration.

So your problem is that you try to inject properties within another property

<property name="hibernateProperties">
   <props>
    <prop key="hibernate.show_sql">${myAppDbShowSql}</prop>
    <prop key="hibernate.format_sql">${myAppDbFormatSql}</prop>
   </props>
  </property>

All your properties you want to update need to be accessible via
getter and setter.
If you want to do this you need to make an extra bean which is
configurable (with the same pid)
and inject that one after it is initialized. you may want to make your
standard bean dependend on the "new" bean.

2010/12/20 karafman <mvangeertruy@comcast.net>
>
> It still isn't working.
>
> Here's an excerpt of my .cfg file (none of the names in the file have any
> characters other than [a-z, A-Z]:
> myAppDbShowSql = false
> myAppDbFormatSql = false
>
> In the file where I get my service I have:
> <osgix:cm-properties id="myAppDatabaseProperties"
> persistent-id="myApp.data.access"/>
> ctx:property-placeholder properties-ref="myAppDatabaseProperties"/>
>
> In the file where I am using the managed service I have (unnecessary bits
> removed):
> <bean id="myAppSessionFactory"
> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
> p:dataSource-ref="myAppPoolDataSource">
>  <osgix:managedProperties persistent-id="myApp.data.access"
> update-strategy="container-managed"/>
>  <property name="mappingResources">
>   <list>hibernate valies</list>
>  </property>
>  <property name="hibernateProperties">
>    <props>
>     <prop key="hibernate.show_sql">${myAppDbShowSql}</prop>
>     <prop key="hibernate.format_sql">${myAppDbFormatSql}</prop>
>    </props>
>   </property>
> </bean>
>
> When I change the values in my .cfg file, I can see those changes being
> populated by doing a config:list.
>
> However, I get the following error in my log:
> Configuration for myApp.data.access has already been used for service
> [org.osgi.service.cm.ManagedService, id=127, bundle=89] and will be also
> given to [org.osgi.service.cm.ManagedService, id=128, bundle=89]
>
> When I restart bundle 89, the properties are properly consumed.
>
> Anyone know what's going wrong?
>
>
> -----
> Karafman
> Slayer of the JEE
> Pounder of the Perl Programmer
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Managed-Properties-question-tp2107407p2121172.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Mime
View raw message