@Override
@SuppressWarnings("unchecked")
- public <T> List<ExtensionWrapper<T>> find(Class<T> type) {
- log.debug("Finding extensions of extension point '{}'", type.getName());
+ public <T> List<ExtensionWrapper<T>> find(Class<T> type) {
+ log.debug("Finding extensions of extension point '{}'", type.getName());
Map<String, Set<String>> entries = getEntries();
List<ExtensionWrapper<T>> result = new ArrayList<>();
}
if (entries.isEmpty()) {
- log.debug("No extensions found for extension point '{}'", type.getName());
+ log.debug("No extensions found for extension point '{}'", type.getName());
} else {
- log.debug("Found {} extensions for extension point '{}'", result.size(), type.getName());
+ log.debug("Found {} extensions for extension point '{}'", result.size(), type.getName());
}
// sort by "ordinal" property
Collections.sort(result);
- return result;
- }
+ return result;
+ }
@Override
@SuppressWarnings("unchecked")
}
@Override
- public List<ExtensionWrapper> find(String pluginId) {
+ public List<ExtensionWrapper> find(String pluginId) {
log.debug("Finding extensions from plugin '{}'", pluginId);
List<ExtensionWrapper> result = new ArrayList<>();
- Set<String> classNames = findClassNames(pluginId);
+ Set<String> classNames = findClassNames(pluginId);
if (classNames.isEmpty()) {
return result;
}
}
@Override
- public void pluginStateChanged(PluginStateEvent event) {
+ public void pluginStateChanged(PluginStateEvent event) {
// TODO optimize (do only for some transitions)
// clear cache
entries = null;
import org.slf4j.LoggerFactory;
/**
- * The default implementation for ExtensionFactory.
- * It uses Class.newInstance() method.
+ * The default implementation for {@link ExtensionFactory}.
+ * It uses {@link Class#newInstance} method.
*
* @author Decebal Suiu
*/
private static final Logger log = LoggerFactory.getLogger(DefaultExtensionFactory.class);
/**
- * Creates an extension instance. If an error occurs than that error is logged and the method returns null.
+ * Creates an extension instance. If an error occurs than that error is logged and the method returns {@code null}.
* @param extensionClass
* @return
*/
private final ExtensionFactory extensionFactory;
private T extension; // cache
- public ExtensionWrapper(ExtensionDescriptor descriptor, ExtensionFactory extensionFactory) {
+ public ExtensionWrapper(ExtensionDescriptor descriptor, ExtensionFactory extensionFactory) {
this.descriptor = descriptor;
this.extensionFactory = extensionFactory;
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked")
public T getExtension() {
if (extension == null) {
extension = (T) extensionFactory.create(descriptor.extensionClass);
}
return extension;
- }
+ }
public ExtensionDescriptor getDescriptor() {
return descriptor;
}
public int getOrdinal() {
- return descriptor.ordinal;
- }
+ return descriptor.ordinal;
+ }
- @Override
- public int compareTo(ExtensionWrapper<T> o) {
- return (getOrdinal() - o.getOrdinal());
- }
+ @Override
+ public int compareTo(ExtensionWrapper<T> o) {
+ return (getOrdinal() - o.getOrdinal());
+ }
}