In the project, openfire must provide an external web interface to accept HTTP requests sent from the client, and return corresponding response after processing according to parameters.
Therefore, we consider using the servlet plug-in.
Implementation Method:
1. Create a directory with the following structure under the src/Plugins directory.
2. Add the myservlet/src/Java directory on the Source Page of the Java build path.
3. Create the class myservletplugin under the org. jivesoftware. openfire. plugin package to implement the plugin interface; create the org. jivesoftware. openfire. plugin. myservlet package, and create a new myservlet class under the package to inherit httpservlet.
4. Rewrite doget (), dopost (), INIT (), and destroy () in myservlet, and implement your own functions in the corresponding part.
Add authcheckfilter. addexclude ("Myservlet/myserv") The format here is [plug-in directory name]/[Sub-url] instead of" [servlet directory name]/[Sub-url]"
Add authcheckfilter. removeexclude ("Myservlet/myserv")
5. Create plugin. xml under myservlet/src with the following content:
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <plugin> <br/> <class> Org. jivesoftware. openfire. plugin. myservletplugin </class> <br/> <Name> my servlet </Name> <br/> <description> Web </description> <br/> <author> myname </ author> <br/> <version> 1.0.0 </version> <br/> <date> 09/08/2011 </date> <br/> <minserverversion> 3.5.1 </minserverversion> <br /> </plugin> <br/>
6. Create a web-custom.xml in the Web-info directory with the following content:
<textarea readonly name="code" class="html"><? XML version = '1. 0' encoding = 'iso-8859-1 '?> <Br/> <! Doctype web-app public "-// Sun Microsystems, Inc. // DTD web application 2.3 // "" http://java.sun.com/dtd/web-app_2_3.dtd "> <br/> <web-app> <br/> <! -- Servlets --> <br/> <servlet-Name> myservlet </servlet-Name> <br/> <servlet-class> Org. jivesoftware. openfire. plugin. myservlet. myservlet </servlet-class> <br/> </servlet> </P> <p> <! -- Servlet mappings --> <br/> <servlet-mapping> <br/> <servlet-Name> myservlet </servlet-Name> <br/> <URL-pattern>/ myserv </url-pattern> <br/> </servlet-mapping> </P> <p> </Web-app></textarea>
7. Open the command line cmd, go to the build directory under the source code, and run the ant plugins compilation plug-in. A myservlet. jar file is generated in the target/plugin directory.
8. Start openfire and load the plug-in.
9. In the browser, enter http: // ***. ***. ***: 9090/plugin/myservlet/myserv? Par1 = ** & par2 =.