一开始要给openfire写一个插件有点没有头绪,去官网上找了一找,
有这么一篇文章http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/source-build.html讲解了一下如何部署源码。
其他的文档在这里,其中也有插件结构的http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/index.html,
openfire的源码中有一个build文件夹,可以用ant来给他打包,
先要把插件的结构整好,最重要的是一个叫做plugin.xml的东西
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Plugin configuration for the broadcast plugin.
-->
- <plugin>
<class>org.jivesoftware.openfire.plugin.MyPlugin</class>
<name>Broadcast</name>
<description>Broadcasts messages to users.</description>
<author>Jive Software</author>
<version>1.8.2</version>
<date>4/19/2010</date>
<url>http://www.igniterealtime.org</url>
<minServerVersion>3.7.0</minServerVersion>
</plugin>
其中最重要的是这个<class>标签,前面一定要写成org.jivesoftware.openfire.plugin.MyPlugin,
logo_large.gif logo_small.gif changelog.html readme.html
这4个文件可以不用管
文件夹内的结构参照http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/plugin-dev-guide.html
public class plugin implements Plugin {
/**
* Constructs a new client control plugin.
*/
public plugin() {
}
// Plugin Interface
public void initializePlugin(PluginManager manager, File pluginDirectory) {
System.out.println("Hellow Openfire!");
}
public void destroyPlugin() {
}
}
简单的写一个hellowWorld
吧文件夹的结构弄好之后在openfire_src 的 bulid 目录下运行ant plugins
插件就自动打包好了。
如果结构不对或者,程序出错,打包过程中会报错,但是uploading plugin时还是会显示plugin uploading successfully,这个有点坑跌。
一切正确后,再次运行Openfire点击start
就会看到,hellowOpenfire,偶~