The Spring DM provides the bundle listener interface Osgibundleapplicationcontextlistener

Source: Internet
Author: User

By using the monitoring interface provided by spring DM, we can better control the service, in fact, the interface is also very simple to use, as long as the custom of a class implementation of the Osgibundleapplicationcontextlistener interface, Implement the Onosgiapplicationevent method, and register the custom class as an OSGi service, perform the appropriate logic processing by judging the event type of events, and also obtain the bundles that are currently listening, thus achieving deeper monitoring.

 Public classListenerdemoImplementsosgibundleapplicationcontextlistener{@Override Public voidonosgiapplicationevent (Osgibundleapplicationcontextevent event) {String bundlename=Event.getbundle (). Getsymbolicname (); if(Eventinstanceofosgibundlecontextrefreshedevent) {//spring Context Creation Success Event System.out.println ("Service startup"); }Else if(Eventinstanceofosgibundlecontextclosedevent) {//spring context destroys event System.out.println ("Service Shutdown"); }    }}

<id= "Listenerdemo"  class= " Com.sample.service.listener.ListenerDemo "></bean>        < ref = "Listenerdemo"  interface= "   Org.springframework.osgi.context.event.OsgiBundleApplicationContextListener "/>

The bundle listener interface provided by Spring DM Osgibundleapplicationcontextlistener

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.