umustafi commented on code in PR #3899:
URL: https://github.com/apache/gobblin/pull/3899#discussion_r1540277722


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/core/GobblinServiceManager.java:
##########
@@ -251,12 +252,23 @@ public static GobblinServiceManager create(String 
serviceName, String serviceId,
   }
 
   public static GobblinServiceManager create(GobblinServiceConfiguration 
serviceConfiguration) {
-    GobblinServiceGuiceModule guiceModule = new 
GobblinServiceGuiceModule(serviceConfiguration);
+    GOBBLIN_SERVICE_GUICE_MODULE = new 
GobblinServiceGuiceModule(serviceConfiguration);
 
-    Injector injector = Guice.createInjector(Stage.PRODUCTION, guiceModule);
+    Injector injector = Guice.createInjector(Stage.PRODUCTION, 
GOBBLIN_SERVICE_GUICE_MODULE);
     return injector.getInstance(GobblinServiceManager.class);
   }
 
+  /**
+   *
+   * @param classToGet
+   * @return a new object if the class type is not marked with @Singleton, 
otherwise the same instance of the class
+   * @param <T>
+   */
+  public static <T> T getClass(Class<T> classToGet) {
+    Injector injector = Guice.createInjector(Stage.PRODUCTION, 
GOBBLIN_SERVICE_GUICE_MODULE);
+    return injector.getInstance(classToGet);
+  }

Review Comment:
   I added a check to throw a runtime exception and modified the main method of 
this class to call the `create` method above which looks like was only used for 
testing previously. We can either catch the error and log an error or stop the 
app. 



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

Reply via email to