@Override
public StoragePluginMetadata getPluginMetadata() throws PluginException
{
if (!this.getClass().isAnnotationPresent(Plugin.class))
{
throw new PluginException("Missing @Plugin annotation in " + this.getClass().getName());
}
Plugin pluginInfo = this.getClass().getAnnotation(Plugin.class);
if (pluginInfo.type() == null)
{
throw new PluginException("Plugin type can not be null in " + this.getClass().getName());
}
StoragePluginMetadata metadata = new StoragePluginMetadata();
metadata.setDefaultIscsiPort(pluginInfo.defaultIscsiPort());
metadata.setDefaultManagementPort(pluginInfo.defaultManagementPort());
metadata.setRequiresAuthentication(pluginInfo.requiresAuthentication());
metadata.setType(pluginInfo.type());
try
{
Method[] methods = StoragePlugin.class.getMethods();
for (Method methodDefinition : methods)
{
if (methodDefinition.isAnnotationPresent(Provides.class))
{
Method implMethod =
this.getClass().getMethod(methodDefinition.getName(),
methodDefinition.getParameterTypes());
if (!implMethod.isAnnotationPresent(UnsupportedOp.class))
{
Provides provides = methodDefinition.getAnnotation(Provides.class);
metadata.getSupportedOperations().add(provides.value());
}
}
}
}
catch (Exception ex)
{
throw new PluginException("Could not get the list of supported operations for plugin: "
+ this.getClass().getName());
}
return metadata;
}