高傲的活着 发表于 2011-12-21 08:44

openfire3.7插件开发方法

<DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo><FONT color=#f00000 size=3>作用:初始化时在控制台打印测试消息</FONT>。</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo><FONT color=#f000f0 size=3>开发环境</FONT>:<FONT color=#f00000 size=2>winxp/eclipse3.6/jdk1.5&amp;1.6/mysql5.0/openfire3.7</FONT></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title><FONT color=#f000f0 size=3>开发步骤</FONT>:</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title><FONT color=#f00000>1. 布署openfire3.7源码</FONT></DIV></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo><FONT color=#f00000 size=2></FONT>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo><A href="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201105/23/25434387_1306152930n499.jpg" target=_blank><IMG border=0 src="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201105/23/25434387_1306152930n499.jpg" ; .load="imgResize(this, 650);"></A></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title>2.<FONT color=#f00000> src/plugins目录下新建文件夹itvi。并按下图的目录结构新建对应的文件</FONT>。</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title><A href="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201105/23/25434387_1306153204rsuE.jpg" target=_blank><IMG border=0 src="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201105/23/25434387_1306153204rsuE.jpg" ; .load="imgResize(this, 650);"></A></DIV></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=todo>
<DIV class=contentCodeFont><FONT color=#f00000>plugin.xml文件代码如下:</FONT></DIV>
<DIV class=contentCodeFont>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000"><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">?</SPAN>xml version<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"1.0"</SPAN> encoding<SPAN style="COLOR: #0000cc">=</SPAN><SPAN style="COLOR: #ff00ff">"UTF-8"</SPAN><SPAN style="COLOR: #0000cc">?</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN>plugin<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #ff0000">class</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN>org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>plugin<SPAN style="COLOR: #0000cc">.</SPAN>Itvi<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #ff0000">class</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN>Itvi<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN>description<SPAN style="COLOR: #0000cc">&gt;</SPAN>Broadcasts messages to users<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>description<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN>author<SPAN style="COLOR: #0000cc">&gt;</SPAN>openfireteam<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>author<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #ff0000">version</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN>1<SPAN style="COLOR: #0000cc">.</SPAN>7<SPAN style="COLOR: #0000cc">.</SPAN>0<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #ff0000">version</SPAN><SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN>date<SPAN style="COLOR: #0000cc">&gt;</SPAN>2<SPAN style="COLOR: #0000cc">/</SPAN>19<SPAN style="COLOR: #0000cc">/</SPAN>2009<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>date<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN>url<SPAN style="COLOR: #0000cc">&gt;</SPAN>http<SPAN style="COLOR: #0000cc">:</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>openfireteam<SPAN style="COLOR: #0000cc">.</SPAN>blogjava<SPAN style="COLOR: #0000cc">.</SPAN>net<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>url<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN>minServerVersion<SPAN style="COLOR: #0000cc">&gt;</SPAN>3<SPAN style="COLOR: #0000cc">.</SPAN>6<SPAN style="COLOR: #0000cc">.</SPAN>3<SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>minServerVersion<SPAN style="COLOR: #0000cc">&gt;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">&lt;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>plugin<SPAN style="COLOR: #0000cc">&gt;</SPAN></SPAN></LI></OL></DIV></DIV>
<DIV class=contentCodeFont>
<DIV class=contentCodeFont><FONT color=#f00000>Itvi.java文件代码如下</FONT>:</DIV>
<DIV class=contentCodeFont>&nbsp;</DIV></DIV>
<DIV class=contentCodeFont>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000">package org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>plugin<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>dom4j<SPAN style="COLOR: #0000cc">.</SPAN>Element<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>IQHandlerInfo<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>handler<SPAN style="COLOR: #0000cc">.</SPAN>IQHandler<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>auth<SPAN style="COLOR: #0000cc">.</SPAN>UnauthorizedException<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> 处理客户端发来的IQ,并回送结果IQ<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">@</SPAN>author Phoenix<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> Mar 14<SPAN style="COLOR: #0000cc">,</SPAN> 2008 4<SPAN style="COLOR: #0000cc">:</SPAN>55<SPAN style="COLOR: #0000cc">:</SPAN>33 PM<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #ff0000">version</SPAN> 0<SPAN style="COLOR: #0000cc">.</SPAN>1<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>dom4j<SPAN style="COLOR: #0000cc">.</SPAN>DocumentHelper<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>dom4j<SPAN style="COLOR: #0000cc">.</SPAN>Element<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>dom4j<SPAN style="COLOR: #0000cc">.</SPAN>QName<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>XMPPServer<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>container<SPAN style="COLOR: #0000cc">.</SPAN>Plugin<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>container<SPAN style="COLOR: #0000cc">.</SPAN>PluginManager<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>disco<SPAN style="COLOR: #0000cc">.</SPAN>IQDiscoInfoHandler<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>disco<SPAN style="COLOR: #0000cc">.</SPAN>IQDiscoItemsHandler<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>forms<SPAN style="COLOR: #0000cc">.</SPAN>DataForm<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>forms<SPAN style="COLOR: #0000cc">.</SPAN>FormField<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>forms<SPAN style="COLOR: #0000cc">.</SPAN>spi<SPAN style="COLOR: #0000cc">.</SPAN>XDataFormImpl<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>forms<SPAN style="COLOR: #0000cc">.</SPAN>spi<SPAN style="COLOR: #0000cc">.</SPAN>XFormFieldImpl<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>resultsetmanager<SPAN style="COLOR: #0000cc">.</SPAN>ResultSet<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>resultsetmanager<SPAN style="COLOR: #0000cc">.</SPAN>ResultSetImpl<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>user<SPAN style="COLOR: #0000cc">.</SPAN>User<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>user<SPAN style="COLOR: #0000cc">.</SPAN>UserManager<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>user<SPAN style="COLOR: #0000cc">.</SPAN>UserNotFoundException<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>util<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>component<SPAN style="COLOR: #0000cc">.</SPAN>Component<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>component<SPAN style="COLOR: #0000cc">.</SPAN>ComponentException<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>component<SPAN style="COLOR: #0000cc">.</SPAN>ComponentManager<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>component<SPAN style="COLOR: #0000cc">.</SPAN>ComponentManagerFactory<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>IQ<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>IQ<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">Type</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>JID<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>Packet<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>PacketError<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>PacketError<SPAN style="COLOR: #0000cc">.</SPAN>Condition<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> java<SPAN style="COLOR: #0000cc">.</SPAN>io<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">File</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> java<SPAN style="COLOR: #0000cc">.</SPAN>util<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> java<SPAN style="COLOR: #0000cc">.</SPAN>util<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000ff">Map</SPAN><SPAN style="COLOR: #0000cc">.</SPAN>Entry<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>public <SPAN style="COLOR: #ff0000">class</SPAN> Itvi implements Plugin<BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>private XMPPServer <SPAN style="COLOR: #0000ff">server</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN>non<SPAN style="COLOR: #0000cc">-</SPAN>Javadoc<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">@</SPAN>see org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>container<SPAN style="COLOR: #0000cc">.</SPAN>Plugin<SPAN style="COLOR: #0000cc">#</SPAN>destroyPlugin<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI>public void destroyPlugin<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN>non<SPAN style="COLOR: #0000cc">-</SPAN>Javadoc<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">@</SPAN>see org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>container<SPAN style="COLOR: #0000cc">.</SPAN>Plugin<SPAN style="COLOR: #0000cc">#</SPAN>initializePlugin<SPAN style="COLOR: #0000cc">(</SPAN>org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>container<SPAN style="COLOR: #0000cc">.</SPAN>PluginManager<SPAN style="COLOR: #0000cc">,</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> java<SPAN style="COLOR: #0000cc">.</SPAN>io<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">File</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI>public void initializePlugin<SPAN style="COLOR: #0000cc">(</SPAN>PluginManager manager<SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #ff0000">File</SPAN> pluginDirectory<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">server</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> XMPPServer<SPAN style="COLOR: #0000cc">.</SPAN>getInstance<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000ff">server</SPAN><SPAN style="COLOR: #0000cc">.</SPAN>getIQRouter<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">.</SPAN>addHandler<SPAN style="COLOR: #0000cc">(</SPAN>new ItviIQHander<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN> <SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI>System<SPAN style="COLOR: #0000cc">.</SPAN>out<SPAN style="COLOR: #0000cc">.</SPAN>println<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"测试插件启动成功"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN></SPAN></LI></OL></DIV></DIV>
<DIV class=contentCodeFont>最后输出语句“测试插件启动成功”在控制台显示乱码,将此改为""</DIV></DIV></DIV>
<P><FONT color=#f00000>ItviIQHander.java文件代码如下:</FONT></P>
<DIV id=codeText class=codeText>
<OL style="PADDING-BOTTOM: 5px; MARGIN: 0px 1px 0px 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 5px" class=dp-css>
<LI><SPAN style="COLOR: #000000">package org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>plugin<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>dom4j<SPAN style="COLOR: #0000cc">.</SPAN>Element<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>IQHandlerInfo<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>handler<SPAN style="COLOR: #0000cc">.</SPAN>IQHandler<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">import</SPAN> org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>auth<SPAN style="COLOR: #0000cc">.</SPAN>UnauthorizedException<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> 处理客户端发来的IQ,并回送结果IQ<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">@</SPAN>author Phoenix<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> Mar 14<SPAN style="COLOR: #0000cc">,</SPAN> 2008 4<SPAN style="COLOR: #0000cc">:</SPAN>55<SPAN style="COLOR: #0000cc">:</SPAN>33 PM <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #ff0000">version</SPAN> 0<SPAN style="COLOR: #0000cc">.</SPAN>1<BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI>public <SPAN style="COLOR: #ff0000">class</SPAN> ItviIQHander <SPAN style="COLOR: #ff0000">extends</SPAN> IQHandler<BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>private static final String MODULE_NAME <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"group tree handler"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>private static final String NAME_SPACE <SPAN style="COLOR: #0000cc">=</SPAN> <SPAN style="COLOR: #ff00ff">"com:im:group"</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>private IQHandlerInfo <SPAN style="COLOR: #ff0000">info</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>public ItviIQHander<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>super<SPAN style="COLOR: #0000cc">(</SPAN>MODULE_NAME<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #ff0000">info</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> new IQHandlerInfo<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"gruops"</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> NAME_SPACE<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #ff0000">info</SPAN> <SPAN style="COLOR: #0000cc">=</SPAN> new IQHandlerInfo<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"query"</SPAN><SPAN style="COLOR: #0000cc">,</SPAN> <SPAN style="COLOR: #ff00ff">"jabber:iq:roster"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>这里我们对”联系人”的IQ进入监控<BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN>non<SPAN style="COLOR: #0000cc">-</SPAN>Javadoc<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">@</SPAN>see org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>handler<SPAN style="COLOR: #0000cc">.</SPAN>IQHandler<SPAN style="COLOR: #0000cc">#</SPAN>getInfo<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">@</SPAN>Override<BR></LI>
<LI>public IQHandlerInfo getInfo<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>return <SPAN style="COLOR: #ff0000">info</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">*</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">(</SPAN>non<SPAN style="COLOR: #0000cc">-</SPAN>Javadoc<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN> <SPAN style="COLOR: #0000cc">@</SPAN>see org<SPAN style="COLOR: #0000cc">.</SPAN>jivesoftware<SPAN style="COLOR: #0000cc">.</SPAN>openfire<SPAN style="COLOR: #0000cc">.</SPAN>handler<SPAN style="COLOR: #0000cc">.</SPAN>IQHandler<SPAN style="COLOR: #0000cc">#</SPAN>handleIQ<SPAN style="COLOR: #0000cc">(</SPAN>org<SPAN style="COLOR: #0000cc">.</SPAN>xmpp<SPAN style="COLOR: #0000cc">.</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>IQ<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">*</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">@</SPAN>Override<BR></LI>
<LI>public IQ handleIQ<SPAN style="COLOR: #0000cc">(</SPAN>IQ packet<SPAN style="COLOR: #0000cc">)</SPAN> throws UnauthorizedException<BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>IQ reply <SPAN style="COLOR: #0000cc">=</SPAN> IQ<SPAN style="COLOR: #0000cc">.</SPAN>createResultIQ<SPAN style="COLOR: #0000cc">(</SPAN>packet<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>Element groups <SPAN style="COLOR: #0000cc">=</SPAN> packet<SPAN style="COLOR: #0000cc">.</SPAN>getChildElement<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>1<BR></LI>
<LI>if <SPAN style="COLOR: #0000cc">(</SPAN>true<SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>System<SPAN style="COLOR: #0000cc">.</SPAN>out<SPAN style="COLOR: #0000cc">.</SPAN>println<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"非法的请求类型111111"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><BR></LI>
<LI>if <SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">!</SPAN>IQ<SPAN style="COLOR: #0000cc">.</SPAN><SPAN style="COLOR: #ff0000">Type</SPAN><SPAN style="COLOR: #0000cc">.</SPAN>get<SPAN style="COLOR: #0000cc">.</SPAN>equals<SPAN style="COLOR: #0000cc">(</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>getType<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">{</SPAN><BR></LI>
<LI>System<SPAN style="COLOR: #0000cc">.</SPAN>out<SPAN style="COLOR: #0000cc">.</SPAN>println<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"非法的请求类型"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>reply<SPAN style="COLOR: #0000cc">.</SPAN>setChildElement<SPAN style="COLOR: #0000cc">(</SPAN>groups<SPAN style="COLOR: #0000cc">.</SPAN>createCopy<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>System<SPAN style="COLOR: #0000cc">.</SPAN>out<SPAN style="COLOR: #0000cc">.</SPAN>println<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"返回的最终XML-SetError前"</SPAN><SPAN style="COLOR: #0000cc">+</SPAN>reply<SPAN style="COLOR: #0000cc">.</SPAN>toXML<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>reply<SPAN style="COLOR: #0000cc">.</SPAN>setError<SPAN style="COLOR: #0000cc">(</SPAN>PacketError<SPAN style="COLOR: #0000cc">.</SPAN>Condition<SPAN style="COLOR: #0000cc">.</SPAN>bad_request<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>System<SPAN style="COLOR: #0000cc">.</SPAN>out<SPAN style="COLOR: #0000cc">.</SPAN>println<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"返回的最终XML-SetError后"</SPAN><SPAN style="COLOR: #0000cc">+</SPAN>reply<SPAN style="COLOR: #0000cc">.</SPAN>toXML<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>return reply<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>String userName <SPAN style="COLOR: #0000cc">=</SPAN> StringUtils<SPAN style="COLOR: #0000cc">.</SPAN>substringBefore<SPAN style="COLOR: #0000cc">(</SPAN>packet<SPAN style="COLOR: #0000cc">.</SPAN>getFrom<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">.</SPAN>toString<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">,</SPAN><SPAN style="COLOR: #ff00ff">"@"</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>GroupManager<SPAN style="COLOR: #0000cc">.</SPAN>getInstance<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">.</SPAN>initElement<SPAN style="COLOR: #0000cc">(</SPAN>groups<SPAN style="COLOR: #0000cc">,</SPAN>userName<SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>reply<SPAN style="COLOR: #0000cc">.</SPAN>setChildElement<SPAN style="COLOR: #0000cc">(</SPAN>groups<SPAN style="COLOR: #0000cc">.</SPAN>createCopy<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>2<BR></LI>
<LI><SPAN style="COLOR: #0000cc">/</SPAN><SPAN style="COLOR: #0000cc">/</SPAN>System<SPAN style="COLOR: #0000cc">.</SPAN>out<SPAN style="COLOR: #0000cc">.</SPAN>println<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #ff00ff">"返回的最终XML"</SPAN> reply<SPAN style="COLOR: #0000cc">.</SPAN>toXML<SPAN style="COLOR: #0000cc">(</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">)</SPAN><SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI>return reply<SPAN style="COLOR: #0000cc">;</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN><BR></LI>
<LI><SPAN style="COLOR: #0000cc">}</SPAN></SPAN></LI></OL></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title><FONT color=#f000f0>3.打包插件</FONT></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content><FONT color=#f00000>a.第一次打包需配置ant工具。在环境变量中</FONT>,
<P style="LINE-HEIGHT: 19px; TEXT-INDENT: 20px; MARGIN: 10px 0px; FONT-SIZE: 13px">添加 path=C:\Program Files\Java\jdk1.5.0_09\;D:\Program Files\MyEclipse6.5\eclipse\plugins\org.apache.ant_1.7.0.v200706080842\bin (如果原来有path,在变量值的尾部添加半角分号 ; 然后再加入上面的jdk和ant路径 )</P>
<P style="LINE-HEIGHT: 19px; TEXT-INDENT: 20px; MARGIN: 10px 0px; FONT-SIZE: 13px"><FONT color=#f00000>b.编译</FONT></P>
<P style="LINE-HEIGHT: 19px; TEXT-INDENT: 20px; MARGIN: 10px 0px; FONT-SIZE: 13px">进入cmd,进入 openfire/build所在目录:输入命令:ant&nbsp;plugins 等待执行完,而且没有报错,说明打包成功。在openfire3.6.3\target\openfire\plugins目录下就生成了itvi.jar</P></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content_title><FONT color=#f000f0>4.测试</FONT></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content>启动openfire ,如发现控制台输出“测试插件启动成功”,说明插件开发成功。</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content>转自:<A href="http://www.blogjava.net/duanzhimin528/archive/2010/07/14/326146.html" target=_blank>http://www.blogjava.net/duanzhimin528/archive/2010/07/14/326146.html</A></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content><FONT color=#f000f0>注:这是第一次开发插件,纠结中成功!但是控制台没有打印出“测试插件启动成功”信息!待研究。。。</FONT></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content><FONT color=#f000f0><FONT color=#f00000>问题解决:</FONT></FONT></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content><FONT color=#f00000>主要是控制台不打印汉字,改为英语,一切OK!以下是运行效果:</FONT></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content><a href="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201105/23/25434387_1306157911kT44.jpg" target="_blank"><IMG border=0 src="http://blog.chinaunix.nethttp://blog.chinaunix.net/attachment/201105/23/25434387_1306157911kT44.jpg" .load="imgResize(this, 650);" ;></A></DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content>&nbsp;</DIV>
<DIV style="LINE-HEIGHT: 16px; FONT-FAMILY: Verdana, Geneva, Arial, Helvetica, sans-serif; FONT-SIZE: 13px" class=content><FONT color=#f00000></FONT>&nbsp;</DIV></DIV></DIV>
页: [1]
查看完整版本: openfire3.7插件开发方法