summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2019-11-13 19:50:05 +0200
committerDecebal Suiu <decebal.suiu@gmail.com>2019-11-13 19:50:05 +0200
commit41f5ade5087bfa9b6cf8466ab2f4f7d337343501 (patch)
treecca69a0142d42271baa12357092dc8e0865e66dd
parente6093a313b8d4970dfe2826bd539c777e51c9aef (diff)
downloadpf4j-41f5ade5087bfa9b6cf8466ab2f4f7d337343501.tar.gz
pf4j-41f5ade5087bfa9b6cf8466ab2f4f7d337343501.zip
Move static method in superclass
-rw-r--r--pf4j/src/main/java/org/pf4j/processor/ExtensionStorage.java22
-rw-r--r--pf4j/src/main/java/org/pf4j/processor/LegacyExtensionStorage.java21
-rw-r--r--pf4j/src/main/java/org/pf4j/processor/ServiceProviderExtensionStorage.java21
3 files changed, 22 insertions, 42 deletions
diff --git a/pf4j/src/main/java/org/pf4j/processor/ExtensionStorage.java b/pf4j/src/main/java/org/pf4j/processor/ExtensionStorage.java
index 20a684f..f3b3bbd 100644
--- a/pf4j/src/main/java/org/pf4j/processor/ExtensionStorage.java
+++ b/pf4j/src/main/java/org/pf4j/processor/ExtensionStorage.java
@@ -17,8 +17,12 @@ package org.pf4j.processor;
import javax.annotation.processing.Filer;
import javax.lang.model.element.Element;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Pattern;
/**
* It's a storage (database) that persists {@link org.pf4j.Extension}s.
@@ -29,6 +33,9 @@ import java.util.Set;
*/
public abstract class ExtensionStorage {
+ private static final Pattern COMMENT = Pattern.compile("#.*");
+ private static final Pattern WHITESPACE = Pattern.compile("\\s+");
+
protected final ExtensionAnnotationProcessor processor;
public ExtensionStorage(ExtensionAnnotationProcessor processor) {
@@ -74,4 +81,19 @@ public abstract class ExtensionStorage {
processor.info(element, message, args);
}
+ public static void read(Reader reader, Set<String> entries) throws IOException {
+ BufferedReader bufferedReader = new BufferedReader(reader);
+
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ line = COMMENT.matcher(line).replaceFirst("");
+ line = WHITESPACE.matcher(line).replaceAll("");
+ if (line.length() > 0) {
+ entries.add(line);
+ }
+ }
+
+ bufferedReader.close();
+ }
+
}
diff --git a/pf4j/src/main/java/org/pf4j/processor/LegacyExtensionStorage.java b/pf4j/src/main/java/org/pf4j/processor/LegacyExtensionStorage.java
index 38ebfb5..3abde8d 100644
--- a/pf4j/src/main/java/org/pf4j/processor/LegacyExtensionStorage.java
+++ b/pf4j/src/main/java/org/pf4j/processor/LegacyExtensionStorage.java
@@ -18,17 +18,14 @@ package org.pf4j.processor;
import javax.annotation.processing.FilerException;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
-import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.Reader;
import java.nio.file.NoSuchFileException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Pattern;
/**
* Stores {@link org.pf4j.Extension}s in {@code META-INF/extensions.idx}.
@@ -39,28 +36,10 @@ public class LegacyExtensionStorage extends ExtensionStorage {
public static final String EXTENSIONS_RESOURCE = "META-INF/extensions.idx";
- private static final Pattern COMMENT = Pattern.compile("#.*");
- private static final Pattern WHITESPACE = Pattern.compile("\\s+");
-
public LegacyExtensionStorage(ExtensionAnnotationProcessor processor) {
super(processor);
}
- public static void read(Reader reader, Set<String> entries) throws IOException {
- BufferedReader bufferedReader = new BufferedReader(reader);
-
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- line = COMMENT.matcher(line).replaceFirst("");
- line = WHITESPACE.matcher(line).replaceAll("");
- if (line.length() > 0) {
- entries.add(line);
- }
- }
-
- bufferedReader.close();
- }
-
@Override
public Map<String, Set<String>> read() {
Map<String, Set<String>> extensions = new HashMap<>();
diff --git a/pf4j/src/main/java/org/pf4j/processor/ServiceProviderExtensionStorage.java b/pf4j/src/main/java/org/pf4j/processor/ServiceProviderExtensionStorage.java
index 7e07cd0..e2bf397 100644
--- a/pf4j/src/main/java/org/pf4j/processor/ServiceProviderExtensionStorage.java
+++ b/pf4j/src/main/java/org/pf4j/processor/ServiceProviderExtensionStorage.java
@@ -18,17 +18,14 @@ package org.pf4j.processor;
import javax.annotation.processing.FilerException;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
-import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.Reader;
import java.nio.file.NoSuchFileException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Pattern;
/**
* Stores {@link org.pf4j.Extension}s in {@code META-INF/services}.
@@ -39,28 +36,10 @@ public class ServiceProviderExtensionStorage extends ExtensionStorage {
public static final String EXTENSIONS_RESOURCE = "META-INF/services";
- private static final Pattern COMMENT = Pattern.compile("#.*");
- private static final Pattern WHITESPACE = Pattern.compile("\\s+");
-
public ServiceProviderExtensionStorage(ExtensionAnnotationProcessor processor) {
super(processor);
}
- public static void read(Reader reader, Set<String> entries) throws IOException {
- BufferedReader bufferedReader = new BufferedReader(reader);
-
- String line;
- while ((line = bufferedReader.readLine()) != null) {
- line = COMMENT.matcher(line).replaceFirst("");
- line = WHITESPACE.matcher(line).replaceAll("");
- if (line.length() > 0) {
- entries.add(line);
- }
- }
-
- bufferedReader.close();
- }
-
@Override
public Map<String, Set<String>> read() {
Map<String, Set<String>> extensions = new HashMap<>();