karaf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Nodet <gno...@gmail.com>
Subject Re: Managed Properties question
Date Mon, 20 Dec 2010 19:26:15 GMT
Or use a cm:property-placeholder in combination with the reload flag
to reload the app if the config change, that's what i used inside
karaf, see:
  http://svn.apache.org/repos/asf/karaf/trunk/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml

2010/12/20 Łukasz Dywicki <luke@code-house.org>:
> 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,
> Lukasz
>
> -----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"
> 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-tp2107407p2121
> 172.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Mime
View raw message