hk2
  1. hk2
  2. HK2-73

Prevent saving config beans with default values to domain.xml

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.*
    • Fix Version/s: 2.1.*
    • Component/s: None
    • Labels:
      None

      Description

      For the config modularity framework we need the possibility to ignore saving the config beans which hold default configuration (no attribute value is changed). For example if a JmsHost config bean is holding the default configuration and none of its attributes has changed since loading time we should not save it to domain.xml. It would be perfect to specify a switch to enable and disable this functionality as well.

        Activity

        Hide
        Bhakti Mehta added a comment -

        John I have started work on this issue and would like to take ownership if you can assign this to me. I have discussed the design with Mahesh and Masoud briefly and will send patches for review soon

        Show
        Bhakti Mehta added a comment - John I have started work on this issue and would like to take ownership if you can assign this to me. I have discussed the design with Mahesh and Masoud briefly and will send patches for review soon
        Hide
        Mahesh Kannan added a comment -

        The fix for this issue on the HK2 side has been checked in (Thanks Bhakti).

        svn diff hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java
        Index: hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java
        ===================================================================
        — hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java (revision 3818)
        +++ hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java (working copy)
        @@ -85,7 +85,30 @@
        private DomDescriptor domDescriptor;

        private ServiceHandle<Dom> serviceHandle;
        + /**
        + * This flag indicates whether a Dom object should be
        + * written to domain.xml. By default everything is written
        + * to domain.xml unless someone explicitly calls the
        + * skipFromXml method
        + */
        + private boolean writeToXml = true;

        + /**
        + * This method should be invoked if this Dom should not be persisted
        + * to the domain.xml file.
        + */
        + public void skipFromXml()

        { + writeToXml = false; + }

        +
        + /**
        + * This method should be invoked if this Dom needs to be persisted to
        + * domain.xml file
        + */
        + public void writeToXml()

        { + writeToXml = true; + }

        +
        static abstract class Child {
        final String name;

        @@ -1262,6 +1285,13 @@
        if(tagName==null)
        throw new IllegalArgumentException("Trying t write a local element "this" w/o a tag name");

        + /**
        + * If someone has explicitly called the skipFromXml then dont write the element to
        + * domain.xml
        + */
        + if (! writeToXml)

        { + return; + }

        w.writeStartElement(tagName);

        for (Map.Entry<String, String> attributeToWrite : attributesToWrite().entrySet()) {

        % svn commit -m "Partial fix for hk2-73" hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java
        Sending hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java
        Transmitting file data .
        Committed revision 3825.

        Show
        Mahesh Kannan added a comment - The fix for this issue on the HK2 side has been checked in (Thanks Bhakti). svn diff hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java Index: hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java =================================================================== — hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java (revision 3818) +++ hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java (working copy) @@ -85,7 +85,30 @@ private DomDescriptor domDescriptor; private ServiceHandle<Dom> serviceHandle; + /** + * This flag indicates whether a Dom object should be + * written to domain.xml. By default everything is written + * to domain.xml unless someone explicitly calls the + * skipFromXml method + */ + private boolean writeToXml = true; + /** + * This method should be invoked if this Dom should not be persisted + * to the domain.xml file. + */ + public void skipFromXml() { + writeToXml = false; + } + + /** + * This method should be invoked if this Dom needs to be persisted to + * domain.xml file + */ + public void writeToXml() { + writeToXml = true; + } + static abstract class Child { final String name; @@ -1262,6 +1285,13 @@ if(tagName==null) throw new IllegalArgumentException("Trying t write a local element " this " w/o a tag name"); + /** + * If someone has explicitly called the skipFromXml then dont write the element to + * domain.xml + */ + if (! writeToXml) { + return; + } w.writeStartElement(tagName); for (Map.Entry<String, String> attributeToWrite : attributesToWrite().entrySet()) { % svn commit -m "Partial fix for hk2-73" hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java Sending hk2-config/src/main/java/org/jvnet/hk2/config/Dom.java Transmitting file data . Committed revision 3825.

          People

          • Assignee:
            Mahesh Kannan
            Reporter:
            Masoud Kalali
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: