Custom VCard provider implementation

Hi Community

I’m going to make a custom VCard provider. I know that I can specify what provider to use by OF system property provider.vcard.className.

But where my class should be deployed?

Actually to check if it is possible at all I’ve made the a class com.mycom.plugin.CustomVCardProvider in the openfire/src/plugins/search/src/java folder, made “ant plugins” and deployed the **search.jar **I got into openfire (via user interface on plugins tab).

Build was successfull.

I was hoping that my class will get into search.jar, and openfire will be aware of it. Then I planned to move it to it’s own plugin. I added it to the search just to make a testing.

But when I make **provider.vcard.className=**com.mycom.plugin.CustomVCardProvider ****I get

org.jivesoftware.openfire.vcard.VCardManager - Error loading vcard provider: com.tnt.transfire.plugin.ExtendedVCardProvider

java.lang.ClassNotFoundException: com.tnt.transfire.plugin.ExtendedVCardProvider

So that means that OF doesn’t see my class.

My question is - how can I force OF to find my VCard provider?

Where should I place my class? That undesirable to make changes in OF classes.

What would you do to make and use Custom VCard provider?

Guys, any suggestions please?

Your best bet is to always check Openfire source code for answers

VCardManager.java

try {
            Class c = ClassUtils.forName(className);
            provider = (VCardProvider) c.newInstance();
        }
        catch (Exception e) {
            Log.error("Error loading vcard provider: " + className, e);
            provider = new DefaultVCardProvider();
        }

Your class is not on the class load path. Either put it in your plugin or in a jar file that is placed in the OPENFIRE_HOME\Lib folder

Thanks for the answer.

But why the OF can’t see my class when I include it in search plugin?

The search.jar file is not on your plugin class path. Only jar files in OPENFIRE_HOME\lib and your plugin lib folder are on your class path when code is running in the context of your plugin. The search plugin class path is not available to your plugin. Thats why every plugin used to include log4j until 3.7 that now has log4j in openfire.jar.

My question is -** how can I force OF to find my VCard provider**?

If your are successful in loading the extendedVcard Provider class. The next step is to configure openfire to point to the extended provider class.

Steps:

  1. Go to Server>System properties

  2. Set a property ‘provider.vcard.className’ with the value

I haven’t any plugins yet. I just included my class into search plugin. So it becomes a part of search plugin. Then I rebuilt it and uploaded into OF. Then I set OF variable to provider.vcard.className=com.mycom.plugin.CustomVCardProvider

**** ****But I get the
**java.lang.ClassNotFoundException:******com.mycom.plugin.****CustomVCardProvider

So my class is inside search plugin jar. But OF can’t see it.

Will it see the ****com.mycom.plugin.********CustomVCardProvider class if I place it in it’s own plugin/jar? ****

Thanks, sagar

I specified that in the my first post.

I set this variable, but got class not found exception, however the class was in the search plugin jar together with search classes.

I haven’t any plugins yet. I just included my class into search plugin. So it becomes a part of search plugin. Then I rebuilt it and uploaded into OF. Then I set OF variable to provider.vcard.className=com.mycom.plugin.CustomVCardProvider

**** ****But I get the
**java.lang.ClassNotFoundException:******com.mycom.plugin.****CustomVCardProvider

So my class is inside search plugin jar. But OF can’t see it.

Will it see the ****com.mycom.plugin.********CustomVCardProvider ****class if I place it in it’s own plugin/jar?