use of org.apache.kafka.connect.components.Versioned in project kafka by apache.
the class Plugins method newPlugin.
public <T> T newPlugin(String klassName, AbstractConfig config, Class<T> pluginKlass) {
T plugin;
Class<? extends T> klass;
try {
klass = pluginClass(delegatingLoader, klassName, pluginKlass);
} catch (ClassNotFoundException e) {
String msg = String.format("Failed to find any class that implements %s and which " + "name matches %s", pluginKlass, klassName);
throw new ConnectException(msg);
}
ClassLoader savedLoader = compareAndSwapLoaders(klass.getClassLoader());
try {
plugin = newPlugin(klass);
if (plugin instanceof Versioned) {
Versioned versionedPlugin = (Versioned) plugin;
if (Utils.isBlank(versionedPlugin.version())) {
throw new ConnectException("Version not defined for '" + klassName + "'");
}
}
if (plugin instanceof Configurable) {
((Configurable) plugin).configure(config.originals());
}
} finally {
compareAndSwapLoaders(savedLoader);
}
return plugin;
}
Aggregations