diff --git a/doma-core/src/main/java/org/seasar/doma/message/Message.java b/doma-core/src/main/java/org/seasar/doma/message/Message.java index 998dd01a8..8aab2bcbb 100644 --- a/doma-core/src/main/java/org/seasar/doma/message/Message.java +++ b/doma-core/src/main/java/org/seasar/doma/message/Message.java @@ -930,6 +930,7 @@ public enum Message implements MessageResource { "If a method annotated with @MultiInsert targets immutable entities for insertion, the return type must be org.seasar.doma.jdbc.MultiResult." + "The type argument of org.seasar.doma.jdbc.MultiResult must be the immutable entity class."), DOMA4462("The property \"{0}\" is not found in the entity class \"{1}\"."), + DOMA4463("'{'\"execTimeMillis\": {0}, \"processor\": \"{1}\", \"element\": \"{2}\"'}'"), // other DOMA5001( diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/Options.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/Options.java index d0a1f8f5e..e04b0db73 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/Options.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/Options.java @@ -27,6 +27,8 @@ public final class Options { public static final String DEBUG = "doma.debug"; + public static final String TRACE = "doma.trace"; + public static final String DAO_PACKAGE = "doma.dao.package"; public static final String DAO_SUBPACKAGE = "doma.dao.subpackage"; @@ -122,6 +124,11 @@ public Date getDate() { return new Date(); } + public boolean isTraceEnabled() { + String trace = getOption(TRACE); + return Boolean.parseBoolean(trace); + } + public boolean isDebugEnabled() { String debug = getOption(DEBUG); return Boolean.parseBoolean(debug); diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/AbstractProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/AbstractProcessor.java index 4bbd9c610..2a233d13b 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/AbstractProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/AbstractProcessor.java @@ -4,6 +4,7 @@ import java.io.StringWriter; import java.io.Writer; import java.lang.annotation.Annotation; +import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.Supplier; import javax.annotation.processing.ProcessingEnvironment; @@ -63,7 +64,18 @@ private void handleElement( .debug(Message.DOMA4090, new Object[] {getClass().getName(), elementNameSupplier.get()}); } try { - handler.accept(element); + if (ctx.getOptions().isTraceEnabled()) { + long startTime = System.nanoTime(); + handler.accept(element); + long endTime = System.nanoTime(); + long execTimeMillis = TimeUnit.NANOSECONDS.toMillis(endTime - startTime); + ctx.getReporter() + .debug( + Message.DOMA4463, + new Object[] {execTimeMillis, getClass().getName(), elementNameSupplier.get()}); + } else { + handler.accept(element); + } } catch (AptException e) { ctx.getReporter().report(e); } catch (AptIllegalOptionException e) { diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DaoProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DaoProcessor.java index 932d41752..3fdd7c7d7 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DaoProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DaoProcessor.java @@ -24,6 +24,7 @@ @SupportedAnnotationTypes({"org.seasar.doma.Dao"}) @SupportedOptions({ Options.TEST, + Options.TRACE, Options.DEBUG, Options.DAO_PACKAGE, Options.DAO_SUBPACKAGE, diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DataTypeProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DataTypeProcessor.java index a9f7005bf..ff38a14b8 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DataTypeProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DataTypeProcessor.java @@ -12,6 +12,7 @@ Options.VERSION_VALIDATION, Options.RESOURCES_DIR, Options.TEST, + Options.TRACE, Options.DEBUG, Options.CONFIG_PATH }) diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainConvertersProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainConvertersProcessor.java index 2773514fc..293003799 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainConvertersProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainConvertersProcessor.java @@ -19,7 +19,13 @@ * @since 1.25.0 */ @SupportedAnnotationTypes({"org.seasar.doma.DomainConverters"}) -@SupportedOptions({Options.RESOURCES_DIR, Options.TEST, Options.DEBUG, Options.CONFIG_PATH}) +@SupportedOptions({ + Options.RESOURCES_DIR, + Options.TEST, + Options.TRACE, + Options.DEBUG, + Options.CONFIG_PATH +}) public class DomainConvertersProcessor extends AbstractProcessor { public DomainConvertersProcessor() { diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainProcessor.java index aba0c8b88..0381e9bf2 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/DomainProcessor.java @@ -13,6 +13,7 @@ Options.RESOURCES_DIR, Options.LOMBOK_VALUE, Options.TEST, + Options.TRACE, Options.DEBUG, Options.CONFIG_PATH }) diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EmbeddableProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EmbeddableProcessor.java index f9100bf27..1c62f1111 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EmbeddableProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EmbeddableProcessor.java @@ -24,6 +24,7 @@ Options.LOMBOK_VALUE, Options.LOMBOK_ALL_ARGS_CONSTRUCTOR, Options.TEST, + Options.TRACE, Options.DEBUG, Options.CONFIG_PATH, Options.METAMODEL_ENABLED, diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EntityProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EntityProcessor.java index 78e27e353..2e8017391 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EntityProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/EntityProcessor.java @@ -32,6 +32,7 @@ Options.LOMBOK_VALUE, Options.LOMBOK_ALL_ARGS_CONSTRUCTOR, Options.TEST, + Options.TRACE, Options.DEBUG, Options.CONFIG_PATH, Options.METAMODEL_ENABLED, diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ExternalDomainProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ExternalDomainProcessor.java index eb8a7927e..aae20af04 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ExternalDomainProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ExternalDomainProcessor.java @@ -21,6 +21,7 @@ Options.VERSION_VALIDATION, Options.RESOURCES_DIR, Options.TEST, + Options.TRACE, Options.DEBUG, Options.CONFIG_PATH }) diff --git a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ScopeProcessor.java b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ScopeProcessor.java index 786f28064..8a71067fc 100644 --- a/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ScopeProcessor.java +++ b/doma-processor/src/main/java/org/seasar/doma/internal/apt/processor/ScopeProcessor.java @@ -14,7 +14,13 @@ import org.seasar.doma.message.Message; @SupportedAnnotationTypes({"org.seasar.doma.Scope"}) -@SupportedOptions({Options.RESOURCES_DIR, Options.TEST, Options.DEBUG, Options.CONFIG_PATH}) +@SupportedOptions({ + Options.RESOURCES_DIR, + Options.TEST, + Options.TRACE, + Options.DEBUG, + Options.CONFIG_PATH +}) public class ScopeProcessor extends AbstractProcessor { public ScopeProcessor() {