Announcement Announcement Module
Collapse
No announcement yet.
Properties from Plan Files Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Unfortunately the property element doesn't do what you would like it to. It simply defines a manifest header in the bundle's manifest.

    Comment


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

      Comment


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

        Comment


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

          Comment


          • #6
            Best refer to the Spring DM reference appendix section.

            Comment


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

              Comment


              • #8
                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?

                Comment


                • #9
                  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".

                  Comment


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

                    Comment


                    • #11
                      dm Server maps properties files into Config Admin by using the name of the properties file as the PID. So in your case the PID is "app-prop".

                      Comment


                      • #12
                        ok, I understan.
                        It's possible to change dinamicly the PID using some properties of the plan?

                        I tell you my problem.
                        I have a generic bundle and I want to deploy it in differents scopes, using several plans. Each of this plans have a different DB configuration.

                        Comment


                        • #13
                          dm Server does not provide a mechanism to achieve that. Of course, you could write code in the bundle to determine the scope in which it was deployed and deduce the PID from the scope (probably by convention).

                          Comment

                          Working...
                          X