Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
property-placeholder configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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...

      Comment


      • #4
        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,

        Comment

        Working...
        X