소스 검색

Fix Sonar warning

plugin_context
Decebal Suiu 1 년 전
부모
커밋
5b7705d86b
1개의 변경된 파일15개의 추가작업 그리고 10개의 파일을 삭제
  1. 15
    10
      pf4j/src/main/java/org/pf4j/DefaultPluginFactory.java

+ 15
- 10
pf4j/src/main/java/org/pf4j/DefaultPluginFactory.java 파일 보기

@@ -59,18 +59,23 @@ public class DefaultPluginFactory implements PluginFactory {
return createInstance(pluginClass, pluginWrapper);
}

/**
* Creates a plugin instance. If an error occurs than that error is logged and the method returns {@code null}.
*/
protected Plugin createInstance(Class<?> pluginClass, PluginWrapper pluginWrapper) {
try {
try {
Constructor<?> constructor = pluginClass.getConstructor(PluginWrapper.class);
return (Plugin) constructor.newInstance(pluginWrapper);
} catch (NoSuchMethodException e) {
Constructor<?> constructor = pluginClass.getConstructor();
return (Plugin) constructor.newInstance();
}
Constructor<?> constructor = pluginClass.getConstructor(PluginWrapper.class);
return (Plugin) constructor.newInstance(pluginWrapper);
} catch (NoSuchMethodException e) {
return createUsingNoParametersConstructor(pluginClass);
} catch (Exception e) {
log.error(e.getMessage(), e);
}

return null;
}

protected Plugin createUsingNoParametersConstructor(Class<?> pluginClass) {
try {
Constructor<?> constructor = pluginClass.getConstructor();
return (Plugin) constructor.newInstance();
} catch (Exception e) {
log.error(e.getMessage(), e);
}

Loading…
취소
저장