diff --git a/src/main/java/br/ufrgs/inf/prosoft/jsonserialiser/JSONSerialiser.java b/src/main/java/br/ufrgs/inf/prosoft/jsonserialiser/JSONSerialiser.java
index cba63bf..d0d3a37 100644
--- a/src/main/java/br/ufrgs/inf/prosoft/jsonserialiser/JSONSerialiser.java
+++ b/src/main/java/br/ufrgs/inf/prosoft/jsonserialiser/JSONSerialiser.java
@@ -5,6 +5,7 @@
*/
package br.ufrgs.inf.prosoft.jsonserialiser;
+import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
@@ -32,6 +33,8 @@ public class JSONSerialiser {
private final List<Object> visited;
private static final boolean TRACER_SERIALISE_INTERNALS = System.getenv("TRACER_SERIALISE_INTERNALS") != null && System.getenv("TRACER_SERIALISE_INTERNALS").equals("true");
private static final String TRACER_IGNORED_PACKAGES = System.getenv("TRACER_IGNORED_PACKAGES") != null ? System.getenv("TRACER_IGNORED_PACKAGES") : "./ignored";
+ private static final String TRACER_WHITELIST = System.getenv("TRACER_WHITELIST") != null ? System.getenv("TRACER_WHITELIST") : "";
+ private static final String TRACER_LOG = System.getenv("TRACER_LOG");
private JSONSerialiser() {
this.visited = new ArrayList<>();
@@ -180,6 +183,13 @@ public class JSONSerialiser {
if (ignoredPackages.stream().anyMatch(ignoredPackage -> objectPackageName.startsWith(ignoredPackage))) {
return getReference(object);
}
+ try {
+ List<String> whiteList = Files.readAllLines(Paths.get(TRACER_WHITELIST));
+ if (!objectPackageName.isEmpty() && whiteList.stream().noneMatch(ignoredPackage -> objectPackageName.startsWith(ignoredPackage))) {
+ log(System.currentTimeMillis() + " [JSONSerialiser] proceeding " + objectPackageName);
+ }
+ } catch (IOException ex) {
+ }
}
if (this.visited.stream().parallel().anyMatch(visited -> visited == object)) {
return getReference(object);
@@ -409,6 +419,16 @@ public class JSONSerialiser {
return stringBuilder.append('"');
}
+ private void log(String message) {
+ if (TRACER_LOG == null) {
+ return;
+ }
+ try (FileWriter fileWriter = new FileWriter(TRACER_LOG, true)) {
+ fileWriter.write(message + "\n");
+ } catch (IOException ex) {
+ }
+ }
+
private static StringBuilder getReference(Object object) {
return new StringBuilder().append("{\"r\":\"@")
.append(object.getClass().getName())