How to write a plugin

Hi,

I hope someone can help me…

i’‘m writing a plugin for wildfire but i’'m not sure if i work correctly.

From the Plugin Developer Guide i deduce to follow this steps:

1 Get Wildfire source

2 Build it with Ant

3 Write the plugin source (a “.java” file) and put it in a directory with a plugin.xml file (which indicates the main class of the plugin)

4 put this directory in the wildfire_src/src/plugins directory and use ant plugins[/i] command to build my plugin and obtain a “.jar” file

My questions are:

is this correct? or i’‘m missing something (or i didn’'t understand nothing)?

I’‘m sorry but i’‘m new in this type of work and is the first time i use java so my head is a little bit confused (i’'m sorry for my English too)

Thanks for your help!

Aster

Hi Aster,

It looks like your plugin directory structure may not be quite right. In the wildfire_src/src/plugins directory you should have another directory that is the same name as your plugin, i.e. wildfire_src/src/plugins/myplugin. Then, inside the myplugin directory you should have the following:

myplugin/
 |- plugin.xml <- Plugin definition file
 |- readme.html <- Optional readme file for plugin
 |- changelog.html <- Optional changelog file for plugin
 |- icon_small.gif <- Optional small (16x16) icon associated with the plugin (can also be a .png file)
 |- icon_large.gif <- Optional large (32x32) icon associated with the plugin (can also be a .png file)
 |- classes/ <- Resources your plugin needs (i.e., a properties file)
 |- lib/ <- Libraries your plugin needs
 |- src/
 |- java <- Java source code for your plugin
 | |- com
 | |- mycompany
 | |- *.java
 |- web
 |- *.jsp <- JSPs your plugin uses for the admin console
 |- images/ <- Any images your JSP pages need (optional)
 |- WEB-INF
 |- web.xml <- Optional file where custom servlets can be registered

Notice, that your .java file(s) are placed inside the src/java directory.

Hope that helps,

Ryan

Thanks for your reply,

but i’‘ve another doubt: i’'m writing the plugin to test the s2s channel (and to learn to write a plugin ) from where I have to start to study the s2s channel.

i’'m studying the javadoc and the source code (in particular the server directory which contains incomingServerSession.java, OutgoingServerSession.java etc etc)

do you have some suggestion to have a full vision of the behavior of the server?

Regards

Aster

Hi Aster,

Other than digging through the source code and documentation I’‘m not aware of any other way to get a good overview of Wildfire’'s architecture. At one point some people were working on an url=http://www.jivesoftware.org/community/thread.jspa?threadID=16238high level diagram[/url] but I think everyone has gotten busy with other things.

Regards,

Ryan

Hi ryang and thanks for your help,

i’‘m sure someone will complete the high level diagram and i think it will be a great help for understand the server’'s architecture.

Regards

Aster

Hi,

i wrote and compiled this example plugin

package org.jivesoftware.wildfire.plugin;

import org.jivesoftware.wildfire.MessageRouter;

import org.jivesoftware.wildfire.XMPPServer;

import org.jivesoftware.wildfire.container.Plugin;

import org.jivesoftware.wildfire.container.PluginManager;

import org.jivesoftware.wildfire.event.UserEventDispatcher;

import org.jivesoftware.wildfire.event.UserEventListener;

import org.jivesoftware.wildfire.group.Group;

import org.jivesoftware.wildfire.group.GroupManager;

import org.jivesoftware.wildfire.group.GroupNotFoundException;

import org.jivesoftware.wildfire.user.User;

import org.jivesoftware.admin.AuthCheckFilter;

import org.jivesoftware.util.EmailService;

import org.jivesoftware.util.JiveGlobals;

import org.jivesoftware.util.Log;

import org.xmpp.packet.JID;

import org.xmpp.packet.Message;

import java.io.File;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Collection;

import java.util.Collections;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

public class AsterPlugin implements Plugin {

public AsterPlugin() {

}

public void initializePlugin(PluginManager manager, File pluginDirectory) {

}

public void destroyPlugin() {

}

}[/code]

How i’‘ve to initialize and destroy the plugin and where i’'ve to put my code (i.e. my instruction for the server)?

Excuse my stupid questions

Aster

Hey Aster,

The #initializePlugin message will be sent by the server when the plugin is loaded. You just need to specify what do you want to do to get your plugin initialized. You may want to take a look at the broadcast plugin or any other out-of-the-box plugin to see some examples. The #destroyPlugin message will be sent when the plugin is removed (e.g. the .jar file was deleted).

Regards,

– Gato