1.点击项目反键,新建source folder,并建相应的插件包org.jivesoftware.openfire.plugin
![](https://img-blog.csdn.net/20170322101821430?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hlbmhhbmRlMTk5MGNoZW5oYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
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.运行后如图
![](https://img-blog.csdn.net/20170322101841556?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hlbmhhbmRlMTk5MGNoZW5oYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
![](https://img-blog.csdn.net/20170322101852212?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hlbmhhbmRlMTk5MGNoZW5oYW4=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)