In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is the role of ServiceBeanExportedEvent in dubbo? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
ServiceBeanExportedEvent
Dubbo-2.7.3/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/event/ServiceBeanExportedEvent.java
Public class ServiceBeanExportedEvent extends ApplicationEvent {/ * * Create a new ApplicationEvent. * * @ param serviceBean {@ link ServiceBean} bean * / public ServiceBeanExportedEvent (ServiceBean serviceBean) {super (serviceBean); / * Get {@ link ServiceBean} instance * * @ return non-null * / public ServiceBean getServiceBean () {return (ServiceBean) super.getSource ();}}
ServiceBeanExportedEvent inherits ApplicationEvent, and its source is ServiceBean
ServiceBean
Dubbo-2.7.3/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/ServiceBean.java
Public class ServiceBean extends ServiceConfig implements InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener, BeanNameAware, ApplicationEventPublisherAware {/ /. / * * @ since 2.6.5 * / @ Override public void export () {super.export (); / / Publish ServiceBeanExportedEvent publishExportEvent ();} / * * @ since 2.6.5 * / private void publishExportEvent () {ServiceBeanExportedEvent exportEvent = new ServiceBeanExportedEvent (this); applicationEventPublisher.publishEvent (exportEvent);} / /.}
The export method of ServiceBean will publishExportEvent
ReferenceAnnotationBeanPostProcessor
Dubbo-2.7.3/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessor.java
Public class ReferenceAnnotationBeanPostProcessor extends AnnotationInjectedBeanPostProcessor implements ApplicationContextAware, ApplicationListener {/ /. @ Override public void onApplicationEvent (ApplicationEvent event) {if (event instanceof ServiceBeanExportedEvent) {onServiceBeanExportEvent ((ServiceBeanExportedEvent) event);} else if (event instanceof ContextRefreshedEvent) {onContextRefreshedEvent ((ContextRefreshedEvent) event);}} private void onServiceBeanExportEvent (ServiceBeanExportedEvent event) {ServiceBean serviceBean = event.getServiceBean (); initReferenceBeanInvocationHandler (serviceBean) } private void initReferenceBeanInvocationHandler (ServiceBean serviceBean) {String serviceBeanName = serviceBean.getBeanName (); / / Remove ServiceBean when it's exported ReferenceBeanInvocationHandler handler = localReferenceBeanInvocationHandlerCache.remove (serviceBeanName); / / Initialize if (handler! = null) {handler.init ();}} / /.}
ReferenceAnnotationBeanPostProcessor implements the onApplicationEvent method of ApplicationListener, executes onServiceBeanExportEvent when the ServiceBeanExportedEvent event is received, removes it from localReferenceBeanInvocationHandlerCache, and then executes the init method of ReferenceBeanInvocationHandler
Summary
ServiceBeanExportedEvent inherits ApplicationEvent, and the export method whose source is ServiceBean;ServiceBean publishExportEvent;ReferenceAnnotationBeanPostProcessor implements the onApplicationEvent method of ApplicationListener, executes onServiceBeanExportEvent when the ServiceBeanExportedEvent event is received, here it is removed from localReferenceBeanInvocationHandlerCache, and then executes the init method of ReferenceBeanInvocationHandler
After reading the above, have you mastered the role of ServiceBeanExportedEvent in dubbo? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.