Hi Dan,

no problem, if there is anything else we can help on come back :)

Regards, Achim

> Hi Achim,
>
> I think it is reasonable to refactor my spring configuration to
> separate standalone spring app and osgi app, rather then mixing them
> and hope for the best
>
> Thank you for all the great advice.
>
> -Dan
>
>
>
> On Sun, Mar 13, 2011 at 12:35 PM, Achim Nierbeck
> <[email protected]> wrote:
>> Hi Dan,
>>
>> depends on how you setup your Spring and your application.
>> I usually use maven as build system and therefore do differentiate
>> between spring in test and on server.
>> In you "test" environment you can keep your configuration.
>>
>> One other possibility is how you tell spring / spring-dm which config
>> files to use.
>>
>> Per default spring-dm searches for a spring xml file in META-INF/spring
>> but you can also
>> tell spring to search in other directories or just to use certain xml
>> files.
>> For example you might set the following in the MANIFEST
>>
>> Spring-Context: config/account-data-context.xml, 
>> config/account-security-context.xml
>>
>>
>> More details on how to configure spring and so forth can be found at [1]
>>
>> Another thing I usually do is to separate Spring bean wiring from it's
>> configuration, this way you can
>> use different configurations for different locations.
>>
>>
>>
>> [1] -
>> http://static.springsource.org/osgi/docs/1.2.1/reference/html/app-deploy.html#app-deploy:headers
>>
>>
>>> Hi Achim
>>>
>>> what do you mean by "Now you just need to replace your property code
>>> by the following."?
>>>
>>> does this mean i need to remove my spring
>>>
>>>  <bean id="propertyConfigurer"
>>> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>>>      <property name="systemPropertiesModeName"
>>> value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
>>>      <property name="location" 
>>> value="classpath:com/.../resources.properties" />
>>>   </bean>
>>>
>>> as well?
>>>
>>> I am hoping to leave my spring config untouched  until we fully
>>> OSGIzing it, so that my current test still functional as standlone
>>> spring test
>>>
>>> Thank you
>>>
>>> -Dan
>>>
>>>
>>> On Sun, Mar 13, 2011 at 12:09 PM, Achim Nierbeck
>>> <[email protected]> wrote:
>>>> Hi Dan,
>>>>
>>>> yes it is.
>>>>
>>>> first of all you need to make sure you got a cfg file in your etc folder
>>>> with a name that matches a "PID" - PersistentID
>>>> e.g. my.very.special.resources.cfg
>>>> where my.very.special.resources is the pid.
>>>> This way the FileInstaller takes this cfg file and tells the config
>>>> admin service to provide a configuration for that pid.
>>>>
>>>> Now you just need to replace your property code by the following.
>>>>
>>>> <osgix:cm-properties id="cfg.with.defaults" 
>>>> persistent-id="my.very.special.resources">
>>>>      <beans:prop key="host">localhost</beans:prop>
>>>>      <beans:prop key="port">3306</beans:prop>
>>>> </osgix:cm-properties>
>>>>
>>>>
>>>>
>>>> It can also be found at [1]
>>>>
>>>>
>>>> Regards, Achim
>>>>
>>>>
>>>> [1]  -
>>>> http://static.springsource.org/osgi/docs/1.2.1/reference/html/compendium.html#compendium:cm
>>>>
>>>>
>>>>> Hello,
>>>>>
>>>>> My jar ( spring bundle ) has a default set of configurations via
>>>>>
>>>>>   <bean id="propertyConfigurer"
>>>>> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>>>>>     <property name="systemPropertiesModeName"
>>>>> value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
>>>>>     <property name="location" 
>>>>> value="classpath:com/.../resources.properties" />
>>>>>   </bean>
>>>>>
>>>>> This way I  can override the default properties using system
>>>>> properties ( ie pass in -Dxuy=value to JVM )
>>>>>
>>>>> Now I'd like to deploy my bundle  to Karaf, is there a way for me to
>>>>> setup Karaf/osgi's configAdmin to to use a config file under karaf's
>>>>> etc directory to override my default properties?
>>>>>
>>>>> Big thanks ahead.
>>>>>
>>>>> -Dan
>>

Reply via email to