@@ -0,0 +1,2127 @@
+package elektra.plugin;%0A%0Aimport elektra.*;%0Aimport java.io.FileInputStream;%0Aimport java.io.BufferedInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.BufferedOutputStream;%0Aimport java.util.Properties;%0Aimport java.util.Map;%0A%0Apublic class PropertiesStorage implements Plugin %7B%0A%09public PropertiesStorage() %7B%0A%09%7D%0A%0A%09public int open(KeySet conf, Key errorKey) %7B%0A%09%09return 0;%0A%09%7D%0A%0A%09public int get(KeySet ks, Key parentKey) %7B%0A%09%09String root=%22system/elektra/modules/jni%22;%0A%09%09if (parentKey.isBelowOrSame(Key.create(root, Key.KEY_END))) %7B%0A%09%09%09ks.append(Key.create(root+%22/infos/provides%22, Key.KEY_VALUE, %22storage%22, Key.KEY_END));%0A%09%09%09ks.append(Key.create(root+%22/infos/placements%22, Key.KEY_VALUE, %22getstorage setstorage%22, Key.KEY_END));%0A%09%09%09Key k = ks.lookup(root+%22/infos/description%22);%0A%09%09%09if (!k.isNull()) %7B%0A%09%09%09%09// append to description%0A%09%09%09%09k.setString(k.getString() +%0A%09%09%09%09%09%22Get + set properties files%22);%0A%09%09%09%7D%0A%09%09%09return 0;%0A%09%09%7D%0A%09%09Properties properties = new Properties();%0A%09%09try (BufferedInputStream stream =%0A%09%09%09new BufferedInputStream(new FileInputStream(parentKey.getString()))) %7B%0A%09%09%09properties.load(stream);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09// TODO: write error%0A%09%09%09System.out.println (%22Could not read file%22);%0A%09%09%09return -1;%0A%09%09%7D%0A%09%09for (Map.Entry%3CObject, Object%3E e:properties.entrySet()) %7B%0A%09%09%09System.out.println(e.getKey() + %22 %22 + e.getValue());%0A%09%09%09ks.append(Key.create(parentKey.getName()+%22/%22+e.getKey(),%0A%09%09%09%09%09Key.KEY_VALUE, e.getValue(),%0A%09%09%09%09%09Key.KEY_END));%0A%09%09%7D%0A%09%09return 0;%0A%09%7D%0A%0A%09public int set(KeySet ks, Key parentKey) %7B%0A%09%09Properties properties = new Properties();%0A%09%09for (Key k: ks) %7B%0A%09%09%09String newName = k.getName().substring(parentKey.getNameSize());%0A%09%09%09properties.setProperty(newName, k.getString());%0A%09%09%7D%0A%09%09try (BufferedOutputStream stream =%0A%09%09%09new BufferedOutputStream(new FileOutputStream(parentKey.getString()))) %7B%0A%09%09%09properties.store(stream, %22written by elektra using Java Properties%22);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09// TODO: write error%0A%09%09%09System.out.println (%22Could not write file%22);%0A%09%09%09return -1;%0A%09%09%7D%0A%09%09return 0;%0A%09%7D%0A%0A%09public int error(KeySet ks, Key parentKey) %7B%0A%09%09return 0;%0A%09%7D%0A%0A%09public int close(Key parentKey) %7B%0A%09%09return 0;%0A%09%7D%0A%0A%7D%0A

add storage plugin example