Extending the XPages Extension Library’s User Bean

The Extension Library comes with a concept of user beans which encapsulate profile information of users. In the context of social applications this is important since in many scenarios user profiles need to be extended with information from other social services. Typical examples are unique ids, quota information, etc.

For example the new LotusLive Files data source requires to pass in a “subscriberId” which is the unique id of the current user. For this purpose the managed bean “userBean” has a new variable “lotusLiveSubscriberId”:

Developers can add their own variables to this bean by implementing the extension point “com.ibm.xsp.extlib.social.PersonDataProvider” in an Eclipse plugin. This extension point is defined in the core com.ibm..xsp.extlib project and the infrastructure in the com.ibm..xsp.extlib.social package.

The custom class needs to extend “com.ibm.xsp.extlib.social.impl.AbstractPeopleDataProvider” and implement the following method.
public Object getValue(PersonImpl person, Object key)

This method needs to return the specific variable for a specific person. There is a convenience method “getSyncObject()” that can be used to synchronize this call so that the same property is not read for the same person multiple times at the same time.

There is also a second method that can be implemented to read all properties for all users together. This speeds up the performance especially for example for scenarios with views where profile information from multiple people is displayed.
public void readValues(PersonImpl persons)

The XPages infrastructure stores/caches users’ profile information. In order to read the latest values the infrastructure calls the two clear methods which developers can implement.
public void clear()
public void clear(String id)

The teamroom template uses this technique as well.