Skip to content

DubboNamespaceHandler 注册监听方法 registerApplicationListeners #6275

@Kookey

Description

@Kookey
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.7
  • Operating System version: macOS Mojave
  • Java version: 1.8
 @Override
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        ...
        registerApplicationListeners(registry);
        ...
private void registerApplicationListeners(BeanDefinitionRegistry registry) {
        registerBeans(registry, DubboLifecycleComponentApplicationListener.class);
        registerBeans(registry, DubboBootstrapApplicationListener.class);
}

解析每一个element节点都会调用registerApplicationListeners方法,虽然在registerBeans中是有判断
bean是否已经注册过了,如果注册就忽略,但是可以在registerApplicationListeners方法中判断下,如果已经存在了就不再调用registerBeans方法了

private void registerApplicationListeners(BeanDefinitionRegistry registry) {
         if (!isPresentBean(registry, DubboLifecycleComponentApplicationListener.class)) {
                registerBeans(registry, DubboLifecycleComponentApplicationListener.class);
         }
        if (!isPresentBean(registry, DubboBootstrapApplicationListener.class)) {
                registerBeans(registry, DubboBootstrapApplicationListener.class);
         }
}

Just put your stack trace here!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions