wu-sheng commented on code in PR #9828:
URL: https://github.com/apache/skywalking/pull/9828#discussion_r1001771163
##########
oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java:
##########
@@ -52,9 +52,28 @@ protected final ModuleManager getManager() {
public abstract Class<? extends ModuleDefine> module();
/**
- *
+ * Create a config creator to initialize this configuration of this module
provider
+ * @return creator instance to initialize the configuration with callback.
Or return null if no config is required.
*/
- public abstract ModuleConfig createConfigBeanIfAbsent();
+ public abstract ConfigCreator newConfigCreator();
+
+ /**
+ * Configuration creator to provide Module Config to initialize
+ * @param <T> class type of the config
+ */
+ public interface ConfigCreator<T extends ModuleConfig> {
+ /**
+ * Declare the type of the config class
+ * @return class type
+ */
+ Class<T> type();
+
+ /**
+ * Callback when the ModuleManager kernel has initialized this
configuration.
+ * @param initialized instance of the given {@link #type()}
+ */
+ void onInitialized(T initialized);
Review Comment:
> why do you say "it actually should not be heavily used by a provider."?
I mean to indicate config initialized as a stage like prepare and start.
>I doubt that they need to be "helpful", all these are lifecycle methods and
they should be invoked by the module manager only once.
My point is, I want to show config has its own initialization process, which
doesn't related to prepare, start and notifyAfterCompleted
In the current design, the boundaries of these three are
- prepare, initial things inside provider.
- start, booting with required modules initialized(prepared) services
- notifyAfterCompleted, process logic after all modules started.
If we add onConfigInitialized here, it means we should put some logic in it,
which leads to the confusion about, which logic should be in it, and why others
should be in prepare? They seem the same.
So, I added this config creator to set the boundaries that, only config
relative things should be placed in here. Such as we need to initial some
fields based on file configurations, because those fields are complex class,
can't be simply just set a value.
I hope this explanation could make the reason clear why I even did more
changes, rather than much simpler to add a new method on provider.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]