Skip to content

Commit 8d0bc48

Browse files
committed
improved comments and provided way to force disable of service search in class path
1 parent 025afa2 commit 8d0bc48

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

jcp/src/main/java/com/igormaznitsa/jcp/context/CommentTextProcessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import java.io.IOException;
55

66
/**
7-
* Custom processor to detect and process text line or text block
7+
* Custom processor to detect and process uncommenting text line or text block
88
* defined through //$ and //$$ directives. It can return the same value or
9-
* changed one.
9+
* changed one. The processor is called after ext prepared for injection into preprocessed source.
10+
* If activated merge block mode for preprocessor so sequentially
11+
* situated lines started with """ will be merged into single text block (and """ will be removed)
1012
*
1113
* @since 7.2.0
1214
*/

jcp/src/main/java/com/igormaznitsa/jcp/utils/PreprocessorUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
*/
6363
public final class PreprocessorUtils {
6464

65+
/**
66+
* Property if defined and true then search of services in class path is disabled.
67+
*
68+
* @since 7.2.0
69+
*/
70+
public static final String SYSTEM_PROPERTY_DISABLE_SEARCH_SERVICES =
71+
"jcp.preprocessor.disable.search.services";
6572
private static final Pattern PATTERN_MACROS_WITH_SPACES =
6673
Pattern.compile("\\/\\*\\s*\\$(.*?)\\$\\s*\\*\\/");
6774

@@ -113,7 +120,6 @@ public static PreprocessorExtension findAndInstantiatePreprocessorExtensionForCl
113120
}
114121
}
115122

116-
117123
/**
118124
* Find comment remover type for provided identifier. Decoding also true and false values.
119125
*
@@ -154,7 +160,6 @@ public static String getFileExtension(final File file) {
154160
return result;
155161
}
156162

157-
158163
public static BufferedReader makeFileReader(final File file, final Charset charset,
159164
final int bufferSize) throws IOException {
160165
Objects.requireNonNull(file, "File is null");
@@ -182,12 +187,10 @@ public static String[] replaceChar(final String[] source,
182187
return result;
183188
}
184189

185-
186190
public static String extractTrimmedTail(final String prefix, final String value) {
187191
return extractTail(prefix, value).trim();
188192
}
189193

190-
191194
public static String extractTail(final String prefix, final String value) {
192195
Objects.requireNonNull(prefix, "Prefix is null");
193196
Objects.requireNonNull(value, "Value is null");
@@ -226,7 +229,6 @@ public static boolean copyFileAttributes(final File from, final File to) {
226229
return result;
227230
}
228231

229-
230232
public static String replacePartByChar(final String text, final char chr, final int startPosition,
231233
final int length) {
232234
if (startPosition < 0) {
@@ -247,6 +249,9 @@ public static String replacePartByChar(final String text, final char chr, final
247249
}
248250

249251
public static <T> List<T> findAndInstantiateAllServices(final Class<T> serviceClass) {
252+
if (Boolean.getBoolean(SYSTEM_PROPERTY_DISABLE_SEARCH_SERVICES)) {
253+
return List.of();
254+
}
250255
final ServiceLoader<T> serviceLoader = ServiceLoader.load(serviceClass);
251256
return serviceLoader.stream().map(ServiceLoader.Provider::get).collect(Collectors.toList());
252257
}

0 commit comments

Comments
 (0)