Bamboo Persistence using Bandana
Bandana is an Atlassian framework for persistence which uses XStream to convert arbitrary Java objects into XML for storage. The concepts used in Bandana are very simple:
- Bandana stores data in contexts. In Bamboo, there is one global context, and one context per plan.
- Each context stores key-value pairs. The key is a
Stringand the value can be any
Object(it should typically implement Serializable).
Based on this design, the BandanaManager has methods for storing and retrieving values from a context by key:
void setValue(BandanaContext context, String key, Object value)— store a value against a key in the Bandana context.
Object getValue(BandanaContext context, String key)— get a key's value from the Bandana context. Returns null if no matching context and key exists.
Object getValue(BandanaContext context, String key, boolean lookUp)— same as above, except if
lookUpis true and the context is a space context, this method will also check the global context if no matching key is found in the space context.
For plugins, it is recommended to use a key for your Bandana values that includes the full package name of your plugin. For example, an auto-favourites plugin might use a key like
This XML is written to the BANDANA table in the database.
To get access to the BandanaManager from your plugin code, normally you only need to include a private BandanaManager field. A setter method will be called the first time your plugin is called.