I am writing a new plugin for openfire.
PROBLEM: how can I store a my table/matrix with some couples key/value in openfire?
My plugin has to read this table that is stored somewhere.
Any suggestions or links about this problem?
I’m sorry for my english and if the problem is too simple.
You could either use system properties or store your data in openfires database. The first variant is easy and designed for few key/value pairs. The second variant you can store more complex data. Using the database directly is more complicated, but can take advantage of the relational database model, use joins, indexes, …
For variant 1.
You can change system properties using admin console: Server -> Server Manager -> System Properties
As key you should choose something like “plugin.PLUGINNAME.key.subkey”.
Take a look on JiveGlobals and PropertyEventListener.
For variant 2.
E.g take the source code of the PacketFilter plugin as example. This is supplied with Openfire source code. PluginDevGuide is probably also helpful here. Take a look on description of databaseKey and databaseVersion.
Message was edited by: Coolcat
my table has few key/value pairs, but every key should have two numerical values, for example:
my plugin has to read that table in given moments using a key(for example name1)and check that numerical values.
Should I have any problems in this case?
For variant 1 you could either use two keys, e.g. “plugin.PLUGINNAME.name1.1” and “plugin.PLUGINNAME.name1.2” or store the numbers in a String “value1, value2”. A third way would be storing it in higher order and lower order bits of an integer or long.
In all cases you should hold your data in memory and only load it while initializing your plugin, or when someone changed them using admin console (see PropertyEventListener).
For variant 2, just create new table:
CREATE TABLE yourPluginData (
id CHAR(15) NOT NULL,
value1 INT NOT NULL,
value2 INT NOT NULL,
To retrieve your data use this SQL:
SELECT value1, value2 FROM yourPluginData WHERE id='name1';