Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-394

Providing BeanDiff(or ConfigurationDiff), BeanBatchUpdateListener, and some merge facility for Configuration(Specially for HierarchialConfiguration) to implement two-phase-commit-like protocol to alter entire configuration hierarchy in atomic manner.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Sorry for English and for such a generic summary:

      If you have ever worked with Weblogic AdminConsole(Weblogic 10.3 in my case) you would find out that it save your changes temporary and finally by clicking "Apply changes" it would save all changes in configurations. If one of the changes is failed then Weblogic would rollback all changes of configurations. Something like database transaction.

      The general idea could be that you create a clone of your entire or some parts of your configuration hierarchy, then change the cloned version, and finally apply back the cloned version on original version of hierarchy. Here when you ask the original configuration hierarchy to accept new changes then the original hierarchy would compute the Diff between itself and cloned version and deliver the changes to all listeners that have registered for configuration changes. If any of listeners are not agree with new changes then all process of applying configuration would be rolled back!

      Here in this scenario you need some facility to be added to Apache Commons Config and also to Apache Commons BeanUtils:

      1- A BeanDiff class(http://issues.apache.org/jira/browse/BEANUTILS-304) that can compute the difference between two JavaBeans. These JavaBeans are custom classes that programmers write for application configuration (e.g. CacheConfiguration class). These custom configuration classes would use the apache common config classes to to store and retrieve the configuration from any source. It can be extended to have ConfigurationDiff that would represent the changes between two Configuration(shows which properties are altered)

      2- Cloning entire hierarchy of configuration, I actually do not know whether currently Apache Commons Config support this feature.

      3- The most important part is adding some method to Configuration interface which enables Configuration interface to accept a whole configuration hierarchy and then apply that hierarchy to itself. The apply process consist of traversing the hierarchy and visiting each node, then computing ConfigurationDiff for each node and then notifying the registered listeners of that node for all updates that node has. If one of listeners reject the update then the process would call rollback method of listeners.

      4- Some class like ConfigurationUpdateListener(or BeanUpdateListener) that has some method like :

      public abstract void prepareUpdate(ConfigurationUpdateEvent updateevent)
      throws ConfigurationUpdateRejectedException;

      public abstract void activateUpdate(ConfigurationUpdateEvent updateevent)
      throws ConfigurationUpdateFailedException;

      public abstract void rollbackUpdate(ConfigurationUpdateEvent updateevent);

      All classes that are interested in configuration changes(batch changes not just one property changes) can implement this class and register themselves in Configuration node in hierarchy.

      ------------------------------

      After some research! in Weblogic classes and jar files you can find the "com.bea.core.descriptor_1.4.0.0.jar" in "BEA_HOME\modules" folder.

      After another research you can find some interesting classes like BeanUpdateListener, BeanUpdateEvent, DescriptorBean, Descriptor inside "weblogic.descriptor" package. And also another interesting class "weblogic.descriptor.internal.BeanDiff" class. Looking at them is useful!!

      I could not completely understand the model that Weblogic works but that point are what I understood about it.
      I some useful features can be added to Apache Commons Config by looking at weblogic works. It also can ease the process of writing ConfigurationMBeans for applications.

      1. BaseConfigBean.fixed.zip
        5 kB
        Java Developer
      2. BeanDiff.zip
        43 kB
        Java Developer
      3. cfggenengine.jar
        79 kB
        Java Developer
      4. ConfigFramework.zip
        53 kB
        Java Developer
      5. FinalConfigClasses.enh2.zip
        175 kB
        Java Developer
      6. FinalConfigClasses.zip
        138 kB
        Java Developer

        Activity

        Hide
        Oliver Heger added a comment -

        This all sounds pretty complicated and probably would require major changes in the Configuration core classes (e.g. the new event listener mechanism or the diff facility). Our focus is more on reading and writing configuration files in various formats, so I wonder whether this request is a bit out of scope for Commons Configuration.

        If you can provide a patch, I am happy to review it. But I fear, this won't be trivial.

        Show
        Oliver Heger added a comment - This all sounds pretty complicated and probably would require major changes in the Configuration core classes (e.g. the new event listener mechanism or the diff facility). Our focus is more on reading and writing configuration files in various formats, so I wonder whether this request is a bit out of scope for Commons Configuration. If you can provide a patch, I am happy to review it. But I fear, this won't be trivial.
        Hide
        Java Developer added a comment -

        Maybe some new project can come out from this model, however I've attached a zip file containing a patch(i.e. some piece of code), that contains some classes:

        1- BeanDiff class which models a bean difference between 2 java beans.
        2- DiffHelper a helper class which actually computes bean diff.
        3- Main class which contains a main() method that explain the way which I described about weblogic mode.
        4- You need XStream serializer also.

        Inside com.test.bean.model package you find out 3 classes which are 3 simple java beans that have reference to each other. Currently the java beans must extends AbstractSettableBean and implements SettableBean interface. But with some extra code it is possible to remove such a requirement.

        I've not tested it completely and I'm not sure it works correctly, however it brings a good model for coding bean difference and configuration listeners.
        Please start with main method and look at the way I've coded to achieve desired behavior.

        I hope it helps.

        Show
        Java Developer added a comment - Maybe some new project can come out from this model, however I've attached a zip file containing a patch(i.e. some piece of code), that contains some classes: 1- BeanDiff class which models a bean difference between 2 java beans. 2- DiffHelper a helper class which actually computes bean diff. 3- Main class which contains a main() method that explain the way which I described about weblogic mode. 4- You need XStream serializer also. Inside com.test.bean.model package you find out 3 classes which are 3 simple java beans that have reference to each other. Currently the java beans must extends AbstractSettableBean and implements SettableBean interface. But with some extra code it is possible to remove such a requirement. I've not tested it completely and I'm not sure it works correctly, however it brings a good model for coding bean difference and configuration listeners. Please start with main method and look at the way I've coded to achieve desired behavior. I hope it helps.
        Hide
        Java Developer added a comment -

        A demo code to describe the following issue of Apache Commons Configuration project:

        http://issues.apache.org/jira/browse/CONFIGURATION-394

        Show
        Java Developer added a comment - A demo code to describe the following issue of Apache Commons Configuration project: http://issues.apache.org/jira/browse/CONFIGURATION-394
        Hide
        Java Developer added a comment - - edited

        Here I've attached the more better code to describe functionality(ConfigFramework.zip),

        Please take look at these classes to find out how it works(It is almost working, except the save() and load() methods to write values inside properties file) :

        com.test.cfg.sample.CacheConfigImpl
        com.test.cfg.sample.BankEARConfigImpl

        com.test.cfg.sample.Test1
        com.test.cfg.sample.Test2
        com.test.cfg.sample.Test3
        com.test.cfg.sample.Test
        com.test.cfg.sample.Test4

        Please follow the instructions of main() methods of Test(1-4) classes to find out how it works.

        I've used the .properties file to store and load the config data, and I've used the 'One readWriteLock per .properties' to synchronize access to the ConfigBeans which are loaded from the same properties file.

        You can also use Preferences API to load/save data(or even XML files).

        I've excluded the ConfigurationUpdateListener and 'two phase commit protocol' from it. Now it is more readable. But it is easy to add 'two phase protocol' to it at future.

        Show
        Java Developer added a comment - - edited Here I've attached the more better code to describe functionality(ConfigFramework.zip), Please take look at these classes to find out how it works(It is almost working, except the save() and load() methods to write values inside properties file) : com.test.cfg.sample.CacheConfigImpl com.test.cfg.sample.BankEARConfigImpl com.test.cfg.sample.Test1 com.test.cfg.sample.Test2 com.test.cfg.sample.Test3 com.test.cfg.sample.Test com.test.cfg.sample.Test4 Please follow the instructions of main() methods of Test(1-4) classes to find out how it works. I've used the .properties file to store and load the config data, and I've used the 'One readWriteLock per .properties' to synchronize access to the ConfigBeans which are loaded from the same properties file. You can also use Preferences API to load/save data(or even XML files). I've excluded the ConfigurationUpdateListener and 'two phase commit protocol' from it. Now it is more readable. But it is easy to add 'two phase protocol' to it at future.
        Hide
        Oliver Heger added a comment -

        This is certainly interesting stuff.

        However, I still think this is out of focus for this project. By its complexity it deserves to be a project on its own. Maybe it would make sense to start a new project somewhere at sourceforge or google?

        Show
        Oliver Heger added a comment - This is certainly interesting stuff. However, I still think this is out of focus for this project. By its complexity it deserves to be a project on its own. Maybe it would make sense to start a new project somewhere at sourceforge or google?
        Hide
        Java Developer added a comment - - edited

        I admit it is out of scope of Apache commons configuration project. But as interested java developer I know there is so much effort to model configuration data which must be effective in web development and also application development. So I completed the implementation and provided a generator framework which generate configuration classes from XML file.

        I thought this is best way to close this issue and also provide a way for googlers to find some useful code to follow it. I actually have no time to spend for new project. So I hope you still accept this last upload and let google searchers use the space of Apache project to find interesting stuff.

        Just as a short description for interested developers I should say:

        1- I've attached a eclipse project (FinalConfigClasses.zip) which contains all code of framework.
        2- The artifact of this project is an ant task which gets the XML input file as description of config-classes and
        its output is a generated config-classes into "com.fanava.psp.cfg.sample" package.
        3- You can inspect classes of "com.fanava.psp.cfg.sample" package to find out how this framework
        would generate useful config-classes that you can use in serious business applications. Test1.java,Test2.java,Test5.java, Test6.java are useful classes to see how you can use generated classes.
        4- The concurrency equipments of generated classes are much simpler than previous upload.
        5- So just execute ant target inside build.xml to see generated class files. You must fix absolute paths also.
        6- Just as a note I've used "Jacobe" code beautifuler to format generated classes. You can download it from http://www.tiobe.com/index.php/content/products/jacobe/Jacobe.html .
        7-I've used velocity as a template engine.
        8-"cfggenengine.jar" contains the compiled code of eclipse project.

        I hope this topic provides new ideas for both java developers and also for Apache commons configuration framework. May be we could place some useful part of this project into Apache commons configuration code.

        Anyway thanks for patient.

        Show
        Java Developer added a comment - - edited I admit it is out of scope of Apache commons configuration project. But as interested java developer I know there is so much effort to model configuration data which must be effective in web development and also application development. So I completed the implementation and provided a generator framework which generate configuration classes from XML file. I thought this is best way to close this issue and also provide a way for googlers to find some useful code to follow it. I actually have no time to spend for new project. So I hope you still accept this last upload and let google searchers use the space of Apache project to find interesting stuff. Just as a short description for interested developers I should say: 1- I've attached a eclipse project (FinalConfigClasses.zip) which contains all code of framework. 2- The artifact of this project is an ant task which gets the XML input file as description of config-classes and its output is a generated config-classes into "com.fanava.psp.cfg.sample" package. 3- You can inspect classes of "com.fanava.psp.cfg.sample" package to find out how this framework would generate useful config-classes that you can use in serious business applications. Test1.java,Test2.java,Test5.java, Test6.java are useful classes to see how you can use generated classes. 4- The concurrency equipments of generated classes are much simpler than previous upload. 5- So just execute ant target inside build.xml to see generated class files. You must fix absolute paths also. 6- Just as a note I've used "Jacobe" code beautifuler to format generated classes. You can download it from http://www.tiobe.com/index.php/content/products/jacobe/Jacobe.html . 7-I've used velocity as a template engine. 8-"cfggenengine.jar" contains the compiled code of eclipse project. I hope this topic provides new ideas for both java developers and also for Apache commons configuration framework. May be we could place some useful part of this project into Apache commons configuration code. Anyway thanks for patient.
        Hide
        Oliver Heger added a comment -

        Thank you for your contribution.

        So I am closing this ticket as Won't fix. Of course, it will remain in this bug tracking system and is available for search engines.

        Show
        Oliver Heger added a comment - Thank you for your contribution. So I am closing this ticket as Won't fix. Of course, it will remain in this bug tracking system and is available for search engines.
        Hide
        Java Developer added a comment -

        I know issue is closed, but current implementation has some benefits(e.g. using oracle Berkeley DB XML).

        thanks!

        Show
        Java Developer added a comment - I know issue is closed, but current implementation has some benefits(e.g. using oracle Berkeley DB XML). thanks!
        Hide
        Java Developer added a comment -

        Hi there,
        this is final complete project which is exactly like oracle weblogic BIG configuration wizard and backbone
        which is very needed indeed. It is program backbone, also apache tomcat use this way to configure itself,
        I mean apache common configuration misleads new developers, please create new jakarta project for this
        issue,
        I've uploaded the source and binary for both java and .net frameworks (documentation in persian language)
        and you can generate configuration backbone of whole software with click! with almost 10 basic feature
        of configuration.
        I think it must be compared and talked against System.Configuration namespace in .net framework.

        Look at Uploaded source codes please.

        Thanks alot.

        Show
        Java Developer added a comment - Hi there, this is final complete project which is exactly like oracle weblogic BIG configuration wizard and backbone which is very needed indeed. It is program backbone, also apache tomcat use this way to configure itself, I mean apache common configuration misleads new developers, please create new jakarta project for this issue, I've uploaded the source and binary for both java and .net frameworks (documentation in persian language) and you can generate configuration backbone of whole software with click! with almost 10 basic feature of configuration. I think it must be compared and talked against System.Configuration namespace in .net framework. Look at Uploaded source codes please. Thanks alot.

          People

          • Assignee:
            Unassigned
            Reporter:
            Java Developer
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2,016h
              2,016h
              Remaining:
              Remaining Estimate - 2,016h
              2,016h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development