Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于ClassInjectDefine中factoryName为空的问题 #1596

Closed
AYue-94 opened this issue Aug 10, 2024 · 7 comments
Closed

关于ClassInjectDefine中factoryName为空的问题 #1596

AYue-94 opened this issue Aug 10, 2024 · 7 comments
Labels
kind/question Further information is requested

Comments

@AYue-94
Copy link

AYue-94 commented Aug 10, 2024

What do you want to ask?

image

  1. 在低版本中,plugin中的类由appclassloader加载,为了使用springboot的接口需要用springboot类加载器加载;
  2. 在高版本中,plugin中的类由pluginclassloader加载,pluginclassloader内部可以用线程类加载器加载到springboot的api;
    高版本是否可以不用再声明factoryName为空的ClassInjectDefine?
@AYue-94 AYue-94 added the kind/question Further information is requested label Aug 10, 2024
@Issues-translate-bot
Copy link

Detect the issue's language is not English and translate it automatically.


Title: About the problem that factoryName in ClassInjectDefine is empty

What do you want to ask?

image

  1. In the lower version, the classes in the plugin are loaded by appclassloader. In order to use the springboot interface, you need to use the springboot classloader to load;
  2. In higher versions, the classes in the plugin are loaded by the pluginclassloader, and the thread classloader can be used inside the pluginclassloader to load to the springboot api;
    Is it possible to no longer declare ClassInjectDefine with empty factoryName in later versions?

@hanbingleixue
Copy link
Collaborator

@AYue-94 ClassInjectDefine is declared to ensure that these classes can be loaded through the class loader of the host. In later versions, ClassInjectDefine with empty factoryName also needs to be declared.

@AYue-94
Copy link
Author

AYue-94 commented Aug 13, 2024

I try to remove ClassInjectDefine with empty factoryName, for example in dynamic-config-plugin.
image
and the host springboot application can works well with dynamic-config-plugin.

for example:

  1. springboot LaunchedURLClassLoader load SpringEnvironmentProcessor but fail. fallback, Sermant ClassLoaderLoadClassInterceptor use PluginClassLoader load SpringEnvironmentProcessor, success;
  2. when SpringEnvironmentProcessor new DynamicConfigPropertySource will use PluginClassLoader too, its ok to find DynamicConfigPropertySource;
  3. DynamicConfigPropertySource implement springboot EnumerablePropertySource interface, EnumerablePropertySource is in LaunchedURLClassLoader, so PluginClassLoader fallback use thread context classloader load EnumerablePropertySource success;

so why need to declare DynamicConfigPropertySource in ClassInjectDefine with empty factoryName ?
image

@hanbingleixue
Copy link
Collaborator

@AYue-94 These classes are loaded by the host to shield the original configuration center of the host. If these classes are not declared, the host can run properly, but the functions are affected.

@AYue-94
Copy link
Author

AYue-94 commented Aug 16, 2024

what does "functions are affected" mean? can you give me some example? I'm very confusion

@hanbingleixue
Copy link
Collaborator

@AYue-94 For example, the dynamic-config-plugin cannot shield the original configuration center after removing these declarations.

@hanbingleixue
Copy link
Collaborator

Answers have been provided, and no other questions are available. Therefore, this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants