Package io.spine.logging.flogger.util
Class StaticMethodCaller
- java.lang.Object
-
- io.spine.logging.flogger.util.StaticMethodCaller
-
public final class StaticMethodCaller extends Object
Helper to call a no-arg constructor or static getter to obtain an instance of a specified type. This is used for logging platform "plugins". It is expected that these constructors/methods will be invoked once during logger initialization and then the results cached in the platform class (thus there is no requirement for the class being invoked to handle caching of the result).- See Also:
- Original Java code of Google Flogger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> @Nullable TgetInstanceFromSystemProperty(String propertyName, @Nullable String defaultValue, Class<T> type)Attempts to get an instance of the giventypethat is specified by the givenpropertyName, returningnullif that is not possible for any reason.static <T> TgetInstanceFromSystemProperty(String propertyName, Class<T> type)Attempts to get an instance of the giventypethat is specified by the givenpropertyName, returningnullif that is not possible for any reason.
-
-
-
Method Detail
-
getInstanceFromSystemProperty
public static <T> T getInstanceFromSystemProperty(String propertyName, Class<T> type)
Attempts to get an instance of the giventypethat is specified by the givenpropertyName, returningnullif that is not possible for any reason.The property's value, if present, is expected to be one of:
- A fully-qualified class name, in which case the instance is obtained by invoking the
class's no-arg static
getInstancemethod, if present, or public no-arg constructor. - A fully-qualified class name followed by
#and a method name, in which case the instance is obtained by invoking a no-arg static method of that name, if present, or a public no-arg constructor if not present.
- A fully-qualified class name, in which case the instance is obtained by invoking the
class's no-arg static
-
getInstanceFromSystemProperty
public static <T> @Nullable T getInstanceFromSystemProperty(String propertyName, @Nullable String defaultValue, Class<T> type)
Attempts to get an instance of the giventypethat is specified by the givenpropertyName, returningnullif that is not possible for any reason.The property's value, if present, or the given
defaultValue, is expected to be one of:- A fully-qualified class name, in which case the instance is obtained by invoking the
class's no-arg static
getInstancemethod, if present, or public no-arg constructor. - A fully-qualified class name followed by
#and a method name, in which case the instance is obtained by invoking a no-arg static method of that name, if present, or a public no-arg constructor if not present.
- A fully-qualified class name, in which case the instance is obtained by invoking the
class's no-arg static
-
-