List<String> keys = new ArrayList<String>();
keys.addAll(connections.keySet());
Collections.sort(keys);
DefaultConnectionWrapper wrapper;
MBeanServerConnectionDescriptor descriptor;
XMLMemento root = XMLMemento.createWriteRoot(CONNECTIONS);
Iterator<String> i = keys.iterator();
while(i.hasNext()) {
wrapper = connections.get(i.next());
if( wrapper != null ) {
descriptor = wrapper.getDescriptor();
if( descriptor != null ) {
IMemento child = root.createChild(CONNECTION);
child.putString(ID, descriptor.getID());
child.putString(URL, descriptor.getURL());
child.putString(USERNAME, descriptor.getUserName());
child.putString(PASSWORD, descriptor.getPassword());
}
}
}
root.saveToFile(filename);
}