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

Method loadPlugins

src/utils/PluginLoader.java:136–154  ·  view source on GitHub ↗

Searches the class path for implementations of the given type, returning a list of all plugins that were found 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 searc

(final Class<T> type)

Source from the content-addressed store, hash-verified

134 * instantiated
135 */
136 public static <T> List<T> loadPlugins(final Class<T> type) {
137 ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
138 Iterator<T> it = serviceLoader.iterator();
139 if (!it.hasNext()) {
140 LOG.warn("Unable to locate any plugins of the type: " + type.getName());
141 return null;
142 }
143
144 ArrayList<T> plugins = new ArrayList<T>();
145 while(it.hasNext()) {
146 plugins.add(it.next());
147 }
148 if (plugins.size() > 0) {
149 return plugins;
150 }
151
152 LOG.warn("Unable to locate plugins for type: " + type.getName());
153 return null;
154 }
155
156 /**
157 * Attempts to load the given jar into the class path

Callers 4

loadPluginsMethod · 0.95
loadPluginsNotFoundMethod · 0.95
initializeFilterMapMethod · 0.95

Calls 6

iteratorMethod · 0.65
hasNextMethod · 0.65
getNameMethod · 0.65
nextMethod · 0.65
sizeMethod · 0.65
addMethod · 0.45

Tested by 2

loadPluginsMethod · 0.76
loadPluginsNotFoundMethod · 0.76