Browse Source

Formatting

pull/219/head
Decebal Suiu 7 years ago
parent
commit
f80bc959c1
  1. 18
      pf4j/src/main/java/org/pf4j/AbstractExtensionFinder.java
  2. 6
      pf4j/src/main/java/org/pf4j/DefaultExtensionFactory.java
  3. 18
      pf4j/src/main/java/org/pf4j/ExtensionWrapper.java

18
pf4j/src/main/java/org/pf4j/AbstractExtensionFinder.java

@ -46,8 +46,8 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin
@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<>();
@ -59,16 +59,16 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin
}
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")
@ -129,11 +129,11 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin
}
@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;
}
@ -182,7 +182,7 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin
}
@Override
public void pluginStateChanged(PluginStateEvent event) {
public void pluginStateChanged(PluginStateEvent event) {
// TODO optimize (do only for some transitions)
// clear cache
entries = null;

6
pf4j/src/main/java/org/pf4j/DefaultExtensionFactory.java

@ -19,8 +19,8 @@ import org.slf4j.Logger;
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
*/
@ -29,7 +29,7 @@ public class DefaultExtensionFactory implements ExtensionFactory {
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
*/

18
pf4j/src/main/java/org/pf4j/ExtensionWrapper.java

@ -26,31 +26,31 @@ public class ExtensionWrapper<T> implements Comparable<ExtensionWrapper<T>> {
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());
}
}

Loading…
Cancel
Save