Results 1 to 4 of 4

Thread: property-placeholder configuration

  1. #1
    Join Date
    Nov 2008
    Posts
    2

    Default property-placeholder configuration

    hi,

    i try to create a bundle (bundle-a) where i can store my environment variables. these variables then should be provided to an other bundle lets say (bundle-b). therefore i use the property-placeholder and the org.eclipse.equinox.cm.

    bundle-a can be uploaded to the springsource dm server without a problem. but when i upload bundle-b, i get a BeanDefinitionStoreException with the message: Invalid bean definition with name 'httpInvokerProxy'... could not resolve placeholder 'serverUrl'...

    how can i reference the persistent-id/variables from bundle-a in bundle-b?

    code from bundle-a:
    Code:
    <osgix:property-placeholder persistent-id="com.xyz.serverConfig">
            ...
    	<osgix:default-properties>
    		<prop key="serverUrl">
    			meineURL
    		</prop>
    	</osgix:default-properties>
    </osgix:property-placeholder>
    code from bundle-b
    Code:
    <osgix:property-placeholder persistent-id="com.xyz.serverConfig"/>
    
    <bean id="httpInvokerProxy" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
    	<property name="serviceUrl" value="${serverUrl}" />
    	...
    </bean>
    thanks in advance,
    marc

  2. #2
    Join Date
    Aug 2005
    Location
    Halifax, NS, Canada
    Posts
    50

    Default

    Default property values assigned to the property placeholder are not written to the OSGi property store. They are only placed into the property placeholder, and therefore the other bundle cannot see them.

    You would need to actually write the properties to the OSGi property store for them to be visible. This can be done several ways, all of which will require you to use the CM api to update the property store, or you can write a little piece of code to read defaults from a property files and write them to the property store, or even add a bean to your bundle-a to do the same thing.

    I chose to write a little piece of code that looks for property files in a certain directory or directories (configurable) and have it load the properties into CM. Works like a charm. For an example, see the http://www.aqute.biz/Code/FileInstall, which at first glance does not look useful, but in addition to loading bundles it also loads properties into CM from files.
    Don Laidlaw
    Infor Global Solutions

  3. #3
    Join Date
    Nov 2008
    Posts
    2

    Default

    thanks a lot for your answer

    i have done it this way:

    i created an environment-bundle which exports a bean as a service which holds the configuration parameters. these parameters can be initialized over the set-method. the values for the set-method are defined in a .properties file which are referenced by a placeholder ${...} and replaced by the PropertyPlaceholderConfigurer.

    other bundles can get the configuration parameters over the osgi service from the environment-bundle. therefore the other bundles have to reference the service. then for each parameter a bean needs to be created by the Spring-Factory. now the parameter is ready to be used...

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Glad to see you guys managed to solve this problem. I wanted to let you know that the newly released 1.2.0 M2 improved the Configuration Admin integration. Notice the compendium schema has also changed.

    Cheers,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •