Openfire插件开发坏境配置指南

本文主要是介绍Openfire插件开发的环境配置,该指南是在你已经完成了Eclipse中Openfire源码开发环境配置(详见:http://www.micmiu.com/opensource/openfire/openfire-src-config/)的基础之上的。

  • 配置编译所有插件
  • 配置编译一个已存在的插件
  • 配置编译自己的插件
  • 如何运行和调试插件

[一]、配置编译所有插件

  • 点击  Run –> External Tools –> Open External Tools Dialog….
  • 选择 Ant Build. 右击 Ant Build 选择 New. 创建一个新的配置
  • 把新配置的默认名称:New_configuration 修改成:openfire build all plugins .
  • 选择Main 标签,点击 Buildfile –> Browse Workspace…. 弹出 Choose Location 窗口
  • Choose Location 窗口 左边 选择 openfire –> build ,右边窗口选择  build.xml ,点击OK 返回主配置界面
  • 选择Targets 标签,选中名称为:plugins 的target,其他全部取消选中。
  • 选择Common 标签,在 Display in favorites menu 下选中 the External Tools,便于以后快捷编译插件
  • 点击主配置界面中的 Apply 和 Close 按钮
  • 你只要点击:Run –> External Tools –> openfire build all plugins (和之前配置的名称一致)即可执行编译所有的插件

[二]、配置编译一个已存在的插件(以 search 插件为例)

  • 点击  Run –> External Tools –> Open External Tools Dialog….
  • 选择 Ant Build. 右击 Ant Build 选择 New. 创建一个新的配置
  • 把新配置的默认名称:New_configuration 修改成:openfire build search plugins .
  • 选择Main 标签,点击 Buildfile –> Browse Workspace…. 弹出 Choose Location 窗口
  • Choose Location 窗口 左边 选择 openfire –> build ,右边窗口选择  build.xml ,点击OK 返回主配置界面
  • 在Main 标签中的 Arguments 设置中添加参数配置:-Dplugin=search 。 
  • 选择Targets 标签,选中名称为:plugin (区别编译由于插件的target:plugins)的,其他全部取消选中。
  • 选择Common 标签,在 Display in favorites menu 下选中 the External Tools,便于以后快捷编译插件
  • 点击主配置界面中的 Apply 和 Close 按钮
  • 之后只要点击:Run –> External Tools –> openfire build search plugins 即可执行编译一个指定的插件
  • 编译好后,刷新项目会在 openfire_src\target\openfire\plugins 看到已经打包好的插件

[三]、配置编译自己的插件

自定义插件,最基本要满足如下两个条件

  • 根目录下要包含:plugin.xml 
  • 根目录下包含一个java源码文件夹,同时要有一个实现了org.jivesoftware.openfire.container.Plugin 接口的java类。
插件开发的详细参见:http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/plugin-dev-guide.html

本文自定义一个 mmlog 的插件,结构如下:

plugin.xml :

MMLogPlugin.java :

其他的编译配置的步骤和上面  第[三] 部分介绍编译一个已存在的插件的过程一致。

编译好后,刷新项目会在 openfire_src\target\openfire\plugins 看到已经打包好的插件:mmlog.jar

[四]、如何运行和调试插件

一个插件本身不会运行,它会随着Openfire 服务端程序的的启动而启动,不管是运行还是调试都需要依赖Openfire 服务端主程序。

[五]、参考文档

本文介绍到此结束@Michael Sun.

原创文章,转载请注明: 转载自micmiu – 软件开发+生活点滴[ http://www.micmiu.com/ ]

本文链接地址: http://www.micmiu.com/opensource/openfire/openfire-plugins-build/

发表评论?

5 条评论。

  1. 最近在学习openfire, 谢谢楼主的文章帮了大忙 🙂
    我有一个问题想要请教一下, 我按照楼主的这篇文章, 第一个插件也能正常运行, 但是每次修改插件然后Build Successful, 发现插件还是我修改前的版本, 每次更改插件的话都需要重启服务器才能应用更改, = =! 楼主遇没遇到这个问题? 需要设置哪里才能解决这个问题?

  2. 🙂 谢谢楼主分享的文章,这样的文章对于新手帮助很大,谢谢。

  3. 你好,我正在收集好博客的链接,做博客导航,有兴趣加入吗?到http://go.zhans.org/03/255.htm 留言哦

回复给 Michael ¬
取消回复


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">