How can I attach/associate my own data to the User class in Openfire?

Hi,

I want to use Openfire’s storage mechanism to store an extra attribute per registered user. I want to do some custom processing in my plugin using the value of this attribute. Till now the best solution I have been able to come up with is to have my own data structures but that leads to more complexity.

Is there a built in mechanism in Openfire, e.g., an API in the User class, that allows me to insert arbitrary data (String, etc) using something like setProperty() method just like the existing setName(), setEMail() methods in the User class.

The class User has a method: private void insertProperty(String propName, String propValue) This method stores a key-value pair (which is perfect for me) in the class data member called properties which is of type Map<String,String>. However, this is a private function and I cannot insert my own property at will from somewhere else (e.g., my plugin).

The User class also has a method: public Map<String,String> getProperties() The documentation for this method says that it returns ‘the extended properties’. But how do u set these extended properties, I couldn’t find anywhere how to set an extended property although the documentation does talk of extended properties in addition to username, email, etc.

Any ideas how this can be done?

Thanks.

I’m doing something that is related to what you want. Maybe it’s applicable to your situation as well. Instead of attaching data to a particular User object, you can attach it to a particular LocalClientSession. Have a look at the setSessionData() method.

Thanks Guus, this is just what I needed.