Openfire servlet plug-in

Source: Internet
Author: User

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 =.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.