MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / loadSpecificPlugin

Method loadSpecificPlugin

src/utils/PluginLoader.java:94–115  ·  view source on GitHub ↗

Searches the class path for the specific plugin of a given type Note: If you want to load JARs dynamically, you need to call #loadJAR or #loadJARs methods with the proper file or directory first, otherwise this will only search whatever was loaded on startup. WARNIN

(final String name, 
      final Class<T> type)

Source from the content-addressed store, hash-verified

92 * @throws IllegalArgumentException if the plugin name is null or empty
93 */
94 public static <T> T loadSpecificPlugin(final String name,
95 final Class<T> type) {
96 if (name.isEmpty()) {
97 throw new IllegalArgumentException("Missing plugin name");
98 }
99 ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
100 Iterator<T> it = serviceLoader.iterator();
101 if (!it.hasNext()) {
102 LOG.warn("Unable to locate any plugins of the type: " + type.getName());
103 return null;
104 }
105
106 while(it.hasNext()) {
107 T plugin = it.next();
108 if (plugin.getClass().getName().equals(name) || plugin.getClass().getSuperclass().getName().equals(name)) {
109 return plugin;
110 }
111 }
112
113 LOG.warn("Unable to locate plugin: " + name);
114 return null;
115 }
116
117 /**
118 * Searches the class path for implementations of the given type, returning a

Callers 11

loadSpecificPluginMethod · 0.95
loadHttpRpcPluginMethod · 0.95
beforeMethod · 0.95
beforeMethod · 0.95
beforeMethod · 0.95
loadStartupPluginsMethod · 0.95
HistogramCodecManagerMethod · 0.95
initializePluginsMethod · 0.95
createAndInitializeMethod · 0.95

Calls 6

isEmptyMethod · 0.80
iteratorMethod · 0.65
hasNextMethod · 0.65
getNameMethod · 0.65
nextMethod · 0.65
equalsMethod · 0.45

Tested by 7

loadSpecificPluginMethod · 0.76
loadHttpRpcPluginMethod · 0.76
beforeMethod · 0.76
beforeMethod · 0.76
beforeMethod · 0.76