java: Preferences API vs. Apache Commons Configuration
        Posted  
        
            by Jason S
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jason S
        
        
        
        Published on 2010-02-23T20:39:32Z
        Indexed on 
            2010/03/08
            15:36 UTC
        
        
        Read the original article
        Hit count: 518
        
java
|configuration
I need to allow the user to store/load an arbitrary number of lists of objects (assume they are Serializable). Conceptually I want a data model like
class FooBean { /* bean stuff here */ }
class FooList {
    final private Set<FooBean> items = new HashSet<FooBean>();
    public boolean add(FooBean item) { return items.add(item); }
    public boolean remove(FooBean item) { return items.remove(item); }
    public Collection<FooBean> getItems() { 
       return Collections.unmodifiableSet(items); 
    }
}
class FooStore {
    public FooStore() {
       /* something... uses Preferences or Commons Configuration */ 
    }
    public FooList load(String key) {
       /* something... retrieves a FooList associated with the key */ 
    }
    public void store(String key, FooList items) { 
       /* something... saves a FooList under the given key */
    }
}
Should I use the Preferences API or Commons Config? What's the advantages of each?
© Stack Overflow or respective owner