Skip to content

Commit

Permalink
format style
Browse files Browse the repository at this point in the history
  • Loading branch information
ihadoop committed Dec 23, 2024
1 parent d15a367 commit d19a13e
Showing 1 changed file with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.apache.amoro.utils;

import org.apache.amoro.table.TableMetaStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -30,27 +29,27 @@

public class ReflectionUtils {

private static final Logger LOG = LoggerFactory.getLogger(ReflectionUtils.class);
private static final Map<String, Class> CLASS_MAP = new HashMap<>();
private static final Logger LOG = LoggerFactory.getLogger(ReflectionUtils.class);
private static final Map<String, Class> CLASS_MAP = new HashMap<>();

public static Object invoke(String className, String methodName)
throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
Class<?> classRef =
CLASS_MAP.computeIfAbsent(
className,
key -> {
try {
return Class.forName(className);
} catch (ClassNotFoundException e) {
//ignore error
return null;
}
});
if (Objects.isNull(classRef)) {
LOG.warn("cannot load class {}, skip execute method {}" ,className, methodName);
return null;
}
Method method = classRef.getDeclaredMethod(methodName);
return method.invoke(null);
public static Object invoke(String className, String methodName)
throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
Class<?> classRef =
CLASS_MAP.computeIfAbsent(
className,
key -> {
try {
return Class.forName(className);
} catch (ClassNotFoundException e) {
// ignore error
return null;
}
});
if (Objects.isNull(classRef)) {
LOG.warn("cannot load class {}, skip execute method {}", className, methodName);
return null;
}
Method method = classRef.getDeclaredMethod(methodName);
return method.invoke(null);
}
}

0 comments on commit d19a13e

Please sign in to comment.