Fastpath and RestApi

Hi

I am working with OpenFire 3.9.3 and the Fastpath Plugin.

I’m trying to implement a RestApi for Fastpath as separate plugin. So that our application can create Agents and add them to the workgroup queues.

Now I have a problem.

After adding the new Agent to the DB and Queue

“INSERT INTO fpqueueagent (queueID,objectID,objectType,administrator) VALUES (?,?,0,0)”;

The Fastpath web interface does not recognize the new agent in the queue. Only after restarting the fastpath plugin, its recognize the new Agent in the Queue.

After looking into the Fastpath Code, there is a call after the addAgentToDb Function : agent.sendAgentAddedToAllAgents(this);

This leads to this code:

/**

  • This agent has been added to a queue so we need to inform the existing agents of the queue
  • ,that previously requested agent information, of this new agent.
  • @param requestQueue the queue where this agent has been added.
    */
    public void sendAgentAddedToAllAgents(RequestQueue requestQueue) {

Workgroup workgroup = requestQueue.getWorkgroup();

for (AgentSession session : workgroup.getAgentSessions()) {

if (session.hasRequestedAgentInfo()) {

IQ iq = new IQ(IQ.Type.set);

iq.setFrom(workgroup.getJID());

iq.setTo(session.getJID());

Element agentStatusRequest = iq.setChildElement(“agent-status-request”,

http://jabber.org/protocol/workgroup”);

agentStatusRequest.add(getAgentInfo());

// Push the new agent info to the agent
workgroup.send(iq);

}

}

}

My question is: Is there some way arround, i dont want add the whole xmpp.workgroup part to my plugin?

I search for a way to refresh the Agents without restarting the plugin.

Try to avoid writing directly to the openfire database unless you are ready to implement a cache with flushing and support clustering, otherwise your plugin will not scale and could break clustering.

The best way to access a plugin’s classes is to make your new plugin a child of the plugin you want to access. Look at the parentPlugin field in the plugin.xml file. See Openfire: Plugin Developer Guide

Is there any Example online, where i can see how to make a child plugin ?

Because, when I add the fastpath to my xml

and than try to access to fastpath methods and objects, i get an error during ant Build. That the he cant find the objects

You have to get the plugin object first and then work your way from there. See the fastpath admin jsp pages for examples

<plugin>
    <class>com.yyyyy.zzzzz.plugin.XXXXXPlugin</class>
    <name>XXXXXX</name>
    <description>XXXX Plugin for Openfire</description>
    <author>YYYYYY</author>
    <version>0.0.1.03</version>
    <parentPlugin>fastpath</parentPlugin>
    <minServerVersion>3.7.1</minServerVersion> </plugin>
import org.jivesoftware.xmpp.workgroup.WorkgroupManager; Log.info("Total Workgroups: " + WorkgroupManager.getInstance().getWorkgroupCount());

Correction. . Just looked at my code. No need to get plugin object Make sure fastpath jar file is in your build path

Hi Dele

Thx for the answer,

I had some problems with the fastpath.jar file that is generated by Ant in the target folder of Openfire. If I add this jar to my build path, i still have no access to the fastpath objects. I found out , that the fastpath.jar file is only a wrapper. The class jar file is inside and have the name plugin-fastpath.jar. I had to extract this jar and add it to my plugin libraries,only after that i could access fastpath objects from my plugin and compile without errors.

Is this the correct way to do it ?

And in this case, what is about the value in should it be “fastpath” or “plugin-fastpath” ?

Is this the correct way to do it ?

And in this case, what is about the value in should it be “fastpath” or “plugin-fastpath” ?

Yes, that is what works for me