pandaapo commented on code in PR #4477:
URL: https://github.com/apache/eventmesh/pull/4477#discussion_r1358110864


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/Application.java:
##########
@@ -35,11 +37,20 @@ public class Application {
 
     public static final Map<String, Connector> CONNECTOR_MAP = new HashMap<>();
 
+    private static final String SPRING = "spring";
+
     public void run(Class<? extends Connector> clazz) throws Exception {
 
-        Connector connector;
+        Connector connector = null;
         try {
-            connector = clazz.getDeclaredConstructor().newInstance();
+            SourceCreateService createService =
+                
EventMeshExtensionFactory.getExtension(SourceCreateService.class, SPRING);
+            if (createService != null) {
+                connector = createService.create();
+            }
+            if (connector == null) {
+                connector = clazz.getDeclaredConstructor().newInstance();
+            }

Review Comment:
   In `Application`, in order to create a specific type of `Connector`, namely 
the Spring Source Connector, the logic of "loading SPI with the specified name 
of Spring" is added.
   Is there some limitation to `Application`? Because `Application` should be a 
class independent of specific connectors, it is hard to create other specific 
types of connectors after this modification (your SPI is also designed for 
other types of connectors).
   
   ---
   在`Application`这个类中为了创建某一特定类型的`Connector`,即Spring Source 
Connector,加入“加载指定名称为Spring的SPI”的逻辑。
   
是不是使这个类出现了某种限制?因为`Application`应该是独立于具体Connector之上的一个类,这样写了以后,若再出现其他特定类型的Connector需要创建就不好办了(你的SPI也是为了其他类型Connector所设计的)。



##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/Application.java:
##########
@@ -35,11 +37,20 @@ public class Application {
 
     public static final Map<String, Connector> CONNECTOR_MAP = new HashMap<>();
 
+    private static final String SPRING = "spring";
+
     public void run(Class<? extends Connector> clazz) throws Exception {
 
-        Connector connector;
+        Connector connector = null;
         try {
-            connector = clazz.getDeclaredConstructor().newInstance();
+            SourceCreateService createService =
+                
EventMeshExtensionFactory.getExtension(SourceCreateService.class, SPRING);
+            if (createService != null) {
+                connector = createService.create();
+            }
+            if (connector == null) {
+                connector = clazz.getDeclaredConstructor().newInstance();
+            }

Review Comment:
   In `Application`, in order to create a specific type of `Connector`, namely 
the Spring Source Connector, the logic of "loading SPI with the specified name 
of Spring" is added.
   Is there some limitation to `Application`? Because `Application` should be a 
class independent of specific connectors, it is hard to create other specific 
types of connectors after this modification (your SPI is also designed for 
other types of connectors).
   
   ---
   在`Application`这个类中为了创建某一特定类型的`Connector`,即Spring Source 
Connector,加入“加载指定名称为Spring的SPI”的逻辑。
   
是不是使这个类出现了某种限制?因为`Application`应该是独立于具体Connector之上的一个类,这样写了以后,若再出现其他特定类型的Connector需要创建就不好办了(你的SPI也是为了其他类型Connector所设计的)。



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to