Search in sources :

Example 1 with UserNameProvider

use of org.jivesoftware.openfire.user.UserNameProvider in project Openfire by igniterealtime.

the class FastpathPlugin method workgroupManagerStart.

private void workgroupManagerStart() {
    workgroupManager = WorkgroupManager.getInstance();
    // Register Fastpath service
    try {
        ComponentManagerFactory.getComponentManager().addComponent("workgroup", workgroupManager);
    } catch (ComponentException e) {
        // Do nothing. Should never happen.
        Log.error(e.getMessage(), e);
    }
    // Register the provider of workgroup names
    UserNameManager.addUserNameProvider(workgroupManager.getAddress().toString(), new UserNameProvider() {

        public String getUserName(JID entity) {
            try {
                Workgroup workgroup = workgroupManager.getWorkgroup(entity);
                return workgroup.getDisplayName();
            } catch (UserNotFoundException e) {
                return entity.toString();
            }
        }
    });
    // Start the Fastpath module
    workgroupManager.start();
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) UserNameProvider(org.jivesoftware.openfire.user.UserNameProvider) JID(org.xmpp.packet.JID) ComponentException(org.xmpp.component.ComponentException) Workgroup(org.jivesoftware.xmpp.workgroup.Workgroup)

Aggregations

UserNameProvider (org.jivesoftware.openfire.user.UserNameProvider)1 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)1 Workgroup (org.jivesoftware.xmpp.workgroup.Workgroup)1 ComponentException (org.xmpp.component.ComponentException)1 JID (org.xmpp.packet.JID)1