Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Properties from Plan Files

  1. #1
    Join Date
    Jun 2005
    Posts
    18

    Default Properties from Plan Files

    Hi,
    Only noticed this feature from another thread but I am hoping you can tell me what I am missing. It would be awesome if I can push a property from the plan file into the bundle as a contructor argument for my bean. From what I can see this can be done but I am probably missing something obvious in my module-context.xml.

    Can you help ?

    In the plan file :
    <artifact type="bundle" name="com.pphelan.logger" version="[1, 2)">
    <property name="output.dir" value="/home/pphelan" />
    </artifact>

    In the module-context.xml of the bundle:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd">

    <bean id="dumpFileDir" class="java.lang.String">
    <constructor-arg value="${output.dir}" />
    </bean>

    </beans>

  2. #2
    Join Date
    Oct 2008
    Location
    Winchester, UK
    Posts
    535

    Default

    Unfortunately the property element doesn't do what you would like it to. It simply defines a manifest header in the bundle's manifest.
    Glyn Normington
    SpringSource

  3. #3
    Join Date
    Jun 2005
    Posts
    18

    Default

    Hi Glyn,
    Thanks for the update. It almost looked too good to be true I will stick to what I have for the moment.

    ~Patsy

  4. #4
    Join Date
    Oct 2008
    Location
    Winchester, UK
    Posts
    535

    Default

    An alternative which you may like to consider is putting that configuration value in a properties file and including that in the plan. Then you can use Spring DM's support for Configuration Admin to extract the property in your Spring context file and use it as a property placeholder.
    Glyn Normington
    SpringSource

  5. #5
    Join Date
    Jun 2009
    Location
    Modena Italy
    Posts
    13

    Default

    Hi,
    I'm tring to use the configuration file method, but it don't work.
    I must put a placeholder bean inside the .xml file?
    In the programmer guide it isn't so clear...
    Bye, Matteo.

  6. #6
    Join Date
    Oct 2008
    Location
    Winchester, UK
    Posts
    535

    Default

    Best refer to the Spring DM reference appendix section.
    Glyn Normington
    SpringSource

  7. #7
    Join Date
    Jun 2009
    Location
    Modena Italy
    Posts
    13

    Default

    Ok, but i want use some properties store in /repository/usr.
    mi plan is file is:
    <?xml version="1.0" encoding="UTF-8"?>

    <plan name="multi-artifact.plan" version="1.0.0" scoped="true" atomic="true"
    xmlns="http://www.springsource.org/schema/dm-server/plan"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springsource.org/schema/dm-server/plan
    http://www.springsource.org/schema/dm-server/plan/springsource-dm-server-plan.xsd">
    <artifact type="configuration" name="app-prop" version="[0.0.0, 2.0.0)"/>
    <artifact type="bundle" name="eu.ebest.dataModel" version="[1.0.0, 2.0.0)"/>
    </plan>

    and in ma repository/usr there is app-prop.properties.

  8. #8
    Join Date
    Jun 2009
    Location
    Modena Italy
    Posts
    13

    Default

    I had just change the spring.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:osgi-compendium="http://www.springframework.org/schema/osgi-compendium"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/osgi
    http://www.springframework.org/schem...g-osgi-1.2.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schem...ontext-2.5.xsd
    http://www.springframework.org/schema/osgi-compendium
    http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2.xsd">

    <bean id="dataSource2" class="eu.ebest.controller.PropertiesController"
    init-method="init">
    <constructor-arg value="${driverClassName}" />
    <constructor-arg value="${url}" />
    <constructor-arg value="${username}" />
    <constructor-arg value="${password}" />
    </bean>

    <contextroperty-placeholder
    properties-ref="configAdminProperties" />
    <osgi-compendium:cm-properties id="configAdminProperties"
    persistent-id="app-prop" />

    </beans>

    and the bundle is deployed correctly.
    Is There some method to set the "persistent-id" from the file.plan?
    I'm reading about attribute and artifact property. May they be a solution?

  9. #9
    Join Date
    Oct 2008
    Location
    Winchester, UK
    Posts
    535

    Default

    Use that plan to get the properties into Config Admin and then use Spring DM specific techniques, described in the link above, to obtain the Config Admin dictionary for PID "app-prop".
    Glyn Normington
    SpringSource

  10. #10
    Join Date
    Jun 2009
    Location
    Modena Italy
    Posts
    13

    Default

    ok, I read it.
    But I want now if is possible to obtain the presistent-id from the file.plan...

Posting Permissions

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