openfire插件开发-简单插件
版权声明:本文为博主原创文章,未经博主允许不得转载。
1.点击项目反键,新建source folder,并建相应的插件包org.jivesoftware.openfire.plugin
2.建完后在src/plugins下面会出现example文件夹,并按照如下目录新建对应的文件:
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.运行后如图