karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Łukasz Dywicki <l...@code-house.org>
Subject RE: Managed Properties question
Date Mon, 20 Dec 2010 18:26:00 GMT
If you try to do managed component your configuration property name must
match field name, otherwise container will not update your bean. Both
spring-dm and aries blueprint works same. In your example the property named
integer have to use placeholder ${integer}. If you would like to use
different names you need to manage changes in bean (set strategy to bean
managed and callback method).

Best regards,

-----Original Message-----
From: Achim Nierbeck [mailto:bcanhome@googlemail.com] 
Sent: Monday, December 20, 2010 6:00 PM
To: user@karaf.apache.org
Subject: Re: Managed Properties question

OK, another try

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

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">
    <prop key="hibernate.show_sql">${myAppDbShowSql}</prop>
    <prop key="hibernate.format_sql">${myAppDbFormatSql}</prop>

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:
> Sent from the Karaf - User mailing list archive at Nabble.com.

View raw message