openfire_插件开发-helloworld

本文详细介绍如何为Openfire即时通讯服务器开发插件,包括创建并编译HelloWorld插件的具体步骤,以及如何将插件集成到Openfire环境中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.openfire编译运行正常,参见:http://blog.youkuaiyun.com/xhcbird/article/details/20458449

2.插件开发,帮助文档很详细,在openfire_src\documentation\docs\index.html文件,用浏览器打开。可以找到:

3.参照文档。在openfire/src/plugins目录下,增加xhcplugin/src/java/com/xhcbird/xhcplugin/HelloWorld.java文件

package com.xhcbird.xhcplugin;

import org.jivesoftware.openfire.container.Plugin;
import org.jivesoftware.openfire.container.PluginManager;

import java.io.File;

/**
 * A sample plugin for Openfire.
 */
public class HelloWorld implements Plugin {

	public void initializePlugin(PluginManager manager, File pluginDirectory) {
        // Your code goes here
    	System.out.println("xhcbird helloworld start!!!");
    }
    public void destroyPlugin() {
        // Your code goes here
    	System.out.println("xhcbird helloworld stop!!!");
    }
}

4.在openfire/src/plugins目录下,增加plugin.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
    <!-- Main plugin class -->
    <class>com.xhcbird.xhcplugin.HelloWorld</class>

    <!-- Plugin meta-data -->
    <name>xhcplugin</name>
    <description>plugin xhc play.</description>
    <author>xhcbird</author>

    <version>1.0</version>
    <date>03/04/2014</date>
    <url>http://www.igniterealtime.org/projects/openfire/plugins.jsp</url>
    <minServerVersion>3.0.0</minServerVersion>
    <licenseType>gpl</licenseType>

    <!-- Admin console entries -->
    <adminconsole>
        <!-- More on this below -->
    </adminconsole>
</plugin>
注意其中的class不要弄错

5.已经可以编译运行了。。。

6.点击Window->Show View->Ant,点击Add Buildfiles,选择build/build.xml文件,如图:

7.点击plugins编译,F5刷新工程。在target/openfire/plusins出现xhcplugin.jar

8.运行。或者在已经运行的openfire中添加插件(插件栏中,点击添加插件按钮),如图:


9.输出信息(console)中,可见:“xhcbird helloworld start!!!”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值