openfire插件开发-简单插件

来源:互联网 发布:阿里云 吉峰农机 编辑:程序博客网 时间:2024/06/09 22:18
 

openfire插件开发-简单插件

标签: openfirejava
 32人阅读 评论(0) 收藏 举报
 分类:

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


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



3.文件介绍

ExamplePlugin.Java

[java] view plain copy
  1. public class ExamplePlugin implements PacketInterceptor, Plugin {  
  2.   
  3.     private static PluginManager pluginManager;  
  4.     private InterceptorManager interceptoerManager;  
  5.     private String domain = JiveProperties.getInstance().get("xmpp.domain");  
  6.       
  7.       
  8.     public ExamplePlugin() {  
  9.         interceptoerManager = InterceptorManager.getInstance();  
  10.     }  
  11.   
  12.     @Override  
  13.     public void initializePlugin(PluginManager manager, File pluginDirectory) {  
  14.         pluginManager = manager;              
  15.         interceptoerManager.addInterceptor(this);  
  16.         System.out.println("Exampple add success");  
  17.         System.out.println("domain = " + domain);  
  18.     }  
  19.   
  20.     @Override  
  21.     public void destroyPlugin() {  
  22.         interceptoerManager.removeInterceptor(this);  
  23.         System.out.println("Exampple destroy success");  
  24.     }  
  25. }  


plugin.xml

[html] view plain copy
  1. <plugin>  
  2.     <class>org.jivesoftware.openfire.plugin.ExamplePlugin</class>  
  3.     <name>Example</name>  
  4.     <description>Example messages to users.</description>  
  5.     <author>Jive Software</author>  
  6.     <version>1.9.0</version>  
  7.     <date>9/13/2013</date>  
  8.     <url>http://www.igniterealtime.org</url>  
  9.     <minServerVersion>3.9.0</minServerVersion>      
  10. </plugin>  

4.运行后如图




原创粉丝点击