wwj-go commented on a change in pull request #1567:
URL:
https://github.com/apache/shardingsphere-elasticjob/pull/1567#discussion_r507029272
##########
File path:
elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/spi/ElasticJobServiceLoader.java
##########
@@ -106,33 +61,42 @@ private static Object newServiceInstance(final Class<?>
clazz) {
/**
* Get cached instance.
*
- * @param typedService service type
+ * @param typedServiceInterface typed service interface
* @param type specific service type
* @param <T> specific type of service
* @return cached service instance
*/
- public static <T extends TypedSPI> T getCachedInstance(final Class<T>
typedService, final String type) {
- T instance = TYPED_SERVICES.containsKey(typedService) ? (T)
TYPED_SERVICES.get(typedService).get(type) : null;
+ public static <T extends TypedSPI> Optional<T>
getCachedTypedServiceInstance(final Class<T> typedServiceInterface, final
String type) {
+ T instance = TYPED_SERVICES.containsKey(typedServiceInterface) ? (T)
TYPED_SERVICES.get(typedServiceInterface).get(type) : null;
Review comment:
That looks good.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]