Methods of using service layer in WebSocket

Source: Internet
Author: User

Create a public utils class

[Java]View PlainCopy
    1. Applicationcontextregister
[Java]View PlainCopy
  1. @Component
  2. @Lazy (false)
  3. Public class Applicationcontextregister implements Applicationcontextaware {
  4. private static ApplicationContext Application_context;
  5. /** 
  6. * Set Spring Context * * @param applicationcontext Spring context * @throws beansexception
  7. */
  8. @Override
  9. public void Setapplicationcontext (ApplicationContext applicationcontext) throws beansexception {
  10. Application_context = ApplicationContext;
  11. }
  12. public static ApplicationContext Getapplicationcontext () {
  13. return application_context;
  14. }
  15. }

[Java]View PlainCopy
    1. WebSocket using the service layer
    2. ApplicationContext act = applicationcontextregister.getapplicationcontext ();
    3. Messagelogservice=act.getbean (Messagelogservice.   Class);
    4. int resultlog = Messagelogservice.insertintomessagelog (MessageLog);

You can use the method in the service!!

Methods of using service layer in WebSocket

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.