openfire插件开发-简单插件

时间:2023-01-27 14:43:52

1.点击项目反键,新建source folder,并建相应的插件包org.jivesoftware.openfire.plugin

openfire插件开发-简单插件

2.建完后在src/plugins下面会出现example文件夹,并按照如下目录新建对应的文件:

openfire插件开发-简单插件


3.文件介绍

ExamplePlugin.java

public class ExamplePlugin implements PacketInterceptor, Plugin {

private static PluginManager pluginManager;
private InterceptorManager interceptoerManager;
private String domain = JiveProperties.getInstance().get("xmpp.domain");


public ExamplePlugin() {
interceptoerManager = InterceptorManager.getInstance();
}

@Override
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
interceptoerManager.addInterceptor(this);
System.out.println("Exampple add success");
System.out.println("domain = " + domain);
}

@Override
public void destroyPlugin() {
interceptoerManager.removeInterceptor(this);
System.out.println("Exampple destroy success");
}
}


plugin.xml

<plugin>
<class>org.jivesoftware.openfire.plugin.ExamplePlugin</class>
<name>Example</name>
<description>Example messages to users.</description>
<author>Jive Software</author>
<version>1.9.0</version>
<date>9/13/2013</date>
<url>http://www.igniterealtime.org</url>
<minServerVersion>3.9.0</minServerVersion>
</plugin>

4.运行后如图

openfire插件开发-简单插件

openfire插件开发-简单插件