OpenFire How to integrate spring MVC

Source: Internet
Author: User

The openfire Web server uses jetty, andthe jetty startup class is adminconsoleplugin, As to when the class is called, it is no longer mentioned.

OpenFireIntegrationSpring MVCThe key point is when you initializeDispatcherservlet. If you're going to putSpring MVCIntegration inOpenFireThe project is then directly fitted to theOpenFireof theWeb. XMLOK, but if you want to configure it in a plug-in, the following configuration process might help you a little bit. What you need.Jarthe package is downloaded online.

1) Create OpenFire plugin projects, there are a lot of examples online.

2) Configure web-custom.xml, note the path address of contextconfiglocation, and change it according to your own path.

3) Spring-actions.xml configuration, the package path that needs to be scanned is changed according to your own path.

4) Action class,spring MVC Action annotation class how to write no longer verbose, the point to note here is that@RequestMapping (value= "/ eraplugins/") be sure to add your plugin name path here, or spring MVC will not find this mapping.

5) to this plug-in this block is almost configured, and then build out first put aside, then modify openfire side of some things.

6) Find The Registerservlets method of the Pluginservlet class and add the parameters Pluginclassloader Pluginloader, add after the PlugInManager class will be error, in the place of error Pluginloader throw in.

7) return to the registerservlets method of the Pluginservlet class and find Object instance= Servletclass.nerinstance () this step.

Add such a piece of code

The main purpose here is,openfire registered plug-in itself did not parse the <init-param>, here to add their own, of course, only for Dispatcherservlet .

8) finish the above steps and then go down one line to find if (instance instanceof Genericservlet) { this step. Add a piece of code according to the code in the diagram.

to this openfire plug-in +spring MVC Configuration is completed, as for how to integrate Hibernate and Spring container temporarily only a clue, have not yet to verify.

Spring MVCthe configuration is primarily aDispatcherservletclass that scans the load for allController, the otherServiceand theEntityand so on is theContextloaderlisteneoperation, so if you want to putHibernateorSpringcontainers and so on configuration into the plug-in, probably will beContextloaderlistenethere's a fuss.

A little more.OpenFireabove the thing,OpenFireinvolves a lot of dynamic loading, such asplugin, so from the personal feeling aboveOpenFireThere are a lot of differentClassLoader, Load StartupOpenFireof the server isThread.CurrentThread (). Getcontextclassloader ();thisClassLoaderin theServerstarterhas becomeJiveclassloader (Openfierthe custom one),

thisClassLoaderfor the moment, we're going to be a mainline.ClassLoader, and thenpluginof theClassLoaderis aPluginloader = new Pluginclassloader ();LoadingJettythe timeNewOne, load the plugin you wrote and thenNewone. Instead of initializingDispatcherservletwhen loading the configuration file.ClassLoaderGets theThread.CurrentThread (). Getcontextclassloader ();So here we can see that the above changesPluginservletplayed a role. As for the specific process is no longer wordy, you can go to seeopenfiredof thePlugInManagerand thePluginservletthese two classes, and then go with anotherDispatcherservletthe source code.


OpenFire How to integrate spring MVC

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.