diff -Nru jboss-logging-tools-2.0.2/annotations/pom.xml jboss-logging-tools-2.1.0/annotations/pom.xml --- jboss-logging-tools-2.0.2/annotations/pom.xml 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/pom.xml 2017-08-09 18:02:31.000000000 +0000 @@ -25,7 +25,7 @@ org.jboss.logging jboss-logging-tools-parent - 2.0.2.Final + 2.1.0.Final ../pom.xml @@ -50,4 +50,4 @@ provided - \ No newline at end of file + diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/BaseUrl.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/BaseUrl.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/BaseUrl.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/BaseUrl.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Messages on reports can have a link to a {@linkplain ResolutionDoc resolution document}. This annotation can be used + * to provide a base URL for these documents. + *

+ * Expressions in the form of {@code ${property.key:default-value}} can be used for the values. If the property key is + * prefixed with {@code sys.} a {@linkplain System#getProperty(String) system property} will be used. If the key is + * prefixed with {@code env.} an {@linkplain System#getenv(String) environment variable} will be used. In all other cases + * the {@code org.jboss.logging.tools.expressionProperties} processor argument is used to specify the path the properties + * file which contains the values for the expressions. + *

+ * + * @author James R. Perkins + * @since 1.2 + */ +@Target(TYPE) +@Retention(CLASS) +@Documented +public @interface BaseUrl { + + /** + * The base URL used for links to resolution documentation on reports. This can be a fully qualified URL or a + * relative URL. + * + * @return the base URL + */ + String value(); +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Field.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Field.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Field.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Field.java 2017-08-09 18:02:31.000000000 +0000 @@ -19,27 +19,109 @@ package org.jboss.logging.annotations; +import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.CLASS; import java.lang.annotation.Documented; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Indicate that a method parameter value should be applied to a field on the resultant exception object. + *

+ * If this annotation is placed on a method the {@linkplain #name() name} attribute becomes a required parameter and one + * default attribute needs to be set. The value of the default attribute is used to set the filed on the resultant + * exception object. + *

* * @author David M. Lloyd + * @author James R. Perkins */ @Retention(CLASS) -@Target(PARAMETER) +@Target({PARAMETER, METHOD}) +@Repeatable(Fields.class) @Documented public @interface Field { /** * The field name. If not specified, the parameter name is assumed to be the field name. + *

+ * This becomes a required attrubyte if this annotation is present on a method. + *

* * @return the field name */ String name() default ""; + + /** + * The default {@code boolean} value if this annotation is used on a method. + * + * @return the default value to use + */ + boolean booleanValue() default false; + + /** + * The default boolean value if this annotation is used on a method. + * + * @return the default value to use + */ + byte byteValue() default 0x00; + + /** + * The default {@code byte} value if this annotation is used on a method. + * + * @return the default value to use + */ + char charValue() default 0x00; + + /** + * The default {@link Class} value if this annotation is used on a method. + * + * @return the default value to use + */ + Class classValue() default Object.class; + + /** + * The default {@code double} value if this annotation is used on a method. + * + * @return the default value to use + */ + double doubleValue() default 0.0d; + + /** + * The default {@code float} value if this annotation is used on a method. + * + * @return the default value to use + */ + float floatValue() default 0.0f; + + /** + * The default {@code int} value if this annotation is used on a method. + * + * @return the default value to use + */ + int intValue() default 0; + + /** + * The default {@code long} value if this annotation is used on a method. + * + * @return the default value to use + */ + long longValue() default 0L; + + /** + * The default {@code short} value if this annotation is used on a method. + * + * @return the default value to use + */ + short shortValue() default 0; + + /** + * The default {@link String} value if this annotation is used on a method. + * + * @return the default value to use + */ + String stringValue() default ""; } diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Fields.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Fields.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Fields.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Fields.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2016 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Defines the default field properties to use on the resultant exception object. + * + * @author James R. Perkins + */ +@Retention(CLASS) +@Target(METHOD) +@Documented +public @interface Fields { + + /** + * The fields to use on the resultant exception object. Note that the {@link Field#name() name} attribute is + * required for these annotations. + * + * @return the fields + */ + Field[] value(); +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Message.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Message.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Message.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Message.java 2017-08-09 18:02:31.000000000 +0000 @@ -55,6 +55,13 @@ /** * The default format string of this message. + *

+ * Expressions in the form of {@code ${property.key:default-value}} can be used for the value. If the property key is + * prefixed with {@code sys.} a {@linkplain System#getProperty(String) system property} will be used. If the key is + * prefixed with {@code env.} an {@linkplain System#getenv(String) environment variable} will be used. In all other cases + * the {@code org.jboss.logging.tools.expressionProperties} processor argument is used to specify the path the properties + * file which contains the values for the expressions. + *

* * @return the format string */ diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Producer.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Producer.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Producer.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Producer.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Identifies a parameter has the ability to produce a {@link Throwable} or a super type of a {@code Throwable}. The + * parameter type must be a {@link java.util.function.Function} or a {@link java.util.function.BiFunction}. + *

+ * For a {@link java.util.function.Function} the input parameter must be a {@link String} which will be the message + * associated with the method. The result type must {@link Throwable} or a super type of a {@code Throwable}. + *

+ * + *

+ * For a {@link java.util.function.BiFunction} one of the input parameters must be a {@link String} which will be the + * message associated with the method. The other input parameter must be a {@link Throwable} or a super type of a + * {@code Throwable} and must be assignable from the parameter annotated with {@link Cause}. The result type must + * {@link Throwable} or a super type of a {@code Throwable}. + *

+ * + *

+ * Example + * + *

+ * @Message("The operation failed due to %s")
+ *  T operationFailed(@Producer Function function, String op);
+ *
+ * @Message("The operation failed due to %s")
+ *  T operationFailed(@Producer BiFunction function, @Cause Throwable cause, String op);
+ *
+ * 
+ * + *

+ * + *

+ * Example Usage + * + *

+ * throw Bundle.MESSAGES.operationFailed(IllegalArgumentException::new, "start");
+ *
+ * throw Bundle.MESSAGES.operationFailed(IllegalStateException::new, cause, "start");
+ *
+ * 
+ * + *

+ * + * @author James R. Perkins + */ +@Target(PARAMETER) +@Retention(CLASS) +@Documented +public @interface Producer { +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Properties.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Properties.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Properties.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Properties.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2016 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Defines the default properties to use on the resultant exception object. + * + * @author James R. Perkins + */ +@Retention(CLASS) +@Target(METHOD) +@Documented +public @interface Properties { + + /** + * The properties to use on the resultant exception object. Note that the {@link Property#name() name} attribute is + * required for these annotations. + * + * @return the properties + */ + Property[] value(); +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Property.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Property.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Property.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Property.java 2017-08-09 18:02:31.000000000 +0000 @@ -20,27 +20,110 @@ package org.jboss.logging.annotations; +import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.RetentionPolicy.CLASS; import java.lang.annotation.Documented; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** - * Indicate that a method parameter value should be applied to a property (with a setter method) on the resultant exception object. + * Indicate that a method parameter value should be applied to a property (with a setter method) on the resultant + * exception object. + *

+ * If this annotation is placed on a method the {@linkplain #name() name} attribute becomes a required parameter and one + * default attribute needs to be set. The value of the default attribute is used to set the property on the resultant + * exception object. + *

* * @author David M. Lloyd + * @author James R. Perkins */ @Retention(CLASS) -@Target(PARAMETER) +@Target({PARAMETER, METHOD}) +@Repeatable(Properties.class) @Documented public @interface Property { /** * The property name. If not specified, the parameter name is assumed to be the property name. + *

+ * This becomes a required attribute if this annotation is present on a method. + *

* * @return the property name */ String name() default ""; + + /** + * The default {@code boolean} value if this annotation is used on a method. + * + * @return the default value to use + */ + boolean booleanValue() default false; + + /** + * The default boolean value if this annotation is used on a method. + * + * @return the default value to use + */ + byte byteValue() default 0x00; + + /** + * The default {@code byte} value if this annotation is used on a method. + * + * @return the default value to use + */ + char charValue() default 0x00; + + /** + * The default {@link Class} value if this annotation is used on a method. + * + * @return the default value to use + */ + Class classValue() default Object.class; + + /** + * The default {@code double} value if this annotation is used on a method. + * + * @return the default value to use + */ + double doubleValue() default 0.0d; + + /** + * The default {@code float} value if this annotation is used on a method. + * + * @return the default value to use + */ + float floatValue() default 0.0f; + + /** + * The default {@code int} value if this annotation is used on a method. + * + * @return the default value to use + */ + int intValue() default 0; + + /** + * The default {@code long} value if this annotation is used on a method. + * + * @return the default value to use + */ + long longValue() default 0L; + + /** + * The default {@code short} value if this annotation is used on a method. + * + * @return the default value to use + */ + short shortValue() default 0; + + /** + * The default {@link String} value if this annotation is used on a method. + * + * @return the default value to use + */ + String stringValue() default ""; } diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/ResolutionDoc.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/ResolutionDoc.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/ResolutionDoc.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/ResolutionDoc.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Allows a link to be created for messages on a report which contain a possible resolution to the issue reported . If + * the method does not include an {@linkplain Message#id() id} no link will be created for the report unless a + * {@link #path()} is defined. + * + *

+ * The rules for building the URL are as follows: + *

+ *

+ * + *

+ * If placed on a type links will be created for all methods on the type. + *

+ * + *

+ * Do note that the processor does not validate the resolution document exists. It simply attempts to create links to + * the resolution document. + *

+ *

+ * Expressions in the form of {@code ${property.key:default-value}} can be used for the values with the exception of the + * {@link #skip() skip} attribute. If the property key is prefixed with {@code sys.} a + * {@linkplain System#getProperty(String) system property} will be used. If the key is prefixed with {@code env.} an + * {@linkplain System#getenv(String) environment variable} will be used. In all other cases the + * {@code org.jboss.logging.tools.expressionProperties} processor argument is used to specify the path the properties + * file which contains the values for the expressions. + *

+ * + * @author James R. Perkins + * @since 1.2 + */ +@Target({METHOD, TYPE}) +@Retention(CLASS) +@Documented +public @interface ResolutionDoc { + + /** + * The URL, fully qualified or relative, to use for the resolution document. If defined this will override the value + * of the {@link BaseUrl} if the annotation is used. + * + * @return the URL or an empty string + */ + String url() default ""; + + /** + * The path to the resolution document. If left undefined this will default to the message id. + * + * @return the path to the resolution document + */ + String path() default ""; + + /** + * The suffix to append to the path. If left undefined this will default to the extension for the report type. For + * example if the report type is {@code xml} the default suffix would be {@code .xml}. + * + * @return the suffix for the resolution document + */ + String suffix() default ""; + + /** + * Allows the creation of a link to be skipped. + * + * @return {@code true} if creating the link should be skipped + */ + boolean skip() default false; +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Signature.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Signature.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Signature.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Signature.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,100 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2016 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Specifies the exact signature to use when creating a {@link Throwable} return type. + * + *

+ * Given the following exception and message bundle interface method the {@code InvalidIntValueException(final RuntimeException cause, final String msg, final int value)} + * constructor would be used. + * + * + *

+ * public class InvalidIntValueException extends RuntimeException {
+ *     private final RuntimeException causeAsRuntime;
+ *     private final int value;
+ *     public InvalidIntValueException(final Throwable cause, final String msg, final int value) {
+ *         super(msg, cause);
+ *         causeAsRuntime = new RuntimeException(cause);
+ *         this.value = value;
+ *     }
+ *
+ *     public InvalidIntValueException(final RuntimeException cause, final String msg, final int value) {
+ *         super(msg, cause);
+ *         causeAsRuntime = cause;
+ *         this.value = value;
+ *     }
+ *     public InvalidIntValueException(final RuntimeException cause, final String msg, final Integer value) {
+ *         super(msg, cause);
+ *         causeAsRuntime = cause;
+ *         this.value = value;
+ *     }
+ * }
+ * 
+ * + * + * + *
+ * @Message("Invalid value %d")
+ * @Signature(causeIndex = 0, messageIndex = 1, value = {RuntimeException.class, String.class, int.class}
+ * InvalidIntValueException invalidValue(@Cause RuntimeException cause, @Param int value);
+ * 
+ *
+ *

+ * + * @author James R. Perkins + */ +@Retention(CLASS) +@Target(METHOD) +@Documented +public @interface Signature { + + /** + * An array of types matching the exact signature to use for the exception being created. + * + * @return an array of types used to find the signature + */ + Class[] value(); + + /** + * The index for the {@linkplain Cause cause} of the exception being created. A value of less than zero assumes + * there is no cause parameter in the constructor. A {@link Cause} annotation can still be used and the + * {@link Throwable#initCause(Throwable)} will be used to initialize the cause of the exception. + * + * @return the index for the cause parameter + */ + int causeIndex() default -1; + + /** + * The index for the message. This is the formatted messaged from the {@link Message#value()}. This is a required + * value defaulting to 0 which would be the first parameter. + * + * @return the index for the message parameter + */ + int messageIndex() default 0; +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Suppressed.java jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Suppressed.java --- jboss-logging-tools-2.0.2/annotations/src/main/java/org/jboss/logging/annotations/Suppressed.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/java/org/jboss/logging/annotations/Suppressed.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,45 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2016 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.annotations; + +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Indicates the parameter should be added as a {@linkplain Throwable#addSuppressed(Throwable) suppressed} exception to + * the returned exception. + *

+ * The annotated parameter can be a single {@linkplain Throwable throwable type}, an array of + * {@linkplain Throwable throwable types} or a {@linkplain java.util.Collection collection} of + * {@linkplain Throwable throwable types}. Note this is only allowed on message bundle methods that return a + * {@linkplain Throwable throwable type}. + *

+ * + * @author James R. Perkins + */ +@Retention(CLASS) +@Target(PARAMETER) +@Documented +public @interface Suppressed { +} diff -Nru jboss-logging-tools-2.0.2/annotations/src/main/resources/META-INF/LICENSE.txt jboss-logging-tools-2.1.0/annotations/src/main/resources/META-INF/LICENSE.txt --- jboss-logging-tools-2.0.2/annotations/src/main/resources/META-INF/LICENSE.txt 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/annotations/src/main/resources/META-INF/LICENSE.txt 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/debian/changelog jboss-logging-tools-2.1.0/debian/changelog --- jboss-logging-tools-2.0.2/debian/changelog 2016-11-21 08:07:40.000000000 +0000 +++ jboss-logging-tools-2.1.0/debian/changelog 2017-08-19 20:14:23.000000000 +0000 @@ -1,3 +1,13 @@ +jboss-logging-tools (2.1.0-1) unstable; urgency=medium + + * New upstream version 2.1.0. + * Declare compliance with Debian Policy 4.0.1. + * Use https for Format field. + * Build-Depend on junit to work around a Maven tool chain issue. + * Use maven compile source and target 1.8. + + -- Markus Koschany Sat, 19 Aug 2017 22:14:23 +0200 + jboss-logging-tools (2.0.2-1) unstable; urgency=medium * Team upload. diff -Nru jboss-logging-tools-2.0.2/debian/control jboss-logging-tools-2.1.0/debian/control --- jboss-logging-tools-2.0.2/debian/control 2016-11-21 08:00:45.000000000 +0000 +++ jboss-logging-tools-2.1.0/debian/control 2017-08-19 20:14:23.000000000 +0000 @@ -8,6 +8,7 @@ debhelper (>= 10), default-jdk, default-jdk-doc, + junit4, libjboss-jdeparser2-java, libjboss-logging-java, libjboss-logmanager-java, @@ -15,7 +16,7 @@ libmaven-javadoc-plugin-java, maven-debian-helper (>= 1.5), testng -Standards-Version: 3.9.8 +Standards-Version: 4.0.1 Vcs-Git: https://anonscm.debian.org/git/pkg-java/jboss-logging-tools.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/jboss-logging-tools.git Homepage: https://github.com/jboss-logging/jboss-logging-tools diff -Nru jboss-logging-tools-2.0.2/debian/copyright jboss-logging-tools-2.1.0/debian/copyright --- jboss-logging-tools-2.0.2/debian/copyright 2016-11-21 08:00:45.000000000 +0000 +++ jboss-logging-tools-2.1.0/debian/copyright 2017-08-19 20:14:23.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: JBoss Logging Tools Source: https://github.com/jboss-logging/jboss-logging-tools @@ -11,7 +11,7 @@ License: Apache-2.0 Files: debian/* -Copyright: 2015-2016, Markus Koschany +Copyright: 2015-2017, Markus Koschany License: Apache-2.0 or LGPL-2.1+ License: Apache-2.0 diff -Nru jboss-logging-tools-2.0.2/debian/maven.properties jboss-logging-tools-2.1.0/debian/maven.properties --- jboss-logging-tools-2.0.2/debian/maven.properties 2016-11-21 08:00:45.000000000 +0000 +++ jboss-logging-tools-2.1.0/debian/maven.properties 2017-08-19 20:14:23.000000000 +0000 @@ -1,6 +1,6 @@ # Include here properties to pass to Maven during the build. # For example: maven.test.skip=true -maven.compiler.source=1.7 -maven.compiler.target=1.7 +maven.compiler.source=1.8 +maven.compiler.target=1.8 diff -Nru jboss-logging-tools-2.0.2/debian/maven.rules jboss-logging-tools-2.1.0/debian/maven.rules --- jboss-logging-tools-2.0.2/debian/maven.rules 2016-11-21 08:00:45.000000000 +0000 +++ jboss-logging-tools-2.1.0/debian/maven.rules 2017-08-19 20:14:23.000000000 +0000 @@ -6,3 +6,4 @@ org.jboss.logging jboss-logging jar s/.*/debian/ * * org.jboss.logmanager jboss-logmanager jar s/.*/debian/ * * org.testng testng jar s/6\..*/6.x/ * * +junit junit jar s/4\..*/4.x/ * * diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/allclasses-frame.html jboss-logging-tools-2.1.0/docs/apidocs/allclasses-frame.html --- jboss-logging-tools-2.0.2/docs/apidocs/allclasses-frame.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/allclasses-frame.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,43 @@ + + + + + + +All Classes (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + +

All Classes

+ + + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/allclasses-noframe.html jboss-logging-tools-2.1.0/docs/apidocs/allclasses-noframe.html --- jboss-logging-tools-2.0.2/docs/apidocs/allclasses-noframe.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/allclasses-noframe.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,43 @@ + + + + + + +All Classes (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + +

All Classes

+ + + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/constant-values.html jboss-logging-tools-2.1.0/docs/apidocs/constant-values.html --- jboss-logging-tools-2.0.2/docs/apidocs/constant-values.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/constant-values.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,161 @@ + + + + + + +Constant Field Values (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

org.jboss.*

+
    +
  • + + + + + + + + + + + + + + + + + + + +
    org.jboss.logging.annotations.Message 
    Modifier and TypeConstant FieldValue
    + +public static final intINHERIT-1
    + +public static final intNONE0
    +
  • +
+
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/deprecated-list.html jboss-logging-tools-2.1.0/docs/apidocs/deprecated-list.html --- jboss-logging-tools-2.0.2/docs/apidocs/deprecated-list.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/deprecated-list.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Deprecated List (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Deprecated API

+

Contents

+
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/help-doc.html jboss-logging-tools-2.1.0/docs/apidocs/help-doc.html --- jboss-logging-tools-2.0.2/docs/apidocs/help-doc.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/help-doc.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,226 @@ + + + + + + +API Help (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Use

    +

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/index-all.html jboss-logging-tools-2.1.0/docs/apidocs/index-all.html --- jboss-logging-tools-2.0.2/docs/apidocs/index-all.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/index-all.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,327 @@ + + + + + + +Index (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
B C F I L M N O P R S T V  + + +

B

+
+
BaseUrl - Annotation Type in org.jboss.logging.annotations
+
+
Messages on reports can have a link to a resolution document.
+
+
+ + + +

C

+
+
Cause - Annotation Type in org.jboss.logging.annotations
+
+
Mark a parameter as being the "exception cause" parameter rather than a positional format parameter.
+
+
ConstructType - Annotation Type in org.jboss.logging.annotations
+
+
Indicates the value of this annotation should be constructed and returned.
+
+
+ + + +

F

+
+
Field - Annotation Type in org.jboss.logging.annotations
+
+
Indicate that a method parameter value should be applied to a field on the resultant exception object.
+
+
Fields - Annotation Type in org.jboss.logging.annotations
+
+
Defines the default field properties to use on the resultant exception object.
+
+
FormatWith - Annotation Type in org.jboss.logging.annotations
+
+
Indicate that the given parameter should be wrapped with a formatting object of the given class.
+
+
+ + + +

I

+
+
INHERIT - Static variable in annotation type org.jboss.logging.annotations.Message
+
+
Indicates that this message should inherit the ID from another message with the same name.
+
+
+ + + +

L

+
+
LoggingClass - Annotation Type in org.jboss.logging.annotations
+
+
Mark a parameter as specifying the name of the logging class to use.
+
+
LogMessage - Annotation Type in org.jboss.logging.annotations
+
+
A typed logger method.
+
+
+ + + +

M

+
+
Message - Annotation Type in org.jboss.logging.annotations
+
+
Assigns a message string to a resource method.
+
+
Message.Format - Enum in org.jboss.logging.annotations
+
+
The possible format types.
+
+
MessageBundle - Annotation Type in org.jboss.logging.annotations
+
+
Signify that an interface is a message bundle interface.
+
+
MessageLogger - Annotation Type in org.jboss.logging.annotations
+
+
Signify that an interface is a typed logger interface.
+
+
+ + + +

N

+
+
NONE - Static variable in annotation type org.jboss.logging.annotations.Message
+
+
Indicates that this message has no ID.
+
+
+ + + +

O

+
+
Once - Annotation Type in org.jboss.logging.annotations
+
+
Indicates a message should only be logged once.
+
+
org.jboss.logging.annotations - package org.jboss.logging.annotations
+
 
+
+ + + +

P

+
+
Param - Annotation Type in org.jboss.logging.annotations
+
+
Identifies a parameter is to be used for constructing an exception and excluded from the formatting of the message.
+
+
Pos - Annotation Type in org.jboss.logging.annotations
+
 
+
Producer - Annotation Type in org.jboss.logging.annotations
+
+
Identifies a parameter has the ability to produce a Throwable or a super type of a Throwable.
+
+
Properties - Annotation Type in org.jboss.logging.annotations
+
+
Defines the default properties to use on the resultant exception object.
+
+
Property - Annotation Type in org.jboss.logging.annotations
+
+
Indicate that a method parameter value should be applied to a property (with a setter method) on the resultant + exception object.
+
+
+ + + +

R

+
+
ResolutionDoc - Annotation Type in org.jboss.logging.annotations
+
+
Allows a link to be created for messages on a report which contain a possible resolution to the issue reported .
+
+
+ + + +

S

+
+
Signature - Annotation Type in org.jboss.logging.annotations
+
+
Specifies the exact signature to use when creating a Throwable return type.
+
+
Suppressed - Annotation Type in org.jboss.logging.annotations
+
+
Indicates the parameter should be added as a suppressed exception to + the returned exception.
+
+
+ + + +

T

+
+
Transform - Annotation Type in org.jboss.logging.annotations
+
+
Indicate the given parameter should be transformed in each of the transform types + provided.
+
+
Transform.TransformType - Enum in org.jboss.logging.annotations
+
+
The transform type
+
+
+ + + +

V

+
+
ValidIdRange - Annotation Type in org.jboss.logging.annotations
+
+
Sets a range of valid id's allowed on the message id.
+
+
ValidIdRanges - Annotation Type in org.jboss.logging.annotations
+
 
+
valueOf(String) - Static method in enum org.jboss.logging.annotations.Message.Format
+
+
Returns the enum constant of this type with the specified name.
+
+
valueOf(String) - Static method in enum org.jboss.logging.annotations.Transform.TransformType
+
+
Returns the enum constant of this type with the specified name.
+
+
values() - Static method in enum org.jboss.logging.annotations.Message.Format
+
+
Returns an array containing the constants of this enum type, in +the order they are declared.
+
+
values() - Static method in enum org.jboss.logging.annotations.Transform.TransformType
+
+
Returns an array containing the constants of this enum type, in +the order they are declared.
+
+
+B C F I L M N O P R S T V 
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/index.html jboss-logging-tools-2.1.0/docs/apidocs/index.html --- jboss-logging-tools-2.0.2/docs/apidocs/index.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/index.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,73 @@ + + + + + + +JBoss Logging I18n Documentation 2.1.0.Final API + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="org/jboss/logging/annotations/package-summary.html">Non-frame version</a>.</p> + + + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/BaseUrl.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/BaseUrl.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/BaseUrl.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/BaseUrl.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,238 @@ + + + + + + +BaseUrl (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type BaseUrl

+
+
+
+
    +
  • +
    +
    +
    @Target(value=TYPE)
    + @Retention(value=CLASS)
    + @Documented
    +public @interface BaseUrl
    +
    Messages on reports can have a link to a resolution document. This annotation can be used + to provide a base URL for these documents. +

    + Expressions in the form of ${property.key:default-value} can be used for the values. If the property key is + prefixed with sys. a system property will be used. If the key is + prefixed with env. an environment variable will be used. In all other cases + the org.jboss.logging.tools.expressionProperties processor argument is used to specify the path the properties + file which contains the values for the expressions. +

    +
    +
    Since:
    +
    1.2
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Stringvalue +
      The base URL used for links to resolution documentation on reports.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract String value
        +
        The base URL used for links to resolution documentation on reports. This can be a fully qualified URL or a + relative URL.
        +
        +
        Returns:
        +
        the base URL
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Cause.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Cause.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Cause.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Cause.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,172 @@ + + + + + + +Cause (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Cause

+
+
+
+ +
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/BaseUrl.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/BaseUrl.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/BaseUrl.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/BaseUrl.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.BaseUrl (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.BaseUrl

+
+
No usage of org.jboss.logging.annotations.BaseUrl
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Cause.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Cause.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Cause.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Cause.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Cause (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Cause

+
+
No usage of org.jboss.logging.annotations.Cause
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ConstructType.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ConstructType.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ConstructType.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ConstructType.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.ConstructType (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.ConstructType

+
+
No usage of org.jboss.logging.annotations.ConstructType
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Field.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Field.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Field.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Field.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Field (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Field

+
+
No usage of org.jboss.logging.annotations.Field
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Fields.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Fields.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Fields.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Fields.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Fields (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Fields

+
+
No usage of org.jboss.logging.annotations.Fields
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/FormatWith.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/FormatWith.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/FormatWith.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/FormatWith.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.FormatWith (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.FormatWith

+
+
No usage of org.jboss.logging.annotations.FormatWith
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/LoggingClass.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/LoggingClass.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/LoggingClass.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/LoggingClass.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.LoggingClass (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.LoggingClass

+
+
No usage of org.jboss.logging.annotations.LoggingClass
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/LogMessage.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/LogMessage.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/LogMessage.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/LogMessage.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.LogMessage (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.LogMessage

+
+
No usage of org.jboss.logging.annotations.LogMessage
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/MessageBundle.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/MessageBundle.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/MessageBundle.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/MessageBundle.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.MessageBundle (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.MessageBundle

+
+
No usage of org.jboss.logging.annotations.MessageBundle
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Message.Format.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Message.Format.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Message.Format.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Message.Format.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,159 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Message.Format (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Message.Format

+
+
+ +
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Message.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Message.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Message.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Message.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Message (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Message

+
+
No usage of org.jboss.logging.annotations.Message
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/MessageLogger.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/MessageLogger.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/MessageLogger.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/MessageLogger.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.MessageLogger (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.MessageLogger

+
+
No usage of org.jboss.logging.annotations.MessageLogger
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Once.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Once.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Once.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Once.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Once (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Once

+
+
No usage of org.jboss.logging.annotations.Once
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Param.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Param.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Param.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Param.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Param (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Param

+
+
No usage of org.jboss.logging.annotations.Param
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Pos.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Pos.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Pos.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Pos.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Pos (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Pos

+
+
No usage of org.jboss.logging.annotations.Pos
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Producer.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Producer.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Producer.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Producer.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Producer (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Producer

+
+
No usage of org.jboss.logging.annotations.Producer
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Properties.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Properties.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Properties.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Properties.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Properties (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Properties

+
+
No usage of org.jboss.logging.annotations.Properties
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Property.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Property.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Property.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Property.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Property (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Property

+
+
No usage of org.jboss.logging.annotations.Property
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ResolutionDoc.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ResolutionDoc.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ResolutionDoc.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ResolutionDoc.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.ResolutionDoc (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.ResolutionDoc

+
+
No usage of org.jboss.logging.annotations.ResolutionDoc
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Signature.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Signature.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Signature.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Signature.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Signature (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Signature

+
+
No usage of org.jboss.logging.annotations.Signature
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Suppressed.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Suppressed.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Suppressed.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Suppressed.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Suppressed (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Suppressed

+
+
No usage of org.jboss.logging.annotations.Suppressed
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Transform (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Transform

+
+
No usage of org.jboss.logging.annotations.Transform
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.TransformType.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.TransformType.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.TransformType.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/Transform.TransformType.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,159 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.Transform.TransformType (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.Transform.TransformType

+
+
+ +
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRange.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRange.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRange.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRange.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.ValidIdRange (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.ValidIdRange

+
+
No usage of org.jboss.logging.annotations.ValidIdRange
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRanges.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRanges.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRanges.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/class-use/ValidIdRanges.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,125 @@ + + + + + + +Uses of Class org.jboss.logging.annotations.ValidIdRanges (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Class
org.jboss.logging.annotations.ValidIdRanges

+
+
No usage of org.jboss.logging.annotations.ValidIdRanges
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ConstructType.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ConstructType.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ConstructType.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ConstructType.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,234 @@ + + + + + + +ConstructType (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type ConstructType

+
+
+
+
    +
  • +
    +
    +
    @Retention(value=CLASS)
    + @Target(value=METHOD)
    + @Documented
    +public @interface ConstructType
    +
    Indicates the value of this annotation should be constructed and returned. This does not change the return type of + the method. +

    + This annotation is only allowed on bundle messages that have a throwable return type. The value must be assignable + to the return type. +

    +
    +
    Since:
    +
    2.0.0
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Class<? extends Throwable>value +
      The actual type that should be constructed for the return type.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract Class<? extends Throwable> value
        +
        The actual type that should be constructed for the return type.
        +
        +
        Returns:
        +
        the class to construct
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Field.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Field.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Field.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Field.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,510 @@ + + + + + + +Field (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Field

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      booleanbooleanValue +
      The default boolean value if this annotation is used on a method.
      +
      bytebyteValue +
      The default boolean value if this annotation is used on a method.
      +
      charcharValue +
      The default byte value if this annotation is used on a method.
      +
      Class<?>classValue +
      The default Class value if this annotation is used on a method.
      +
      doubledoubleValue +
      The default double value if this annotation is used on a method.
      +
      floatfloatValue +
      The default float value if this annotation is used on a method.
      +
      intintValue +
      The default int value if this annotation is used on a method.
      +
      longlongValue +
      The default long value if this annotation is used on a method.
      +
      Stringname +
      The field name.
      +
      shortshortValue +
      The default short value if this annotation is used on a method.
      +
      StringstringValue +
      The default String value if this annotation is used on a method.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        name

        +
        public abstract String name
        +
        The field name. If not specified, the parameter name is assumed to be the field name. +

        + This becomes a required attrubyte if this annotation is present on a method. +

        +
        +
        Returns:
        +
        the field name
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        booleanValue

        +
        public abstract boolean booleanValue
        +
        The default boolean value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        false
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        byteValue

        +
        public abstract byte byteValue
        +
        The default boolean value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        charValue

        +
        public abstract char charValue
        +
        The default byte value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        classValue

        +
        public abstract Class<?> classValue
        +
        The default Class value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        java.lang.Object.class
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        doubleValue

        +
        public abstract double doubleValue
        +
        The default double value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0.0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        floatValue

        +
        public abstract float floatValue
        +
        The default float value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0.0f
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        intValue

        +
        public abstract int intValue
        +
        The default int value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        longValue

        +
        public abstract long longValue
        +
        The default long value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0L
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        shortValue

        +
        public abstract short shortValue
        +
        The default short value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        stringValue

        +
        public abstract String stringValue
        +
        The default String value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Fields.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Fields.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Fields.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Fields.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,228 @@ + + + + + + +Fields (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Fields

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Field[]value +
      The fields to use on the resultant exception object.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract Field[] value
        +
        The fields to use on the resultant exception object. Note that the name attribute is + required for these annotations.
        +
        +
        Returns:
        +
        the fields
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/FormatWith.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/FormatWith.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/FormatWith.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/FormatWith.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,231 @@ + + + + + + +FormatWith (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type FormatWith

+
+
+
+
    +
  • +
    +
    +
    @Target(value=PARAMETER)
    + @Retention(value=CLASS)
    + @Documented
    +public @interface FormatWith
    +
    Indicate that the given parameter should be wrapped with a formatting object of the given class. The class + must have a one-argument constructor which unambiguously accepts a value of this parameter's type. The resultant + object will be passed in as a parameter to the underlying format type; thus its toString() + method will be invoked (or, if the format style is PRINTF, the object may implement + Formattable to get extra functionality).
    +
    +
    Author:
    +
    David M. Lloyd
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Class<?>value +
      The class of the formatting object to use.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract Class<?> value
        +
        The class of the formatting object to use.
        +
        +
        Returns:
        +
        the class
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/LoggingClass.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/LoggingClass.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/LoggingClass.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/LoggingClass.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,173 @@ + + + + + + +LoggingClass (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type LoggingClass

+
+
+
+ +
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/LogMessage.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/LogMessage.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/LogMessage.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/LogMessage.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,259 @@ + + + + + + +LogMessage (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type LogMessage

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      org.jboss.logging.Logger.Levellevel +
      The log level at which this message should be logged.
      +
      Class<?>loggingClass +
      The logging class name to use for this message, if any.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        level

        +
        public abstract org.jboss.logging.Logger.Level level
        +
        The log level at which this message should be logged. Defaults to INFO.
        +
        +
        Returns:
        +
        the log level
        +
        +
        +
        Default:
        +
        org.jboss.logging.Logger.Level.INFO
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        loggingClass

        +
        public abstract Class<?> loggingClass
        +
        The logging class name to use for this message, if any.
        +
        +
        Returns:
        +
        the logging class name
        +
        +
        +
        Default:
        +
        java.lang.Void.class
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/MessageBundle.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/MessageBundle.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/MessageBundle.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/MessageBundle.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,311 @@ + + + + + + +MessageBundle (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type MessageBundle

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      StringprojectCode +
      Get the project code for messages that have an associated code.
      +
      +
    • +
    + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      intlength +
      The length of the padding used for each id in the message bundle.
      +
      StringrootLocale +
      Specifies the locale for formatting bundle messages.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        projectCode

        +
        public abstract String projectCode
        +
        Get the project code for messages that have an associated code. If no project code is associated + with this bundle, specify "" (the empty string).
        +
        +
        Returns:
        +
        the project code
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +
        +
      • +

        length

        +
        public abstract int length
        +
        The length of the padding used for each id in the message bundle. For example given the default padding length + of 6 and a message with an id of 100 would result would be "000100". +

        + Valid values a range of 3 to 8. Any value less than 0 turns off padding. Any other value will result in an error + being produced.

        +
        +
        Returns:
        +
        the length the id should be padded
        +
        +
        +
        Default:
        +
        6
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        rootLocale

        +
        public abstract String rootLocale
        +
        Specifies the locale for formatting bundle messages. This is only used in the super + implementation. Subclasses will define their own locale to use based on the name of the resource bundle at + compile time. +

        + An empty string will default to Locale.ROOT. +

        +

        + A non-empty string will be parsed by the Locale.forLanguageTag(String). This uses the + IETF BCP 47 format. +

        +
        +
        Returns:
        +
        the default locale message bundles should use for formatting messages
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Message.Format.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Message.Format.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Message.Format.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Message.Format.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,368 @@ + + + + + + +Message.Format (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Enum Message.Format

+
+
+ +
+ +
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        values

        +
        public static Message.Format[] values()
        +
        Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
        +for (Message.Format c : Message.Format.values())
        +    System.out.println(c);
        +
        +
        +
        Returns:
        +
        an array containing the constants of this enum type, in the order they are declared
        +
        +
      • +
      + + + +
        +
      • +

        valueOf

        +
        public static Message.Format valueOf(String name)
        +
        Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.)
        +
        +
        Parameters:
        +
        name - the name of the enum constant to be returned.
        +
        Returns:
        +
        the enum constant with the specified name
        +
        Throws:
        +
        IllegalArgumentException - if this enum type has no constant with the specified name
        +
        NullPointerException - if the argument is null
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Message.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Message.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Message.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Message.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,363 @@ + + + + + + +Message (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Message

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFields and Description
      static intINHERIT +
      Indicates that this message should inherit the ID from another message with the same name.
      +
      static intNONE +
      Indicates that this message has no ID.
      +
      +
    • +
    + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Stringvalue +
      The default format string of this message.
      +
      +
    • +
    + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      Message.Formatformat +
      The format type of this method (defaults to Message.Format.PRINTF).
      +
      intid +
      The message ID number.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        NONE

        +
        public static final int NONE
        +
        Indicates that this message has no ID.
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        INHERIT

        +
        public static final int INHERIT
        +
        Indicates that this message should inherit the ID from another message with the same name.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract String value
        +
        The default format string of this message. +

        + Expressions in the form of ${property.key:default-value} can be used for the value. If the property key is + prefixed with sys. a system property will be used. If the key is + prefixed with env. an environment variable will be used. In all other cases + the org.jboss.logging.tools.expressionProperties processor argument is used to specify the path the properties + file which contains the values for the expressions. +

        +
        +
        Returns:
        +
        the format string
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +
        +
      • +

        id

        +
        public abstract int id
        +
        The message ID number. Only one message with a given name may specify an ID other than INHERIT.
        +
        +
        Returns:
        +
        the message ID number
        +
        +
        +
        Default:
        +
        -1
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        format

        +
        public abstract Message.Format format
        +
        The format type of this method (defaults to Message.Format.PRINTF).
        +
        +
        Returns:
        +
        the format type
        +
        +
        +
        Default:
        +
        org.jboss.logging.annotations.Message.Format.PRINTF
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/MessageLogger.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/MessageLogger.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/MessageLogger.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/MessageLogger.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,313 @@ + + + + + + +MessageLogger (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type MessageLogger

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      StringprojectCode +
      Get the project code for messages that have an associated code.
      +
      +
    • +
    + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      intlength +
      The length of the padding used for each id in the message bundle.
      +
      StringrootLocale +
      Specifies the locale for formatting bundle messages.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        projectCode

        +
        public abstract String projectCode
        +
        Get the project code for messages that have an associated code. If no project code is associated + with this logger, specify "" (the empty string).
        +
        +
        Returns:
        +
        the project code
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +
        +
      • +

        length

        +
        public abstract int length
        +
        The length of the padding used for each id in the message bundle. For example given the default padding length + of 6 and a message with an id of 100 would result would be "000100". +

        + Valid values a range of 3 to 8. Any value less than 0 turns off padding. Any other value will result in an error + being produced.

        +
        +
        Returns:
        +
        the length the id should be padded
        +
        +
        +
        Default:
        +
        6
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        rootLocale

        +
        public abstract String rootLocale
        +
        Specifies the locale for formatting bundle messages. This is only used in the super + implementation. Subclasses will define their own locale to use based on the name of the resource bundle at + compile time. +

        + An empty string will default to Locale.ROOT. +

        +

        + A non-empty string will be parsed by the Locale.forLanguageTag(String). This uses the + IETF BCP 47 format. +

        +
        +
        Returns:
        +
        the default locale message bundles should use for formatting messages
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Once.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Once.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Once.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Once.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,177 @@ + + + + + + +Once (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Once

+
+
+
+ +
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-frame.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-frame.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-frame.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-frame.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,47 @@ + + + + + + +org.jboss.logging.annotations (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + +

org.jboss.logging.annotations

+ + + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-summary.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-summary.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-summary.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-summary.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,299 @@ + + + + + + +org.jboss.logging.annotations (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Package org.jboss.logging.annotations

+
+
+
    +
  • + + + + + + + + + + + + + + + + +
    Enum Summary 
    EnumDescription
    Message.Format +
    The possible format types.
    +
    Transform.TransformType +
    The transform type
    +
    +
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Annotation Types Summary 
    Annotation TypeDescription
    BaseUrl +
    Messages on reports can have a link to a resolution document.
    +
    Cause +
    Mark a parameter as being the "exception cause" parameter rather than a positional format parameter.
    +
    ConstructType +
    Indicates the value of this annotation should be constructed and returned.
    +
    Field +
    Indicate that a method parameter value should be applied to a field on the resultant exception object.
    +
    Fields +
    Defines the default field properties to use on the resultant exception object.
    +
    FormatWith +
    Indicate that the given parameter should be wrapped with a formatting object of the given class.
    +
    LoggingClass +
    Mark a parameter as specifying the name of the logging class to use.
    +
    LogMessage +
    A typed logger method.
    +
    Message +
    Assigns a message string to a resource method.
    +
    MessageBundle +
    Signify that an interface is a message bundle interface.
    +
    MessageLogger +
    Signify that an interface is a typed logger interface.
    +
    Once +
    Indicates a message should only be logged once.
    +
    Param +
    Identifies a parameter is to be used for constructing an exception and excluded from the formatting of the message.
    +
    Pos 
    Producer +
    Identifies a parameter has the ability to produce a Throwable or a super type of a Throwable.
    +
    Properties +
    Defines the default properties to use on the resultant exception object.
    +
    Property +
    Indicate that a method parameter value should be applied to a property (with a setter method) on the resultant + exception object.
    +
    ResolutionDoc +
    Allows a link to be created for messages on a report which contain a possible resolution to the issue reported .
    +
    Signature +
    Specifies the exact signature to use when creating a Throwable return type.
    +
    Suppressed +
    Indicates the parameter should be added as a suppressed exception to + the returned exception.
    +
    Transform +
    Indicate the given parameter should be transformed in each of the transform types + provided.
    +
    ValidIdRange +
    Sets a range of valid id's allowed on the message id.
    +
    ValidIdRanges 
    +
  • +
+
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-tree.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-tree.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-tree.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-tree.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,165 @@ + + + + + + +org.jboss.logging.annotations Class Hierarchy (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Hierarchy For Package org.jboss.logging.annotations

+
+
+

Annotation Type Hierarchy

+ +

Enum Hierarchy

+ +
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-use.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-use.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/package-use.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/package-use.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,150 @@ + + + + + + +Uses of Package org.jboss.logging.annotations (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Uses of Package
org.jboss.logging.annotations

+
+
+ +
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Param.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Param.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Param.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Param.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,237 @@ + + + + + + +Param (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Param

+
+
+
+
    +
  • +
    +
    +
    @Target(value=PARAMETER)
    + @Retention(value=CLASS)
    + @Documented
    +public @interface Param
    +
    Identifies a parameter is to be used for constructing an exception and excluded from the formatting of the message. +

    + Parameters will be order-matched first, then type-matched to resolve ambiguity. If a match fails an error should + occur. +

    + The value() option will allow an optional class to be specified which will have to match the exact type of + the parameter in question, to enable unambiguous resolution. The value must be the fully qualified class name.

    +
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      Class<?>value +
      Defines an exact class the parameter must match for unambiguous resolution.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract Class<?> value
        +
        Defines an exact class the parameter must match for unambiguous resolution.
        +
        +
        Returns:
        +
        the class the parameter must match.
        +
        +
        +
        Default:
        +
        java.lang.Object.class
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Pos.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Pos.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Pos.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Pos.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,273 @@ + + + + + + +Pos (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Pos

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      int[]value +
      The positions the value should be used at.
      +
      +
    • +
    + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      Transform[]transform +
      The transform types used on the parameter.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract int[] value
        +
        The positions the value should be used at.
        +
        +
        Returns:
        +
        an array of the positions for the parameter
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +
        +
      • +

        transform

        +
        public abstract Transform[] transform
        +
        The transform types used on the parameter.
        +
        +
        Returns:
        +
        an array of the transformer types
        +
        See Also:
        +
        Transform
        +
        +
        +
        Default:
        +
        {}
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Producer.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Producer.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Producer.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Producer.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,210 @@ + + + + + + +Producer (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Producer

+
+
+
+
    +
  • +
    +
    +
    @Target(value=PARAMETER)
    + @Retention(value=CLASS)
    + @Documented
    +public @interface Producer
    +
    Identifies a parameter has the ability to produce a Throwable or a super type of a Throwable. The + parameter type must be a Function or a BiFunction. +

    + For a Function the input parameter must be a String which will be the message + associated with the method. The result type must Throwable or a super type of a Throwable. +

    + +

    + For a BiFunction one of the input parameters must be a String which will be the + message associated with the method. The other input parameter must be a Throwable or a super type of a + Throwable and must be assignable from the parameter annotated with Cause. The result type must + Throwable or a super type of a Throwable. +

    + +

    + Example + +

    + @Message("The operation failed due to %s")
    +  T operationFailed(@Producer Function function, String op);
    +
    + @Message("The operation failed due to %s")
    +  T operationFailed(@Producer BiFunction function, @Cause Throwable cause, String op);
    +
    + 
    + +

    + +

    + Example Usage + +

    + throw Bundle.MESSAGES.operationFailed(IllegalArgumentException::new, "start");
    +
    + throw Bundle.MESSAGES.operationFailed(IllegalStateException::new, cause, "start");
    +
    + 
    + +

    +
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Properties.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Properties.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Properties.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Properties.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,228 @@ + + + + + + +Properties (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Properties

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Property[]value +
      The properties to use on the resultant exception object.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract Property[] value
        +
        The properties to use on the resultant exception object. Note that the name attribute is + required for these annotations.
        +
        +
        Returns:
        +
        the properties
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Property.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Property.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Property.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Property.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,511 @@ + + + + + + +Property (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Property

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      booleanbooleanValue +
      The default boolean value if this annotation is used on a method.
      +
      bytebyteValue +
      The default boolean value if this annotation is used on a method.
      +
      charcharValue +
      The default byte value if this annotation is used on a method.
      +
      Class<?>classValue +
      The default Class value if this annotation is used on a method.
      +
      doubledoubleValue +
      The default double value if this annotation is used on a method.
      +
      floatfloatValue +
      The default float value if this annotation is used on a method.
      +
      intintValue +
      The default int value if this annotation is used on a method.
      +
      longlongValue +
      The default long value if this annotation is used on a method.
      +
      Stringname +
      The property name.
      +
      shortshortValue +
      The default short value if this annotation is used on a method.
      +
      StringstringValue +
      The default String value if this annotation is used on a method.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        name

        +
        public abstract String name
        +
        The property name. If not specified, the parameter name is assumed to be the property name. +

        + This becomes a required attribute if this annotation is present on a method. +

        +
        +
        Returns:
        +
        the property name
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        booleanValue

        +
        public abstract boolean booleanValue
        +
        The default boolean value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        false
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        byteValue

        +
        public abstract byte byteValue
        +
        The default boolean value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        charValue

        +
        public abstract char charValue
        +
        The default byte value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        classValue

        +
        public abstract Class<?> classValue
        +
        The default Class value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        java.lang.Object.class
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        doubleValue

        +
        public abstract double doubleValue
        +
        The default double value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0.0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        floatValue

        +
        public abstract float floatValue
        +
        The default float value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0.0f
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        intValue

        +
        public abstract int intValue
        +
        The default int value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        longValue

        +
        public abstract long longValue
        +
        The default long value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0L
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        shortValue

        +
        public abstract short shortValue
        +
        The default short value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        stringValue

        +
        public abstract String stringValue
        +
        The default String value if this annotation is used on a method.
        +
        +
        Returns:
        +
        the default value to use
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ResolutionDoc.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ResolutionDoc.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ResolutionDoc.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ResolutionDoc.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,350 @@ + + + + + + +ResolutionDoc (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type ResolutionDoc

+
+
+
+
    +
  • +
    +
    +
    @Target(value={METHOD,TYPE})
    + @Retention(value=CLASS)
    + @Documented
    +public @interface ResolutionDoc
    +
    Allows a link to be created for messages on a report which contain a possible resolution to the issue reported . If + the method does not include an id no link will be created for the report unless a + path() is defined. + +

    + The rules for building the URL are as follows: +

      +
    • url: If left empty and the type is annotated with a BaseUrl the value for the + @BaseUrl will be used. If defined this will override the value of the BaseUrl. If neither are + defined the rules for the path() will be followed.
    • +
    • path: If defined this will be the path appended to the url() or the value of the + BaseUrl. Note that neither url() nor BaseUrl are required. If the value is left + undefined the id (project code plus the message id) will be used for the path.
    • +
    • suffix: The suffix to append to the path(). This is mostly useful if the path + is left undefined and a suffix should be appended to the messages id. If left undefined and the path() + is not defined, the suffix will be determined based on the report type.
    • +
    +

    + +

    + If placed on a type links will be created for all methods on the type. +

    + +

    + Do note that the processor does not validate the resolution document exists. It simply attempts to create links to + the resolution document. +

    +

    + Expressions in the form of ${property.key:default-value} can be used for the values with the exception of the + skip attribute. If the property key is prefixed with sys. a + system property will be used. If the key is prefixed with env. an + environment variable will be used. In all other cases the + org.jboss.logging.tools.expressionProperties processor argument is used to specify the path the properties + file which contains the values for the expressions. +

    +
    +
    Since:
    +
    1.2
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      Stringpath +
      The path to the resolution document.
      +
      booleanskip +
      Allows the creation of a link to be skipped.
      +
      Stringsuffix +
      The suffix to append to the path.
      +
      Stringurl +
      The URL, fully qualified or relative, to use for the resolution document.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        url

        +
        public abstract String url
        +
        The URL, fully qualified or relative, to use for the resolution document. If defined this will override the value + of the BaseUrl if the annotation is used.
        +
        +
        Returns:
        +
        the URL or an empty string
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        path

        +
        public abstract String path
        +
        The path to the resolution document. If left undefined this will default to the message id.
        +
        +
        Returns:
        +
        the path to the resolution document
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        suffix

        +
        public abstract String suffix
        +
        The suffix to append to the path. If left undefined this will default to the extension for the report type. For + example if the report type is xml the default suffix would be .xml.
        +
        +
        Returns:
        +
        the suffix for the resolution document
        +
        +
        +
        Default:
        +
        ""
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        skip

        +
        public abstract boolean skip
        +
        Allows the creation of a link to be skipped.
        +
        +
        Returns:
        +
        true if creating the link should be skipped
        +
        +
        +
        Default:
        +
        false
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Signature.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Signature.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Signature.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Signature.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,338 @@ + + + + + + +Signature (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Signature

+
+
+
+
    +
  • +
    +
    +
    @Retention(value=CLASS)
    + @Target(value=METHOD)
    + @Documented
    +public @interface Signature
    +
    Specifies the exact signature to use when creating a Throwable return type. + +

    + Given the following exception and message bundle interface method the InvalidIntValueException(final RuntimeException cause, final String msg, final int value) + constructor would be used. + + +

    + public class InvalidIntValueException extends RuntimeException {
    +     private final RuntimeException causeAsRuntime;
    +     private final int value;
    +     public InvalidIntValueException(final Throwable cause, final String msg, final int value) {
    +         super(msg, cause);
    +         causeAsRuntime = new RuntimeException(cause);
    +         this.value = value;
    +     }
    +
    +     public InvalidIntValueException(final RuntimeException cause, final String msg, final int value) {
    +         super(msg, cause);
    +         causeAsRuntime = cause;
    +         this.value = value;
    +     }
    +     public InvalidIntValueException(final RuntimeException cause, final String msg, final Integer value) {
    +         super(msg, cause);
    +         causeAsRuntime = cause;
    +         this.value = value;
    +     }
    + }
    + 
    + + + +
    + @Message("Invalid value %d")
    + @Signature(causeIndex = 0, messageIndex = 1, value = {RuntimeException.class, String.class, int.class}
    + InvalidIntValueException invalidValue(@Cause RuntimeException cause, @Param int value);
    + 
    +
    +

    +
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Class<?>[]value +
      An array of types matching the exact signature to use for the exception being created.
      +
      +
    • +
    + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      intcauseIndex +
      The index for the cause of the exception being created.
      +
      intmessageIndex +
      The index for the message.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract Class<?>[] value
        +
        An array of types matching the exact signature to use for the exception being created.
        +
        +
        Returns:
        +
        an array of types used to find the signature
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +
        +
      • +

        causeIndex

        +
        public abstract int causeIndex
        +
        The index for the cause of the exception being created. A value of less than zero assumes + there is no cause parameter in the constructor. A Cause annotation can still be used and the + Throwable.initCause(Throwable) will be used to initialize the cause of the exception.
        +
        +
        Returns:
        +
        the index for the cause parameter
        +
        +
        +
        Default:
        +
        -1
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        messageIndex

        +
        public abstract int messageIndex
        +
        The index for the message. This is the formatted messaged from the Message.value(). This is a required + value defaulting to 0 which would be the first parameter.
        +
        +
        Returns:
        +
        the index for the message parameter
        +
        +
        +
        Default:
        +
        0
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Suppressed.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Suppressed.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Suppressed.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Suppressed.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,179 @@ + + + + + + +Suppressed (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Suppressed

+
+
+
+ +
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Transform.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Transform.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Transform.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Transform.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,245 @@ + + + + + + +Transform (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type Transform

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      Transform.TransformType[]value +
      The transform types used on the parameter.
      +
      +
    • +
    +
  • +
+
+
+ +
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Transform.TransformType.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Transform.TransformType.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/Transform.TransformType.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/Transform.TransformType.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,383 @@ + + + + + + +Transform.TransformType (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Enum Transform.TransformType

+
+
+ +
+ +
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        values

        +
        public static Transform.TransformType[] values()
        +
        Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
        +for (Transform.TransformType c : Transform.TransformType.values())
        +    System.out.println(c);
        +
        +
        +
        Returns:
        +
        an array containing the constants of this enum type, in the order they are declared
        +
        +
      • +
      + + + +
        +
      • +

        valueOf

        +
        public static Transform.TransformType valueOf(String name)
        +
        Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.)
        +
        +
        Parameters:
        +
        name - the name of the enum constant to be returned.
        +
        Returns:
        +
        the enum constant with the specified name
        +
        Throws:
        +
        IllegalArgumentException - if this enum type has no constant with the specified name
        +
        NullPointerException - if the argument is null
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ValidIdRange.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ValidIdRange.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ValidIdRange.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ValidIdRange.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,274 @@ + + + + + + +ValidIdRange (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type ValidIdRange

+
+
+
+
    +
  • +
    +
    +
    @Target(value=TYPE)
    + @Retention(value=CLASS)
    + @Documented
    +public @interface ValidIdRange
    +
    Sets a range of valid id's allowed on the message id. Both Message.INHERIT and Message.NONE are ignored when validating. +

    + Note: Message id's from inherited interfaces are not validated within the range provided. Super interfaces + would need their own annotation for range validation. +

    + +

    +          @MessageLogger(projectCode = "EXAMPLE")
    +          @ValidIdRange(min = 100, max = 200)
    +          public interface ExampleLogger {
    +
    +              @LogMessage
    +              @Message(id = 100, value = "Example message")
    +              void example();
    +          }
    + 
    +
    +
    +
    Author:
    +
    James R. Perkins
    +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Optional Element Summary

      + + + + + + + + + + + + + + +
      Optional Elements 
      Modifier and TypeOptional Element and Description
      intmax +
      The maximum id allowed in the message id.
      +
      intmin +
      The minimum id allowed in the message id.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        min

        +
        public abstract int min
        +
        The minimum id allowed in the message id. Both Message.INHERIT and Message.NONE are ignored when validating.
        +
        +
        Returns:
        +
        the minimum id allowed
        +
        +
        +
        Default:
        +
        1
        +
        +
      • +
      +
    • +
    +
      +
    • + + +
        +
      • +

        max

        +
        public abstract int max
        +
        The maximum id allowed in the message id. Both Message.INHERIT and Message.NONE are ignored when validating.
        +
        +
        Returns:
        +
        the maximum id allowed
        +
        +
        +
        Default:
        +
        999999
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ValidIdRanges.html jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ValidIdRanges.html --- jboss-logging-tools-2.0.2/docs/apidocs/org/jboss/logging/annotations/ValidIdRanges.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/org/jboss/logging/annotations/ValidIdRanges.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,226 @@ + + + + + + +ValidIdRanges (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + + +
+
org.jboss.logging.annotations
+

Annotation Type ValidIdRanges

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Required Element Summary

      + + + + + + + + + + +
      Required Elements 
      Modifier and TypeRequired Element and Description
      ValidIdRange[]value +
      An array of valid id ranges.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Element Detail

      + + + +
        +
      • +

        value

        +
        public abstract ValidIdRange[] value
        +
        An array of valid id ranges.
        +
        +
        Returns:
        +
        an array of valid id ranges
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/overview-tree.html jboss-logging-tools-2.1.0/docs/apidocs/overview-tree.html --- jboss-logging-tools-2.0.2/docs/apidocs/overview-tree.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/overview-tree.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,169 @@ + + + + + + +Class Hierarchy (JBoss Logging I18n Documentation 2.1.0.Final API) + + + + + + + +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +
+

Hierarchy For All Packages

+Package Hierarchies: + +
+
+

Annotation Type Hierarchy

+ +

Enum Hierarchy

+ +
+ +
+ + + + + + + +
JBoss Logging Tools, 2.1.0.Final
+
+ + +

Copyright © 2017 JBoss by Red Hat. All rights reserved.

+ + diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/package-list jboss-logging-tools-2.1.0/docs/apidocs/package-list --- jboss-logging-tools-2.0.2/docs/apidocs/package-list 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/package-list 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1 @@ +org.jboss.logging.annotations diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/script.js jboss-logging-tools-2.1.0/docs/apidocs/script.js --- jboss-logging-tools-2.0.2/docs/apidocs/script.js 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/script.js 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff -Nru jboss-logging-tools-2.0.2/docs/apidocs/stylesheet.css jboss-logging-tools-2.1.0/docs/apidocs/stylesheet.css --- jboss-logging-tools-2.0.2/docs/apidocs/stylesheet.css 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/apidocs/stylesheet.css 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff -Nru jboss-logging-tools-2.0.2/docs/default-notes.html jboss-logging-tools-2.1.0/docs/default-notes.html --- jboss-logging-tools-2.0.2/docs/default-notes.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/default-notes.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,547 @@ + + + + + + + +Untitled + + + + + + + +
+
+ + + + + +
+ + +A message is inheritable if the two methods have the same name and same number of format parameters. +
+
+
+ + + + + +
+ + +A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; @FormatWith, @Pos or @Transform. +
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/examples/AppLogger.html jboss-logging-tools-2.1.0/docs/examples/AppLogger.html --- jboss-logging-tools-2.0.2/docs/examples/AppLogger.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/examples/AppLogger.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,566 @@ + + + + + + + +Example Messages + + + + + + + +
+ + ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1. org.jboss.logging.tools.examples.AppLogger
Message IdMessageLog LevelReturn Type

 — 

%s version %d.%d.%d.%s

INFO

void

CW000100

Failure while closing %s

ERROR

void

CW000101

Encoding %s could not be found. Defaulting to %s.

WARN

void

CW000102

Cache size changed to %d

INFO

void

+
+ + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/examples/ErrorMessages.html jboss-logging-tools-2.1.0/docs/examples/ErrorMessages.html --- jboss-logging-tools-2.0.2/docs/examples/ErrorMessages.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/examples/ErrorMessages.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,572 @@ + + + + + + + +Example Messages + + + + + + + +
+ + ++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1. org.jboss.logging.tools.examples.ErrorMessages
Message IdMessageLog LevelReturn Type

 — 

Version %d.%d.%d.%s

 — 

java.lang.String

CW000001

Value %s is invalid

 — 

java.lang.IllegalArgumentException

CW000002

Failure closing %s

 — 

org.jboss.logging.tools.examples.CloseException

CW000003

Parameter %s cannot be null

 — 

java.util.function.Supplier

CW000004

Operation %s failed.

 — 

java.lang.RuntimeException

+
+ + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/examples/errors/CW000003.html jboss-logging-tools-2.1.0/docs/examples/errors/CW000003.html --- jboss-logging-tools-2.0.2/docs/examples/errors/CW000003.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/examples/errors/CW000003.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,532 @@ + + + + + + + +CW000003: Null Parameter + + + + + + + +
+
+

CW000003: Null Parameter

+
+
+

This error indicates you’ve passed a null parameter where a non-null value +is required.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/examples/errors/CW000100.html jboss-logging-tools-2.1.0/docs/examples/errors/CW000100.html --- jboss-logging-tools-2.0.2/docs/examples/errors/CW000100.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/examples/errors/CW000100.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,532 @@ + + + + + + + +CW000100: Close Failure + + + + + + + +
+
+

CW000100: Close Failure

+
+
+

This error indicates there was a failure closing a resource. Please see previous error messages and contact support if +required.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/examples/errors/CW000101.html jboss-logging-tools-2.1.0/docs/examples/errors/CW000101.html --- jboss-logging-tools-2.0.2/docs/examples/errors/CW000101.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/examples/errors/CW000101.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,532 @@ + + + + + + + +CW000101: Encoding Error + + + + + + + +
+
+

CW000101: Encoding Error

+
+
+

This error indicates an invalid encoding is attempting to be used and a default encoding of UTF-8 will be used. You can +fix this by setting a valid encoding value.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/examples.html jboss-logging-tools-2.1.0/docs/examples.html --- jboss-logging-tools-2.0.2/docs/examples.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/examples.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,622 @@ + + + + + + + +Example Use Cases + + + + + + + +
+
+

Example Use Cases

+
+
+

Below are some example use case snippets from the examples.

+
+
+
+
/**
+ * Writes the value of the object to the file.
+ *
+ * @param value the value to write, cannot be {@code null}
+ *
+ * @throws UncheckedIOException if an error occurs writing the data
+ */
+public void write(final Object value) {
+    AppLogger.LOGGER.appVersion("ContentWriter", 1, 0, 0, "Beta1"); (1)
+    Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")); (2)
+    write(Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")).toString());
+}
+
+/**
+ * Writes the value to the file.
+ *
+ * @param value the value to write, cannot be {@code null} or an {@linkplain String#isEmpty() empty string}.
+ *
+ * @throws UncheckedIOException if an error occurs writing the data
+ */
+public void write(final String value) {
+    AppLogger.LOGGER.appVersion("ContentWriter", 1, 0, 0, "Beta1");
+    if (Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")).isEmpty()) {
+        throw ErrorMessages.MESSAGES.invalidValue(value); (3)
+    }
+    try {
+        synchronized (outputLock) {
+            writer.write(value);
+            writer.newLine();
+            if (autoFlush) {
+                flush();
+            }
+        }
+    } catch (IOException e) {
+        throw ErrorMessages.MESSAGES.operationFailed(UncheckedIOException::new, e, "write"); (4)
+    }
+}
+
+@Override
+public void close() {
+    try {
+        synchronized (outputLock) {
+            writer.close();
+        }
+        AppLogger.LOGGER.tracef("ContentWriter %s was successfully closed.", this);
+    } catch (Exception e) {
+        throw ErrorMessages.MESSAGES.closeFailure(e, this);
+    }
+}
+
+/**
+ * Safely close this writer logging any errors that occur during closing.
+ */
+public void safeClose() {
+    try {
+        synchronized (outputLock) {
+            writer.close();
+        }
+        AppLogger.LOGGER.tracef("ContentWriter %s was successfully closed.", this);
+    } catch (Exception e) {
+        AppLogger.LOGGER.closeFailure(e, this); (5)
+    }
+}
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
1Logs the application version. Note this uses the @Once annotation to indicate this should only be logged once regardless of which write method is used.
2The ErrorMessages.nullParam() returns a java.lang.function.Supplier. This allows the message to be lazily formatted only if the value is null.
3Throws a message if the value is an empty string.
4Uses a java.lang.function.BiFunction to create a new UncheckedIOException with the caught exception set as the cause.
5Logs the caught exception instead of throwing a new exception.
+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/expressions.html jboss-logging-tools-2.1.0/docs/expressions.html --- jboss-logging-tools-2.0.2/docs/expressions.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/expressions.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,550 @@ + + + + + + + +Untitled + + + + + + + +
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/getting-started.html jboss-logging-tools-2.1.0/docs/getting-started.html --- jboss-logging-tools-2.0.2/docs/getting-started.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/getting-started.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,588 @@ + + + + + + + +Getting Started + + + + + + + +
+
+

Getting Started

+
+
+

To get started you need to include three dependencies in your project.

+
+ ++++ + + + + + + + + + + + + + + +

JBoss Logging

Required at compile time and runtime.

JBoss Logging Annotations

Required at compile time only.

JBoss Logging Processor

Required at compile time only.

+
+

If you’re using maven here is an example pom.xml snippet:

+
+
+
+
<dependencies>
+    <!-- Required by the annotation processor and will be used at runtime -->
+    <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging</artifactId>
+    </dependency>
+
+    <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging-annotations</artifactId>
+        <version>2.1.0.Final</version>
+        <!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
+              projects that depend on this project.-->
+        <scope>provided</scope>
+        <optional>true</optional>
+    </dependency>
+
+    <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging-processor</artifactId>
+        <version>2.1.0.Final</version>
+        <!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
+              projects that depend on this project.-->
+        <scope>provided</scope>
+        <optional>true</optional>
+    </dependency>
+</dependencies>
+
+
+
+

Once your project is configured you can create either a message bundle interface or a message logger interface. For detailed information see the JavaDocs for the annotations.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/index.html jboss-logging-tools-2.1.0/docs/index.html --- jboss-logging-tools-2.0.2/docs/index.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/index.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,1242 @@ + + + + + + + + +JBoss Logging Tools + + + + + + + +
+
+

Introduction

+
+
+

The JBoss logging tools are used to create internationalized log statements and exceptions.

+
+
+
+
+

Getting Started

+
+
+

To get started you need to include three dependencies in your project.

+
+ ++++ + + + + + + + + + + + + + + +

JBoss Logging

Required at compile time and runtime.

JBoss Logging Annotations

Required at compile time only.

JBoss Logging Processor

Required at compile time only.

+
+

If you’re using maven here is an example pom.xml snippet:

+
+
+
+
<dependencies>
+    <!-- Required by the annotation processor and will be used at runtime -->
+    <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging</artifactId>
+    </dependency>
+
+    <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging-annotations</artifactId>
+        <version>2.1.0.Final</version>
+        <!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
+              projects that depend on this project.-->
+        <scope>provided</scope>
+        <optional>true</optional>
+    </dependency>
+
+    <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging-processor</artifactId>
+        <version>2.1.0.Final</version>
+        <!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
+              projects that depend on this project.-->
+        <scope>provided</scope>
+        <optional>true</optional>
+    </dependency>
+</dependencies>
+
+
+
+

Once your project is configured you can create either a message bundle interface or a message logger interface. For detailed information see the JavaDocs for the annotations.

+
+
+
+
+

Message Bundle Interfaces

+
+
+

Message bundle interfaces provide a way to internationalize exceptions or strings. A message bundle interface is +annotated with @MessageBundle. Each method in must be annotated with @Message +which will be used to determine the String used for either the return type or the message for the exception being +returned.

+
+
+

The value for a @Message may contain an expression.

+
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+

The following constraints are placed on methods in a message bundle:

+
+
+
    +
  • +

    The return type must be one of the follow

    +
    +
      +
    • +

      A java.lang.String

      +
    • +
    • +

      A java.lang.Throwable or a subtype of java.lang.Throwable

      +
    • +
    • +

      A java.lang.function.Supplier who’s return type fits one of the other two constraints above.

      +
    • +
    +
    +
  • +
  • +

    The method must be annotated with @Message or a message must be inheritable.

    +
  • +
  • +

    A method can have only one @Cause parameter.

    +
  • +
  • +

    A method can only have one @Producer parameter.

    +
  • +
+
+
+ + + + + +
+ + +A message is inheritable if the two methods have the same name and same number of format parameters. +
+
+
+ + + + + +
+ + +A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; @FormatWith, @Pos or @Transform. +
+
+
+

Example Message Bundle

+
+
+
@MessageBundle(projectCode = "CW") (1)
+public interface ErrorMessages {
+    ErrorMessages MESSAGES = Messages.getBundle(ErrorMessages.class);
+
+    @Message("Version %d.%d.%d.%s") (2)
+    String version(int major, int minor, int macro, String rel);
+
+    @Message(id = 1, value = "Value '%s' is invalid")
+    IllegalArgumentException invalidValue(Object value);
+
+    @Message(id = 2, value = "Failure closing %s") (3)
+    CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c);
+
+    CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c, @Suppressed Throwable... errors);
+
+    @Message(id = 3, value = "Parameter %s cannot be null")
+    Supplier<String> nullParam(String name);
+
+    @Message(id = 4, value = "Operation %s failed.")
+    <T extends RuntimeException> T operationFailed(@Producer Function<String, T> fn, String name); (4)
+
+    <T extends RuntimeException> T operationFailed(@Producer BiFunction<String, IOException, T> fn, @Cause IOException cause, String name);
+}
+
+
+
+ + + + + + + + + + + + + + + + + +
1The projectCode will be prepended to messages which have an id specified. For example with id = 1 the message will be prepended with CW000001. You can control the number padding with the length property on the annotation.
2No id is specified for this message which means no id will be prepended on this message.
3The @Param annotation tells the generator that the parameter should be used to construct the CloseException. The @Pos(1) annotation indicates the parameter should also be used when formatting the message.
4The @Producer annotation indicates that the Function should be used to create the exception being returned.
+
+
+ + + + + +
+ + +Message bundle interfaces can also contain valid message logger methods. +
+
+
+
+
+
+

Message Logger Interfaces

+
+
+

Logger interfaces provide a way to internationalize log messages. A logger interface is an interface annotated with +@MessageLogger. Each method in must be annotated with @Message which will +be used to determine the message to be logged.

+
+
+

The value for a @Message may contain an expression.

+
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+

The following constraints are placed on methods in a message logger:

+
+
+
    +
  • +

    The method must have a void return type

    +
  • +
  • +

    The method must be annotated with @LogMessage

    +
  • +
  • +

    The method must be annotated with @Message or a message must be inheritable.

    +
  • +
  • +

    A method can have only one @Cause parameter.

    +
  • +
+
+
+ + + + + +
+ + +A message is inheritable if the two methods have the same name and same number of format parameters. +
+
+
+ + + + + +
+ + +A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; @FormatWith, @Pos or @Transform. +
+
+
+

A message logger interface may also extend the org.jboss.logging.BasicLogger. This allows the logging interface to be usable for standard logging. For example AppLogger.LOGGER.debugf("Initializing %s", this);

+
+
+

Example Message Logger

+
+
+
@MessageLogger(projectCode = "CW") (1)
+public interface AppLogger extends BasicLogger {
+
+    AppLogger LOGGER = Logger.getMessageLogger(AppLogger.class, AppLogger.class.getPackage().getName());
+
+    @LogMessage
+    @Once (2)
+    @Message("%s version %d.%d.%d.%s") (3)
+    void appVersion(CharSequence name, int major, int minor, int macro, String rel);
+
+    @LogMessage(level = Logger.Level.ERROR) (4)
+    @Message(id = 100, value = "Failure while closing %s")
+    void closeFailure(@Cause Throwable cause, Object obj);
+
+    @LogMessage(level = Logger.Level.WARN)
+    @Message(id = 101, value = "Encoding %s could not be found. Defaulting to %s.")
+    void encodingNotFound(String encoding, Charset dft);
+
+    @LogMessage
+    @Message(id = 102, value = "Cache size changed to '%d'")
+    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Collection<String> c);
+
+    @LogMessage
+    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) String... array);
+
+    @LogMessage
+    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Map<String, Object> map);
+}
+
+
+
+ + + + + + + + + + + + + + + + + +
1The projectCode will be prepended to messages which have an id specified. For example with id = 100 the message will be prepended with CW000100. You can control the number padding with the length property on the annotation.
2Ensures the log message is only written once.
3No id is specified for this message which means no id will be prepended on this message.
4Overrides the default level to ERROR to indicate an error message should be logged.
+
+
+
+
+
+

Reports

+
+
+

There are currently two types of reports that can be generated. The options are adoc or asciidoc for asciidoc and xml for XML.

+
+
+

The reports contain the following data:

+
+
+
    +
  • +

    The formatted message id.

    +
  • +
  • +

    A possible link to a resolution document for the error.

    +
  • +
  • +

    The unformatted message.

    +
  • +
  • +

    The log level, if applicable.

    +
  • +
  • +

    The return type, if applicable.

    +
  • +
+
+
+

Annotations

+
+

Two annotations can be used to assist withing linking resolution documents for messages.

+
+
+
    +
  • +

    @BaseUrl

    +
    +
      +
    • +

      This annotation can be used on a type to define the base URL for linking resolution documents. This annotation is +not required for links to be created on reports.

      +
    • +
    +
    +
  • +
  • +

    @ResolutionDoc

    +
    +
      +
    • +

      This annotation is used to define information about the resolution document for creating links. If placed on an +interface all methods that have a defined id will have a link generated. This can also be placed individually on +the method to only generate links for specific id’s.

      +
    • +
    +
    +
  • +
+
+
+
+
+
+

Example Use Cases

+
+
+

Below are some example use case snippets from the examples.

+
+
+
+
/**
+ * Writes the value of the object to the file.
+ *
+ * @param value the value to write, cannot be {@code null}
+ *
+ * @throws UncheckedIOException if an error occurs writing the data
+ */
+public void write(final Object value) {
+    AppLogger.LOGGER.appVersion("ContentWriter", 1, 0, 0, "Beta1"); (1)
+    Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")); (2)
+    write(Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")).toString());
+}
+
+/**
+ * Writes the value to the file.
+ *
+ * @param value the value to write, cannot be {@code null} or an {@linkplain String#isEmpty() empty string}.
+ *
+ * @throws UncheckedIOException if an error occurs writing the data
+ */
+public void write(final String value) {
+    AppLogger.LOGGER.appVersion("ContentWriter", 1, 0, 0, "Beta1");
+    if (Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")).isEmpty()) {
+        throw ErrorMessages.MESSAGES.invalidValue(value); (3)
+    }
+    try {
+        synchronized (outputLock) {
+            writer.write(value);
+            writer.newLine();
+            if (autoFlush) {
+                flush();
+            }
+        }
+    } catch (IOException e) {
+        throw ErrorMessages.MESSAGES.operationFailed(UncheckedIOException::new, e, "write"); (4)
+    }
+}
+
+@Override
+public void close() {
+    try {
+        synchronized (outputLock) {
+            writer.close();
+        }
+        AppLogger.LOGGER.tracef("ContentWriter %s was successfully closed.", this);
+    } catch (Exception e) {
+        throw ErrorMessages.MESSAGES.closeFailure(e, this);
+    }
+}
+
+/**
+ * Safely close this writer logging any errors that occur during closing.
+ */
+public void safeClose() {
+    try {
+        synchronized (outputLock) {
+            writer.close();
+        }
+        AppLogger.LOGGER.tracef("ContentWriter %s was successfully closed.", this);
+    } catch (Exception e) {
+        AppLogger.LOGGER.closeFailure(e, this); (5)
+    }
+}
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
1Logs the application version. Note this uses the @Once annotation to indicate this should only be logged once regardless of which write method is used.
2The ErrorMessages.nullParam() returns a java.lang.function.Supplier. This allows the message to be lazily formatted only if the value is null.
3Throws a message if the value is an empty string.
4Uses a java.lang.function.BiFunction to create a new UncheckedIOException with the caught exception set as the cause.
5Logs the caught exception instead of throwing a new exception.
+
+
+
+
+

Translation Property Files

+
+
+

The translation properties files must exist in the same directory structure as the interface. The name of the properties file InterfaceName.i18n_language_country_variant.properties. For example if you have a class named org.jboss.logging.tools.examples.ErrorMessages and you want to translate this into French you create a properties file called ErrorMessages.i18n_fr.properties in a directory org/jboss/logging/tools/examples.

+
+
+
+
+

Annotation Processor Options

+
+
+

You can pass options to an annotation processor with the -A compiler option. For example to disable generating the @Generated annotation from being placed on the generated source files you would pass -Aorg.jboss.logging.tools.addGeneratedAnnotation=false to the compiler command.

+
+
+

General

+ ++++ + + + + + + + + + + + + + + + + + + + + +
OptionDescription

debug

This option turns on debug logging for the processor

org.jboss.logging.tools.expressionProperties

This option allows you to define a path where, at compile-time, expressions in messages can be resolved.

org.jboss.logging.tools.addGeneratedAnnotation

If set to false the @Generated annotation will not be placed on the generated source files. The default is true.

+
+ + + + + +
+ + +In Java 9 the @javax.annotation.Generated was moved to @javax.annotation.processor.Generated. The processor attempts to determine which annotation to use by attempting to find the @javax.annotation.Generated first. If it fails the @javax.annotation.processor.Generated is attempted. If neither can be found no annotation will be placed on the generated implementations. +
+
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+
+

Translation Options

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + +
OptionDescription

translationsFilesPath

The base path for the translated properties files. This defaults to the location where new class files are placed.

skipTranslations

If set to true source files with the translated tet will not be generated. The default is false.

generatedTranslationFilesPath

If defined this indicates the path a skeleton file should be generated for the interface. The generated skeleton file will be placed in a directory that matches the package with a name that matches the interface with a .i18n_locale_COUNTRY_VARIANT.properties suffix.

org.jboss.logging.tools.level

Sets the maximum level to include in the generated skeleton files. For example if set to INFO the skeleton files will not contain any properties where the log level was set to DEBUG or TRACE.

+
+
+

Report Options

+ ++++ + + + + + + + + + + + + + + + + + + + + +
OptionDescription

org.jboss.logging.tools.report.type

Indicates the type of report that should be generated. The current report types are adoc for asciidoc or xml for XML.

org.jboss.logging.tools.report.path

The path where the generated reports should be placed. This defaults to the location where new class files are placed.

org.jboss.logging.tools.report.title

An optional title for the report. For asciidoc this defaults to Messages. For XML the <title> element is left off.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/js/links.js jboss-logging-tools-2.1.0/docs/js/links.js --- jboss-logging-tools-2.0.2/docs/js/links.js 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/js/links.js 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,9 @@ +function annotationLinks() { + var links = document.getElementsByTagName("a"); + for(var i = 0, max = links.length; i < max; i++) { + var l = links[i]; + if (l.text.startsWith("@")) { + l.href = l.href + "/org/jboss/logging/annotations/" + l.text.substring(1) + ".html"; + } + } +} \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/message-bundle.html jboss-logging-tools-2.1.0/docs/message-bundle.html --- jboss-logging-tools-2.0.2/docs/message-bundle.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/message-bundle.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,682 @@ + + + + + + + +Message Bundle Interfaces + + + + + + + +
+
+

Message Bundle Interfaces

+
+
+

Message bundle interfaces provide a way to internationalize exceptions or strings. A message bundle interface is +annotated with @MessageBundle. Each method in must be annotated with @Message +which will be used to determine the String used for either the return type or the message for the exception being +returned.

+
+
+

The value for a @Message may contain an expression.

+
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+

The following constraints are placed on methods in a message bundle:

+
+
+
    +
  • +

    The return type must be one of the follow

    +
    +
      +
    • +

      A java.lang.String

      +
    • +
    • +

      A java.lang.Throwable or a subtype of java.lang.Throwable

      +
    • +
    • +

      A java.lang.function.Supplier who’s return type fits one of the other two constraints above.

      +
    • +
    +
    +
  • +
  • +

    The method must be annotated with @Message or a message must be inheritable.

    +
  • +
  • +

    A method can have only one @Cause parameter.

    +
  • +
  • +

    A method can only have one @Producer parameter.

    +
  • +
+
+
+ + + + + +
+ + +A message is inheritable if the two methods have the same name and same number of format parameters. +
+
+
+ + + + + +
+ + +A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; @FormatWith, @Pos or @Transform. +
+
+
+

Example Message Bundle

+
+
+
@MessageBundle(projectCode = "CW") (1)
+public interface ErrorMessages {
+    ErrorMessages MESSAGES = Messages.getBundle(ErrorMessages.class);
+
+    @Message("Version %d.%d.%d.%s") (2)
+    String version(int major, int minor, int macro, String rel);
+
+    @Message(id = 1, value = "Value '%s' is invalid")
+    IllegalArgumentException invalidValue(Object value);
+
+    @Message(id = 2, value = "Failure closing %s") (3)
+    CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c);
+
+    CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c, @Suppressed Throwable... errors);
+
+    @Message(id = 3, value = "Parameter %s cannot be null")
+    Supplier<String> nullParam(String name);
+
+    @Message(id = 4, value = "Operation %s failed.")
+    <T extends RuntimeException> T operationFailed(@Producer Function<String, T> fn, String name); (4)
+
+    <T extends RuntimeException> T operationFailed(@Producer BiFunction<String, IOException, T> fn, @Cause IOException cause, String name);
+}
+
+
+
+ + + + + + + + + + + + + + + + + +
1The projectCode will be prepended to messages which have an id specified. For example with id = 1 the message will be prepended with CW000001. You can control the number padding with the length property on the annotation.
2No id is specified for this message which means no id will be prepended on this message.
3The @Param annotation tells the generator that the parameter should be used to construct the CloseException. The @Pos(1) annotation indicates the parameter should also be used when formatting the message.
4The @Producer annotation indicates that the Function should be used to create the exception being returned.
+
+
+ + + + + +
+ + +Message bundle interfaces can also contain valid message logger methods. +
+
+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/message-logger.html jboss-logging-tools-2.1.0/docs/message-logger.html --- jboss-logging-tools-2.0.2/docs/message-logger.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/message-logger.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,664 @@ + + + + + + + +Message Logger Interfaces + + + + + + + +
+
+

Message Logger Interfaces

+
+
+

Logger interfaces provide a way to internationalize log messages. A logger interface is an interface annotated with +@MessageLogger. Each method in must be annotated with @Message which will +be used to determine the message to be logged.

+
+
+

The value for a @Message may contain an expression.

+
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+

The following constraints are placed on methods in a message logger:

+
+
+
    +
  • +

    The method must have a void return type

    +
  • +
  • +

    The method must be annotated with @LogMessage

    +
  • +
  • +

    The method must be annotated with @Message or a message must be inheritable.

    +
  • +
  • +

    A method can have only one @Cause parameter.

    +
  • +
+
+
+ + + + + +
+ + +A message is inheritable if the two methods have the same name and same number of format parameters. +
+
+
+ + + + + +
+ + +A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; @FormatWith, @Pos or @Transform. +
+
+
+

A message logger interface may also extend the org.jboss.logging.BasicLogger. This allows the logging interface to be usable for standard logging. For example AppLogger.LOGGER.debugf("Initializing %s", this);

+
+
+

Example Message Logger

+
+
+
@MessageLogger(projectCode = "CW") (1)
+public interface AppLogger extends BasicLogger {
+
+    AppLogger LOGGER = Logger.getMessageLogger(AppLogger.class, AppLogger.class.getPackage().getName());
+
+    @LogMessage
+    @Once (2)
+    @Message("%s version %d.%d.%d.%s") (3)
+    void appVersion(CharSequence name, int major, int minor, int macro, String rel);
+
+    @LogMessage(level = Logger.Level.ERROR) (4)
+    @Message(id = 100, value = "Failure while closing %s")
+    void closeFailure(@Cause Throwable cause, Object obj);
+
+    @LogMessage(level = Logger.Level.WARN)
+    @Message(id = 101, value = "Encoding %s could not be found. Defaulting to %s.")
+    void encodingNotFound(String encoding, Charset dft);
+
+    @LogMessage
+    @Message(id = 102, value = "Cache size changed to '%d'")
+    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Collection<String> c);
+
+    @LogMessage
+    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) String... array);
+
+    @LogMessage
+    void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Map<String, Object> map);
+}
+
+
+
+ + + + + + + + + + + + + + + + + +
1The projectCode will be prepended to messages which have an id specified. For example with id = 100 the message will be prepended with CW000100. You can control the number padding with the length property on the annotation.
2Ensures the log message is only written once.
3No id is specified for this message which means no id will be prepended on this message.
4Overrides the default level to ERROR to indicate an error message should be logged.
+
+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/pom.xml jboss-logging-tools-2.1.0/docs/pom.xml --- jboss-logging-tools-2.0.2/docs/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/pom.xml 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,207 @@ + + + + + 4.0.0 + + + org.jboss.logging + jboss-logging-tools-parent + 2.1.0.Final + ../pom.xml + + + jboss-logging-tools-docs + jar + + JBoss Logging I18n Documentation + + + + Apache License, version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + 1.5.5 + apidocs + ${project.build.directory}/site/${java.docs.dir} + + + + + + org.jboss.logging + jboss-logging + provided + + + org.jboss.logging + jboss-logging-annotations + ${project.version} + provided + true + + + org.jboss.logging + jboss-logging-processor + ${project.version} + provided + true + + + + + + generate-site + + + generate-site + + + + + + maven-clean-plugin + + + + ${java.docs.dir}/ + + + examples/ + + + ${project.basedir} + + *.html + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + -Aorg.jboss.logging.tools.report.type=adoc + -Aorg.jboss.logging.tools.report.path=${project.reporting.outputDirectory}/adoc + -Aorg.jboss.logging.tools.report.title=Example Messages + + + + + maven-javadoc-plugin + + + create-javadoc + generate-resources + + javadoc + + + true + ${project.reporting.outputDirectory}/${java.docs.dir} + *.examples.* + true + + org.jboss.logging:jboss-logging-annotations:* + + true + + + + + + + maven-resources-plugin + + + copy-javadoc + process-resources + + copy-resources + + + ${project.basedir}/${java.docs.dir} + + + ${project.reporting.outputDirectory}/${java.docs.dir} + + + + + + + + org.asciidoctor + asciidoctor-maven-plugin + ${version.asciidoctor} + + html5 + coderay + + font + true + + + - + true + ${java.docs.dir} + ${project.version} + + ${project.version} + ${project.organization.name} + + ${project.basedir} + + + + output-html + generate-resources + + process-asciidoc + + + true + + + + output-report-html + process-classes + + process-asciidoc + + + ${project.reporting.outputDirectory}/adoc/ + ${project.basedir}/examples/ + + + + + + + + + diff -Nru jboss-logging-tools-2.0.2/docs/processor-options.html jboss-logging-tools-2.1.0/docs/processor-options.html --- jboss-logging-tools-2.0.2/docs/processor-options.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/processor-options.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,661 @@ + + + + + + + +Annotation Processor Options + + + + + + + +
+
+

Annotation Processor Options

+
+
+

You can pass options to an annotation processor with the -A compiler option. For example to disable generating the @Generated annotation from being placed on the generated source files you would pass -Aorg.jboss.logging.tools.addGeneratedAnnotation=false to the compiler command.

+
+
+

General

+ ++++ + + + + + + + + + + + + + + + + + + + + +
OptionDescription

debug

This option turns on debug logging for the processor

org.jboss.logging.tools.expressionProperties

This option allows you to define a path where, at compile-time, expressions in messages can be resolved.

org.jboss.logging.tools.addGeneratedAnnotation

If set to false the @Generated annotation will not be placed on the generated source files. The default is true.

+
+ + + + + +
+ + +In Java 9 the @javax.annotation.Generated was moved to @javax.annotation.processor.Generated. The processor attempts to determine which annotation to use by attempting to find the @javax.annotation.Generated first. If it fails the @javax.annotation.processor.Generated is attempted. If neither can be found no annotation will be placed on the generated implementations. +
+
+
+ + + + + +
+ + +Expressions are in the form of ${key:defaultValue}. If the key is prefixed with sys. a system property is +used. If the key is prefixed with env. an environment variable is used. In all other cases the properties are resolved +from the org.jboss.logging.tools.expressionProperties path. If the key is not found in the properties the default +value will be used. +
+
+
+ + + + + +
+ + +Expressions are processed at compile time. The values will be hard-coded in the generated source files. +
+
+
+
+

Translation Options

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + +
OptionDescription

translationsFilesPath

The base path for the translated properties files. This defaults to the location where new class files are placed.

skipTranslations

If set to true source files with the translated tet will not be generated. The default is false.

generatedTranslationFilesPath

If defined this indicates the path a skeleton file should be generated for the interface. The generated skeleton file will be placed in a directory that matches the package with a name that matches the interface with a .i18n_locale_COUNTRY_VARIANT.properties suffix.

org.jboss.logging.tools.level

Sets the maximum level to include in the generated skeleton files. For example if set to INFO the skeleton files will not contain any properties where the log level was set to DEBUG or TRACE.

+
+
+

Report Options

+ ++++ + + + + + + + + + + + + + + + + + + + + +
OptionDescription

org.jboss.logging.tools.report.type

Indicates the type of report that should be generated. The current report types are adoc for asciidoc or xml for XML.

org.jboss.logging.tools.report.path

The path where the generated reports should be placed. This defaults to the location where new class files are placed.

org.jboss.logging.tools.report.title

An optional title for the report. For asciidoc this defaults to Messages. For XML the <title> element is left off.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/reports.html jboss-logging-tools-2.1.0/docs/reports.html --- jboss-logging-tools-2.0.2/docs/reports.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/reports.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,586 @@ + + + + + + + +Reports + + + + + + + +
+
+

Reports

+
+
+

There are currently two types of reports that can be generated. The options are adoc or asciidoc for asciidoc and xml for XML.

+
+
+

The reports contain the following data:

+
+
+
    +
  • +

    The formatted message id.

    +
  • +
  • +

    A possible link to a resolution document for the error.

    +
  • +
  • +

    The unformatted message.

    +
  • +
  • +

    The log level, if applicable.

    +
  • +
  • +

    The return type, if applicable.

    +
  • +
+
+
+

Annotations

+
+

Two annotations can be used to assist withing linking resolution documents for messages.

+
+
+
    +
  • +

    @BaseUrl

    +
    +
      +
    • +

      This annotation can be used on a type to define the base URL for linking resolution documents. This annotation is +not required for links to be created on reports.

      +
    • +
    +
    +
  • +
  • +

    @ResolutionDoc

    +
    +
      +
    • +

      This annotation is used to define information about the resolution document for creating links. If placed on an +interface all methods that have a defined id will have a link generated. This can also be placed individually on +the method to only generate links for specific id’s.

      +
    • +
    +
    +
  • +
+
+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/default-notes.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/default-notes.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/default-notes.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/default-notes.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,3 @@ +NOTE: A message is inheritable if the two methods have the same name and same number of format parameters. + +NOTE: A format parameter is a parameter that has no annotations or is annotated with one of the following annotations; link:{javadocsdir}[`@FormatWith`], link:{javadocsdir}[`@Pos`] or link:{javadocsdir}[`@Transform`]. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/docinfo-footer.html jboss-logging-tools-2.1.0/docs/src/main/asciidoc/docinfo-footer.html --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/docinfo-footer.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/docinfo-footer.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,4 @@ + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples/errors/CW000003.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples/errors/CW000003.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples/errors/CW000003.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples/errors/CW000003.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,4 @@ +== CW000003: Null Parameter + +This error indicates you've passed a `null` parameter where a `non-null` value +is required. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples/errors/CW000100.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples/errors/CW000100.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples/errors/CW000100.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples/errors/CW000100.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,4 @@ +== CW000100: Close Failure + +This error indicates there was a failure closing a resource. Please see previous error messages and contact support if +required. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples/errors/CW000101.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples/errors/CW000101.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples/errors/CW000101.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples/errors/CW000101.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,4 @@ +== CW000101: Encoding Error + +This error indicates an invalid encoding is attempting to be used and a default encoding of UTF-8 will be used. You can +fix this by setting a valid encoding value. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/examples.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/examples.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,17 @@ + +:sourcedir: java/org/jboss/logging/tools/examples +:projecturl: https://github.com/jboss-logging/jboss-logging-tools/docs/src/main + +== Example Use Cases + +Below are some example use case snippets from the link:{projecturl}/{sourcedir}[examples]. + +[source,java,indent=0] +---- +include::../{sourcedir}/ContentWriter.java[tags=write;close] +---- +<1> Logs the application version. Note this uses the link:{javadocsdir}[@Once] annotation to indicate this should only be logged once regardless of which `write` method is used. +<2> The `ErrorMessages.nullParam()` returns a `java.lang.function.Supplier`. This allows the message to be lazily formatted only if the `value` is `null`. +<3> Throws a message if the `value` is an empty string. +<4> Uses a `java.lang.function.BiFunction` to create a new `UncheckedIOException` with the caught exception set as the cause. +<5> Logs the caught exception instead of throwing a new exception. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/expressions.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/expressions.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/expressions.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/expressions.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,7 @@ + +NOTE: Expressions are in the form of `${key:defaultValue}`. If the key is prefixed with `sys.` a system property is +used. If the key is prefixed with `env.` an environment variable is used. In all other cases the properties are resolved +from the `org.jboss.logging.tools.expressionProperties` path. If the key is not found in the properties the default +value will be used. + +IMPORTANT: Expressions are processed at compile time. The values will be hard-coded in the generated source files. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/getting-started.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/getting-started.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/getting-started.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/getting-started.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,47 @@ +:repourl: https://repository.jboss.org/org/jboss/logging + +== Getting Started + +To get started you need to include three dependencies in your project. + +[frame=none,grid=none,options="noheader"] +|=== +| link:{repourl}/jboss-logging/[JBoss Logging] | Required at compile time and runtime. +| link:{repourl}/jboss-logging-annotations/[JBoss Logging Annotations] | Required at compile time only. +| link:{repourl}/jboss-logging-processor/[JBoss Logging Processor] | Required at compile time only. +|=== + +If you're using maven here is an example `pom.xml` snippet: + +[source,xml,subs="attributes+"] +---- + + + + org.jboss.logging + jboss-logging + + + + org.jboss.logging + jboss-logging-annotations + {version} + + provided + true + + + + org.jboss.logging + jboss-logging-processor + {version} + + provided + true + + +---- + +Once your project is configured you can create either a <> or a <>. For detailed information see the link:{javadocsdir}/index.html[JavaDocs] for the annotations. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/index.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/index.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/index.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/index.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,24 @@ += JBoss Logging Tools +:Author: James R. Perkins +:Email: +:docinfo: shared +:toc: left +:scriptsdir: ./js + +== Introduction + +The JBoss logging tools are used to create internationalized log statements and exceptions. + +include::getting-started.adoc[] + +include::message-bundle.adoc[] + +include::message-logger.adoc[] + +include::reports.adoc[] + +include::examples.adoc[] + +include::translation-property-files.adoc[] + +include::processor-options.adoc[] \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/js/links.js jboss-logging-tools-2.1.0/docs/src/main/asciidoc/js/links.js --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/js/links.js 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/js/links.js 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,9 @@ +function annotationLinks() { + var links = document.getElementsByTagName("a"); + for(var i = 0, max = links.length; i < max; i++) { + var l = links[i]; + if (l.text.startsWith("@")) { + l.href = l.href + "/org/jboss/logging/annotations/" + l.text.substring(1) + ".html"; + } + } +} \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/message-bundle.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/message-bundle.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/message-bundle.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/message-bundle.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,58 @@ + +== Message Bundle Interfaces + +Message bundle interfaces provide a way to internationalize exceptions or strings. A message bundle interface is +annotated with link:{javadocsdir}[`@MessageBundle`]. Each method in must be annotated with link:{javadocsdir}[`@Message`] +which will be used to determine the String used for either the return type or the message for the exception being +returned. + +The value for a link:{javadocsdir}[`@Message`] may contain an expression. + +include::expressions.adoc[] + +The following constraints are placed on methods in a message bundle: + +- The return type must be one of the follow + * A `java.lang.String` + * A `java.lang.Throwable` or a subtype of `java.lang.Throwable` + * A `java.lang.function.Supplier` who's return type fits one of the other two constraints above. +- The method must be annotated with link:{javadocsdir}[`@Message`] or a message must be inheritable. +- A method can have only one link:{javadocsdir}[`@Cause`] parameter. +- A method can only have one link:{javadocsdir}[`@Producer`] parameter. + +include::default-notes.adoc[] + +=== Example Message Bundle + +[source,java] +---- +@MessageBundle(projectCode = "CW") <1> +public interface ErrorMessages { + ErrorMessages MESSAGES = Messages.getBundle(ErrorMessages.class); + + @Message("Version %d.%d.%d.%s") <2> + String version(int major, int minor, int macro, String rel); + + @Message(id = 1, value = "Value '%s' is invalid") + IllegalArgumentException invalidValue(Object value); + + @Message(id = 2, value = "Failure closing %s") <3> + CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c); + + CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c, @Suppressed Throwable... errors); + + @Message(id = 3, value = "Parameter %s cannot be null") + Supplier nullParam(String name); + + @Message(id = 4, value = "Operation %s failed.") + T operationFailed(@Producer Function fn, String name); <4> + + T operationFailed(@Producer BiFunction fn, @Cause IOException cause, String name); +} +---- +<1> The `projectCode` will be prepended to messages which have an `id` specified. For example with `id = 1` the message will be prepended with `CW000001`. You can control the number padding with the `length` property on the annotation. +<2> No `id` is specified for this message which means no id will be prepended on this message. +<3> The `@Param` annotation tells the generator that the parameter should be used to construct the `CloseException`. The `@Pos(1)` annotation indicates the parameter should also be used when formatting the message. +<4> The `@Producer` annotation indicates that the `Function` should be used to create the exception being returned. + +TIP: Message bundle interfaces can also contain valid <>. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/message-logger.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/message-logger.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/message-logger.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/message-logger.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,59 @@ + +== Message Logger Interfaces + +Logger interfaces provide a way to internationalize log messages. A logger interface is an interface annotated with +link:{javadocsdir}[`@MessageLogger`]. Each method in must be annotated with link:{javadocsdir}[`@Message`] which will +be used to determine the message to be logged. + +The value for a link:{javadocsdir}[`@Message`] may contain an expression. + +include::expressions.adoc[] + +The following constraints are placed on methods in a message logger: + +- The method must have a `void` return type +- The method must be annotated with link:{javadocsdir}[`@LogMessage`] +- The method must be annotated with link:{javadocsdir}[`@Message`] or a message must be inheritable. +- A method can have only one link:{javadocsdir}[`@Cause`] parameter. + +include::default-notes.adoc[] + +A message logger interface may also extend the `org.jboss.logging.BasicLogger`. This allows the logging interface to be usable for standard logging. For example `AppLogger.LOGGER.debugf("Initializing %s", this);` + +=== Example Message Logger + +[source,java] +---- +@MessageLogger(projectCode = "CW") <1> +public interface AppLogger extends BasicLogger { + + AppLogger LOGGER = Logger.getMessageLogger(AppLogger.class, AppLogger.class.getPackage().getName()); + + @LogMessage + @Once <2> + @Message("%s version %d.%d.%d.%s") <3> + void appVersion(CharSequence name, int major, int minor, int macro, String rel); + + @LogMessage(level = Logger.Level.ERROR) <4> + @Message(id = 100, value = "Failure while closing %s") + void closeFailure(@Cause Throwable cause, Object obj); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 101, value = "Encoding %s could not be found. Defaulting to %s.") + void encodingNotFound(String encoding, Charset dft); + + @LogMessage + @Message(id = 102, value = "Cache size changed to '%d'") + void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Collection c); + + @LogMessage + void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) String... array); + + @LogMessage + void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Map map); +} +---- +<1> The `projectCode` will be prepended to messages which have an `id` specified. For example with `id = 100` the message will be prepended with `CW000100`. You can control the number padding with the `length` property on the annotation. +<2> Ensures the log message is only written once. +<3> No `id` is specified for this message which means no id will be prepended on this message. +<4> Overrides the default level to `ERROR` to indicate an error message should be logged. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/processor-options.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/processor-options.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/processor-options.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/processor-options.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,44 @@ + +== Annotation Processor Options + +You can pass options to an annotation processor with the `-A` compiler option. For example to disable generating the `@Generated` annotation from being placed on the generated source files you would pass `-Aorg.jboss.logging.tools.addGeneratedAnnotation=false` to the compiler command. + +=== General + +[frame=none,grid=none] +|=== +| Option | Description + +| `debug` | This option turns on debug logging for the processor +| `org.jboss.logging.tools.expressionProperties` | This option allows you to define a path where, at compile-time, expressions in messages can be resolved. +| `org.jboss.logging.tools.addGeneratedAnnotation` | If set to `false` the `@Generated` annotation will not be placed on the generated source files. The default is `true`. +|=== + +NOTE: In Java 9 the `@javax.annotation.Generated` was moved to `@javax.annotation.processor.Generated`. The processor attempts to determine which annotation to use by attempting to find the `@javax.annotation.Generated` first. If it fails the `@javax.annotation.processor.Generated` is attempted. If neither can be found no annotation will be placed on the generated implementations. + +include::expressions.adoc[] + +=== Translation Options + +[frame=none,grid=none] +|=== +| Option | Description + +| `translationsFilesPath` | The base path for the translated properties files. This defaults to the location where new class files are placed. +| `skipTranslations` | If set to `true` source files with the translated tet will not be generated. The default is `false`. +| `generatedTranslationFilesPath` | If defined this indicates the path a skeleton file should be generated for the interface. The generated skeleton file will be placed in a directory that matches the package with a name that matches the interface with a `.i18n_locale_COUNTRY_VARIANT.properties` suffix. +| `org.jboss.logging.tools.level` | Sets the maximum level to include in the generated skeleton files. For example if set to `INFO` the skeleton files will not contain any properties where the log level was set to `DEBUG` or `TRACE`. + +|=== + +=== Report Options + +[frame=none,grid=none] +|=== +| Option | Description + +| `org.jboss.logging.tools.report.type` | Indicates the type of report that should be generated. The current report types are `adoc` for asciidoc or `xml` for XML. +| `org.jboss.logging.tools.report.path` | The path where the generated reports should be placed. This defaults to the location where new class files are placed. +| `org.jboss.logging.tools.report.title` | An optional title for the report. For asciidoc this defaults to `Messages`. For XML the `` element is left off. + +|=== \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/reports.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/reports.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/reports.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/reports.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,24 @@ + +== Reports + +There are currently two types of reports that can be generated. The options are `adoc` or `asciidoc` for asciidoc and `xml` for XML. + +The reports contain the following data: + +* The formatted message id. +* A possible link to a resolution document for the error. +* The unformatted message. +* The log level, if applicable. +* The return type, if applicable. + +=== Annotations + +Two annotations can be used to assist withing linking resolution documents for messages. + +* link:{javadocsdir}[`@BaseUrl`] + - This annotation can be used on a type to define the base URL for linking resolution documents. This annotation is + not required for links to be created on reports. +* link:{javadocsdir}[`@ResolutionDoc`] + - This annotation is used to define information about the resolution document for creating links. If placed on an + interface all methods that have a defined id will have a link generated. This can also be placed individually on + the method to only generate links for specific id's. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/asciidoc/translation-property-files.adoc jboss-logging-tools-2.1.0/docs/src/main/asciidoc/translation-property-files.adoc --- jboss-logging-tools-2.0.2/docs/src/main/asciidoc/translation-property-files.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/asciidoc/translation-property-files.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,4 @@ + +== Translation Property Files + +The translation properties files must exist in the same directory structure as the interface. The name of the properties file `InterfaceName.i18n_language_country_variant.properties`. For example if you have a class named `org.jboss.logging.tools.examples.ErrorMessages` and you want to translate this into French you create a properties file called `ErrorMessages.i18n_fr.properties` in a directory `org/jboss/logging/tools/examples`. \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/AppLogger.java jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/AppLogger.java --- jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/AppLogger.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/AppLogger.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,109 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.tools.examples; + +import java.nio.charset.Charset; +import java.util.Collection; +import java.util.Map; + +import org.jboss.logging.BasicLogger; +import org.jboss.logging.Logger; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.Once; +import org.jboss.logging.annotations.ResolutionDoc; +import org.jboss.logging.annotations.Transform; + +/** + * A common logger for the application. + * + * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> + */ +@SuppressWarnings({"unused", "SameParameterValue"}) +@MessageLogger(projectCode = "CW") +@ResolutionDoc(url = "errors", suffix = ".html") +public interface AppLogger extends BasicLogger { + + AppLogger LOGGER = Logger.getMessageLogger(AppLogger.class, AppLogger.class.getPackage().getName()); + + /** + * Logs an informational message, once, indicating the applications version. + * + * @param name the name of the application + * @param major the major version + * @param minor the minor version + * @param macro the macro version + * @param rel the release suffix, e.g. {@code Beta1}, {@code Final} + */ + @LogMessage + @Once + @Message("%s version %d.%d.%d.%s") + void appVersion(CharSequence name, int major, int minor, int macro, String rel); + + /** + * Logs an error message indicating a failure to close the object. + * + * @param cause the cause of the error + * @param obj the object that failed closing + */ + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 100, value = "Failure while closing %s") + void closeFailure(@Cause Throwable cause, Object obj); + + /** + * Logs a warning message indicating the encoding is invalid and a default encoding will be used. + * + * @param encoding the invalid encoding + * @param dft the default encoding + */ + @LogMessage(level = Logger.Level.WARN) + @Message(id = 101, value = "Encoding %s could not be found. Defaulting to %s.") + void encodingNotFound(String encoding, Charset dft); + + /** + * Logs an informational message indicating the cache size has changed and the size the cache is now. + * + * @param c the collection holding the cache + */ + @LogMessage + @Message(id = 102, value = "Cache size changed to '%d'") + @ResolutionDoc(skip = true) + void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Collection<String> c); + + /** + * Logs an informational message indicating the cache size has changed and the size the cache is now. + * + * @param array the cache arracy + */ + @LogMessage + @ResolutionDoc(skip = true) + void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) String... array); + + /** + * Logs an informational message indicating the cache size has changed and the size the cache is now. + * + * @param map the map holding the cache + */ + @LogMessage + @ResolutionDoc(skip = true) + void cacheSizeChanged(@Transform(Transform.TransformType.SIZE) Map<String, Object> map); +} diff -Nru jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/CloseException.java jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/CloseException.java --- jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/CloseException.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/CloseException.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.tools.examples; + +import java.io.Closeable; + +/** + * An error with access to the failing {@link Closeable}. + * + * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> + */ +@SuppressWarnings("unused") +public class CloseException extends RuntimeException { + private final Closeable closeable; + + /** + * Creates a new error. + * + * @param msg the message for the error + * @param closeable the failed closeable + */ + public CloseException(final String msg, final Closeable closeable) { + super(msg); + this.closeable = closeable; + } + + /** + * Creates a new error. + * + * @param msg the message for the error + * @param cause the cause of the error + * @param closeable the failed closeable + */ + public CloseException(final String msg, final Throwable cause, final Closeable closeable) { + super(msg, cause); + this.closeable = closeable; + } + + /** + * Returns the failed closeable. + * + * @return the failed closeable + */ + public Closeable getCloseable() { + return closeable; + } +} diff -Nru jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriterBuilder.java jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriterBuilder.java --- jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriterBuilder.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriterBuilder.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,113 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.tools.examples; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.charset.UnsupportedCharsetException; +import java.nio.file.Files; +import java.nio.file.OpenOption; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.Objects; + +/** + * Builds a {@link ContentWriter}. + * + * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> + */ +@SuppressWarnings("unused") +public class ContentWriterBuilder { + private final Path path; + private boolean append = true; + private String encoding = null; + + + private ContentWriterBuilder(final Path path) { + this.path = path; + } + + /** + * Creates a new builder. + * + * @param path the path where the content should be written to, cannot be {@code null} + * + * @return the new content writer + */ + public static ContentWriterBuilder of(final Path path) { + Objects.requireNonNull(path, ErrorMessages.MESSAGES.nullParam("path")); + return new ContentWriterBuilder(path); + } + + /** + * Set the encoding of for the content. If the encoding is not a valid {@link Charset} a default encoding of + * {@link StandardCharsets#UTF_8} will be used. + * + * @param encoding the encoding to use + * + * @return this builder + */ + public ContentWriterBuilder setEncoding(final String encoding) { + this.encoding = encoding; + return this; + } + + /** + * Indicates whether or not the content should be appended to any previous content already written. The default + * value is {@link true}. + * + * @param append {@code false} if the created writer should overwrite previously written content, otherwise + * {@code true} + * + * @return this builder + */ + public ContentWriterBuilder setAppend(final boolean append) { + this.append = append; + return this; + } + + /** + * Creates the {@link ContentWriter}. + * + * @return the created writer + * + * @throws IOException if a failure creating the writer occurs + */ + public ContentWriter build() throws IOException { + final OpenOption[] options; + if (append) { + options = new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.APPEND}; + } else { + options = new OpenOption[] {StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING}; + } + Charset charset = StandardCharsets.UTF_8; + if (encoding != null) { + try { + charset = Charset.forName(encoding); + } catch (UnsupportedCharsetException e) { + AppLogger.LOGGER.encodingNotFound(encoding, charset); + } + } + final BufferedWriter writer = Files.newBufferedWriter(path, charset, options); + return new ContentWriter(path, writer); + } +} diff -Nru jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriter.java jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriter.java --- jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/ContentWriter.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,164 @@ +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.tools.examples; + +import java.io.BufferedWriter; +import java.io.Closeable; +import java.io.Flushable; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Path; +import java.util.Objects; + +/** + * A writer for writing content to a file. + * + * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> + */ +@SuppressWarnings({"unused", "WeakerAccess"}) +public class ContentWriter implements Closeable, Flushable { + + private final Object outputLock = new Object(); + + private final Path contentPath; + private final BufferedWriter writer; + private volatile boolean autoFlush = true; + + ContentWriter(final Path contentPath, final BufferedWriter writer) { + this.contentPath = Objects.requireNonNull(contentPath, ErrorMessages.MESSAGES.nullParam("contentPath")); + this.writer = Objects.requireNonNull(writer, ErrorMessages.MESSAGES.nullParam("writer")); + } + + // tag::write[] + + /** + * Writes the value of the object to the file. + * + * @param value the value to write, cannot be {@code null} + * + * @throws UncheckedIOException if an error occurs writing the data + */ + public void write(final Object value) { + AppLogger.LOGGER.appVersion("ContentWriter", 1, 0, 0, "Beta1"); // <1> + Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")); // <2> + write(Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")).toString()); + } + + /** + * Writes the value to the file. + * + * @param value the value to write, cannot be {@code null} or an {@linkplain String#isEmpty() empty string}. + * + * @throws UncheckedIOException if an error occurs writing the data + */ + public void write(final String value) { + AppLogger.LOGGER.appVersion("ContentWriter", 1, 0, 0, "Beta1"); + if (Objects.requireNonNull(value, ErrorMessages.MESSAGES.nullParam("value")).isEmpty()) { + throw ErrorMessages.MESSAGES.invalidValue(value); // <3> + } + try { + synchronized (outputLock) { + writer.write(value); + writer.newLine(); + if (autoFlush) { + flush(); + } + } + } catch (IOException e) { + throw ErrorMessages.MESSAGES.operationFailed(UncheckedIOException::new, e, "write"); // <4> + } + } + // end::write[] + + /** + * Set the value to {@code false} if the buffer should not automatically {@linkplain #flush() flush} on each write. + * <p> + * Defaults to {@code true}. + * </p> + * + * @param autoFlush {@code true} to {@linkplain #flush() flush} on each write, otherwise {@code false} to flush + * when the buffer determines it should be flushed + */ + public void setAutoFlush(final boolean autoFlush) { + this.autoFlush = autoFlush; + } + + // tag::close[] + + @Override + public void close() { + try { + synchronized (outputLock) { + writer.close(); + } + AppLogger.LOGGER.tracef("ContentWriter %s was successfully closed.", this); + } catch (Exception e) { + throw ErrorMessages.MESSAGES.closeFailure(e, this); + } + } + + /** + * Safely close this writer logging any errors that occur during closing. + */ + public void safeClose() { + try { + synchronized (outputLock) { + writer.close(); + } + AppLogger.LOGGER.tracef("ContentWriter %s was successfully closed.", this); + } catch (Exception e) { + AppLogger.LOGGER.closeFailure(e, this); // <5> + } + } + // end::close[] + + @Override + public void flush() { + try { + synchronized (outputLock) { + writer.flush(); + } + } catch (IOException e) { + throw ErrorMessages.MESSAGES.operationFailed(UncheckedIOException::new, e, "flush"); + } + } + + @Override + public int hashCode() { + return Objects.hash(contentPath); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof ContentWriter)) { + return false; + } + final ContentWriter other = (ContentWriter) obj; + return Objects.equals(contentPath, other.contentPath); + } + + @Override + public String toString() { + return "ContentWriter[" + contentPath.toAbsolutePath() + "]"; + } +} diff -Nru jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/ErrorMessages.java jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/ErrorMessages.java --- jboss-logging-tools-2.0.2/docs/src/main/java/org/jboss/logging/tools/examples/ErrorMessages.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/src/main/java/org/jboss/logging/tools/examples/ErrorMessages.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,145 @@ + +/* + * JBoss, Home of Professional Open Source. + * + * Copyright 2017 Red Hat, Inc., and individual contributors + * as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jboss.logging.tools.examples; + +import java.io.Closeable; +import java.io.IOException; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + +import org.jboss.logging.Messages; +import org.jboss.logging.annotations.BaseUrl; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.Param; +import org.jboss.logging.annotations.Pos; +import org.jboss.logging.annotations.Producer; +import org.jboss.logging.annotations.ResolutionDoc; +import org.jboss.logging.annotations.Suppressed; + +/** + * Common error messages for the application. + * + * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> + */ +@SuppressWarnings("unused") +@MessageBundle(projectCode = "CW") +@BaseUrl("errors/") +public interface ErrorMessages { + /** + * The static message instance. + */ + ErrorMessages MESSAGES = Messages.getBundle(ErrorMessages.class); + + /** + * Returns the internationalized version message. + * + * @param major the major version + * @param minor the minor version + * @param macro the macro version + * @param rel the release suffix, e.g. {@code Beta1}, {@code Final} + * + * @return the formatted version + */ + @Message("Version %d.%d.%d.%s") + String version(int major, int minor, int macro, String rel); + + /** + * Creates an exception indicating the value is invalid. + * + * @param value the invalid value + * + * @return an {@link IllegalStateException} for the error + */ + @Message(id = 1, value = "Value '%s' is invalid") + IllegalArgumentException invalidValue(Object value); + + /** + * Creates an exception indicating a failure to close the {@link Closeable} + * + * @param cause the cause of the error + * @param c the closeable that failed + * + * @return a {@link CloseException} for the error + */ + @Message(id = 2, value = "Failure closing %s") + CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c); + + /** + * Creates an exception indicating a failure to close the {@link Closeable} + * + * @param cause the cause of the error + * @param c the closeable that failed + * @param errors errors that should be added as {@linkplain Throwable#getSuppressed() suppressed exceptions}. + * + * @return a {@link CloseException} for the error + */ + CloseException closeFailure(@Cause Throwable cause, @Param @Pos(1) Closeable c, @Suppressed Throwable... errors); + + /** + * Creates a message indicating the parameter is {@code null}. + * <p> + * This can be used to lazily format the message for {@code null} checks like + * {@link java.util.Objects#requireNonNull(Object, Supplier)}. + * </p> + * + * @param name the name of the parameter + * + * @return a supplier for the message + */ + @Message(id = 3, value = "Parameter %s cannot be null") + @ResolutionDoc(suffix = ".html") + Supplier<String> nullParam(String name); + + /** + * Uses the producer function to create the returned exception indicating the operation has failed. + * <p> + * The formatted value of the message will be the parameter for the functions + * {@linkplain Function#apply(Object) apply} method. + * </p> + * + * @param fn the function to produce the returned exception + * @param name the name of the operation that failed + * @param <T> the type of the exception to return, must be assignable to a {@link RuntimeException} + * + * @return the produced exception for the error + */ + @Message(id = 4, value = "Operation %s failed.") + <T extends RuntimeException> T operationFailed(@Producer Function<String, T> fn, String name); + + /** + * Uses the producer function to create the returned exception indicating the operation has failed. + * <p> + * The formatted value of the message will be the first parameter for the functions + * {@linkplain BiFunction#apply(Object, Object)} apply} method. The second parameter will be the cause. + * </p> + * + * @param fn the function to produce the returned exception + * @param cause the cause of the exception to pass to the function + * @param name the name of the operation that failed + * @param <T> the type of the exception to return, must be assignable to a {@link RuntimeException} + * + * @return the produced exception for the error + */ + <T extends RuntimeException> T operationFailed(@Producer BiFunction<String, IOException, T> fn, @Cause IOException cause, String name); +} diff -Nru jboss-logging-tools-2.0.2/docs/translation-property-files.html jboss-logging-tools-2.1.0/docs/translation-property-files.html --- jboss-logging-tools-2.0.2/docs/translation-property-files.html 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/docs/translation-property-files.html 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,531 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="UTF-8"> +<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<meta name="generator" content="Asciidoctor 1.5.5"> +<title>Translation Property Files + + + + + + + +
+
+

Translation Property Files

+
+
+

The translation properties files must exist in the same directory structure as the interface. The name of the properties file InterfaceName.i18n_language_country_variant.properties. For example if you have a class named org.jboss.logging.tools.examples.ErrorMessages and you want to translate this into French you create a properties file called ErrorMessages.i18n_fr.properties in a directory org/jboss/logging/tools/examples.

+
+
+
+
+ + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/pom.xml jboss-logging-tools-2.1.0/pom.xml --- jboss-logging-tools-2.0.2/pom.xml 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/pom.xml 2017-08-09 18:02:31.000000000 +0000 @@ -28,12 +28,12 @@ org.jboss jboss-parent - 14 + 20 org.jboss.logging jboss-logging-tools-parent - 2.0.2.Final + 2.1.0.Final pom JBoss Logging Tools Parent @@ -49,13 +49,19 @@ + + scm:git:git@github.com:jboss-logging/jboss-logging-tools.git + scm:git:git@github.com:jboss-logging/jboss-logging-tools.git + http://github.com/jboss-logging/jboss-logging-tools + + UTF-8 2.0.2.Final 3.1.2.GA - 1.3.2.Final + 2.0.3.Final 2.19.2.Final - 6.3.1 + 4.12 @@ -104,16 +110,37 @@ - org.testng - testng - ${version.org.testng} + junit + junit + ${version.junit} + test + + + + + maven-javadoc-plugin + + + http://docs.oracle.com/javase/8/docs/api + + public +
JBoss Logging Tools, ${project.version}
+
JBoss Logging Tools, ${project.version}
+ JBoss Logging Tools, ${project.version} +
+
+
+
+
+ annotations processor processor-tests + docs diff -Nru jboss-logging-tools-2.0.2/processor/pom.xml jboss-logging-tools-2.1.0/processor/pom.xml --- jboss-logging-tools-2.0.2/processor/pom.xml 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/pom.xml 2017-08-09 18:02:31.000000000 +0000 @@ -1,5 +1,4 @@ - + + test-compile-adoc + test-compile + + testCompile + + + + -Aorg.jboss.logging.tools.report.type=adoc + -Aorg.jboss.logging.tools.report.path=${test.report.path} + -Aorg.jboss.logging.tools.report.title=Test Title + -Aorg.jboss.logging.tools.expressionProperties=${expression.properties.path} + + + + + + test-compile-xml + test-compile + + testCompile + + + + -Aorg.jboss.logging.tools.report.type=xml + -Aorg.jboss.logging.tools.report.path=${test.report.path} + -Aorg.jboss.logging.tools.report.title=Test Title + -Aorg.jboss.logging.tools.expressionProperties=${expression.properties.path} + + + org.apache.maven.plugins maven-surefire-plugin + + envValue + org.jboss.logmanager.LogManager ${project.build.testSourceDirectory} ${project.build.directory}/generated-test-sources/test-annotations + ${test.report.path} + sysValue + ${expression.properties.path} - \ No newline at end of file + diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/AbstractClassType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/AbstractClassType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/AbstractClassType.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/AbstractClassType.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; + +import org.jboss.logging.processor.model.ClassType; +import org.jboss.logging.processor.util.ElementHelper; + +/** + * @author James R. Perkins + */ +abstract class AbstractClassType implements ClassType { + protected final ProcessingEnvironment processingEnv; + protected final Elements elements; + protected final Types types; + protected final TypeMirror typeMirror; + + AbstractClassType(final ProcessingEnvironment processingEnv, final TypeMirror typeMirror) { + this.processingEnv = processingEnv; + this.elements = processingEnv.getElementUtils(); + this.types = processingEnv.getTypeUtils(); + this.typeMirror = typeMirror; + } + + AbstractClassType(final ProcessingEnvironment processingEnv, final Element element) { + this.processingEnv = processingEnv; + this.elements = processingEnv.getElementUtils(); + this.types = processingEnv.getTypeUtils(); + this.typeMirror = element.asType(); + } + + @Override + public final boolean isAssignableFrom(final Class type) { + return types.isAssignable(types.erasure(toType(type)), types.erasure(this.typeMirror)); + } + + @Override + public final boolean isSubtypeOf(final Class type) { + return types.isSubtype(types.erasure(this.typeMirror), toType(type)); + } + + @Override + public final boolean isSameAs(final Class type) { + return types.isSameType(types.erasure(this.typeMirror), toType(type)); + } + + /** + * Creates a {@link TypeMirror} from a class type. + * + * @param type the type to create the {@link TypeMirror} for + * + * @return the {@code TypeMirror} to represent the type + */ + private TypeMirror toType(final Class type) { + return types.erasure(ElementHelper.toType(elements, type)); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/AbstractGenerator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/AbstractGenerator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/AbstractGenerator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/AbstractGenerator.java 2017-08-09 18:02:31.000000000 +0000 @@ -21,17 +21,28 @@ */ package org.jboss.logging.processor.apt; +import java.io.Writer; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; import javax.annotation.processing.Filer; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.SupportedOptions; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import javax.lang.model.util.Types; +import org.jboss.logging.processor.model.DelegatingElement; +import org.jboss.logging.processor.model.DelegatingTypeElement; import org.jboss.logging.processor.model.MessageInterface; /** @@ -44,7 +55,7 @@ private final ToolLogger logger; - private final ProcessingEnvironment processingEnv; + final ProcessingEnvironment processingEnv; /** * Constructs a new processor. @@ -76,42 +87,6 @@ } /** - * Returns the filer. - * - * @return the filer - */ - final Filer filer() { - return processingEnv.getFiler(); - } - - /** - * Returns the element utils. - * - * @return the utils - */ - final Elements elementUtils() { - return processingEnv.getElementUtils(); - } - - /** - * Returns the type utils. - * - * @return the utils - */ - public final Types typeUtils() { - return processingEnv.getTypeUtils(); - } - - /** - * Returns the processing environment. - * - * @return the processing environment being used. - */ - public final ProcessingEnvironment processingEnv() { - return processingEnv; - } - - /** * Returns the name of the processor. * * @return the name of the processor. @@ -128,7 +103,7 @@ public final Set getSupportedOptions() { SupportedOptions options = this.getClass().getAnnotation(SupportedOptions.class); if (options != null) { - return new HashSet(Arrays.asList(options.value())); + return new HashSet<>(Arrays.asList(options.value())); } return Collections.emptySet(); diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/AbstractMessageObjectType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/AbstractMessageObjectType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/AbstractMessageObjectType.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/AbstractMessageObjectType.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.logging.processor.apt; - -import static org.jboss.logging.processor.util.ElementHelper.typeToString; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import javax.lang.model.element.Element; -import javax.lang.model.element.TypeParameterElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; -import javax.lang.model.type.WildcardType; -import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; - -import org.jboss.logging.processor.model.MessageObjectType; - -/** - * @author James R. Perkins - */ -abstract class AbstractMessageObjectType implements MessageObjectType { - protected final Elements elements; - protected final Types types; - protected final TypeMirror typeMirror; - - protected AbstractMessageObjectType(final Elements elements, final Types types, final TypeMirror typeMirror) { - this.elements = elements; - this.types = types; - this.typeMirror = typeMirror; - } - - protected AbstractMessageObjectType(final Elements elements, final Types types, final Element element) { - this.elements = elements; - this.types = types; - this.typeMirror = element.asType(); - } - - @Override - public String type() { - return name(); - } - - @Override - public final boolean isAssignableFrom(final Class type) { - final TypeMirror typeMirror = elements.getTypeElement(typeToString(type)).asType(); - return types.isAssignable(types.erasure(typeMirror), types.erasure(this.typeMirror)); - } - - @Override - public final boolean isSubtypeOf(final Class type) { - final TypeMirror typeMirror = elements.getTypeElement(typeToString(type)).asType(); - return types.isSubtype(types.erasure(this.typeMirror), types.erasure(typeMirror)); - } - - @Override - public final boolean isSameAs(final Class type) { - return type().equals(typeToString(type)); - } -} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ImplementationClassGenerator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ImplementationClassGenerator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ImplementationClassGenerator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ImplementationClassGenerator.java 2017-08-09 18:02:31.000000000 +0000 @@ -60,7 +60,7 @@ @Override public void processTypeElement(final TypeElement annotation, final TypeElement element, final MessageInterface messageInterface) { try { - final ClassModel classModel = ClassModelFactory.implementation(filer(), messageInterface, useLogging31); + final ClassModel classModel = ClassModelFactory.implementation(processingEnv, messageInterface, useLogging31); classModel.generateAndWrite(); } catch (IllegalStateException | IOException e) { logger().error(element, e); diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/LoggingToolsProcessor.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/LoggingToolsProcessor.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/LoggingToolsProcessor.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/LoggingToolsProcessor.java 2017-08-09 18:02:31.000000000 +0000 @@ -24,23 +24,35 @@ import static javax.lang.model.util.ElementFilter.typesIn; +import java.io.BufferedReader; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Properties; import java.util.Set; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedOptions; import javax.lang.model.SourceVersion; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.ConstructType; import org.jboss.logging.annotations.Field; import org.jboss.logging.annotations.FormatWith; import org.jboss.logging.annotations.LogMessage; @@ -48,14 +60,16 @@ import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.Once; import org.jboss.logging.annotations.Param; import org.jboss.logging.annotations.Pos; import org.jboss.logging.annotations.Property; +import org.jboss.logging.annotations.Signature; import org.jboss.logging.annotations.Transform; import org.jboss.logging.annotations.ValidIdRange; import org.jboss.logging.annotations.ValidIdRanges; +import org.jboss.logging.processor.model.DelegatingElement; import org.jboss.logging.processor.model.MessageInterface; -import org.jboss.logging.processor.util.ElementHelper; import org.jboss.logging.processor.validation.ValidationMessage; import org.jboss.logging.processor.validation.Validator; @@ -66,11 +80,15 @@ * @author Kevin Pollet - SERLI - (kevin.pollet@serli.com) */ @SupportedOptions({ - LoggingToolsProcessor.DEBUG_OPTION + LoggingToolsProcessor.DEBUG_OPTION, + LoggingToolsProcessor.EXPRESSION_PROPERTIES, + LoggingToolsProcessor.ADD_GENERATED_ANNOTATION, }) public class LoggingToolsProcessor extends AbstractProcessor { public static final String DEBUG_OPTION = "debug"; + static final String EXPRESSION_PROPERTIES = "org.jboss.logging.tools.expressionProperties"; + static final String ADD_GENERATED_ANNOTATION = "org.jboss.logging.tools.addGeneratedAnnotation"; private final List interfaceAnnotations = Arrays.asList(MessageBundle.class.getName(), MessageLogger.class.getName()); private final List generators; private final Set supportedAnnotations; @@ -81,28 +99,30 @@ */ public LoggingToolsProcessor() { this.generators = new ArrayList<>(); - final Set annotations = new HashSet<>(); - // Interface annotations - annotations.addAll(interfaceAnnotations); - // Other annotations - annotations.add(Cause.class.getName()); - annotations.add(Field.class.getName()); - annotations.add(FormatWith.class.getName()); - annotations.add(LoggingClass.class.getName()); - annotations.add(LogMessage.class.getName()); - annotations.add(Message.class.getName()); - annotations.add(Param.class.getName()); - annotations.add(Pos.class.getName()); - annotations.add(Property.class.getName()); - annotations.add(Transform.class.getName()); - annotations.add(ValidIdRange.class.getName()); - annotations.add(ValidIdRanges.class.getName()); - this.supportedAnnotations = Collections.unmodifiableSet(annotations); + this.supportedAnnotations = createSupportedAnnotations( + Cause.class, + ConstructType.class, + Field.class, + FormatWith.class, + LoggingClass.class, + LogMessage.class, + Message.class, + MessageBundle.class, + MessageLogger.class, + Once.class, + Param.class, + Pos.class, + Property.class, + Signature.class, + Transform.class, + ValidIdRange.class, + ValidIdRanges.class + ); } @Override public Set getSupportedOptions() { - Set supportedOptions = new HashSet(); + Set supportedOptions = new HashSet<>(); //Add global options SupportedOptions globalOptions = this.getClass().getAnnotation(SupportedOptions.class); @@ -138,12 +158,37 @@ generators.add(new ImplementationClassGenerator(processingEnv)); generators.add(new TranslationClassGenerator(processingEnv)); generators.add(new TranslationFileGenerator(processingEnv)); + generators.add(new ReportFileGenerator(processingEnv)); } @Override public boolean process(final Set annotations, final RoundEnvironment roundEnv) { - boolean process = true; - final Validator validator = new Validator(); + if (!roundEnv.processingOver() && !annotations.isEmpty()) { + doProcess(annotations, roundEnv); + } + return true; + } + + private void doProcess(final Set annotations, final RoundEnvironment roundEnv) { + final String propertiesPath = processingEnv.getOptions().getOrDefault(EXPRESSION_PROPERTIES, ""); + final Properties expressionProperties = new Properties(); + if (!propertiesPath.isEmpty()) { + final Path path = Paths.get(propertiesPath); + if (Files.notExists(path)) { + logger.error("Expression properties file %s does not exist.", propertiesPath); + return; + } else { + try (final BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { + expressionProperties.load(reader); + } catch (IOException e) { + logger.error(e, "Error reading expression properties file %s", propertiesPath); + return; + } + } + } + final boolean addGeneratedAnnotation = Boolean.parseBoolean(processingEnv.getOptions().getOrDefault(ADD_GENERATED_ANNOTATION, "true")); + boolean generate = true; + final Validator validator = new Validator(processingEnv); //Call jboss logging tools for (TypeElement annotation : annotations) { @@ -153,26 +198,14 @@ final Set interfaces = typesIn(roundEnv.getElementsAnnotatedWith(annotation)); for (TypeElement interfaceElement : interfaces) { try { - final MessageInterface messageInterface = MessageInterfaceFactory.of(processingEnv, interfaceElement); + final MessageInterface messageInterface = MessageInterfaceFactory.of(processingEnv, interfaceElement, expressionProperties, addGeneratedAnnotation); final Collection validationMessages = validator.validate(messageInterface); for (ValidationMessage message : validationMessages) { - final Element element = ElementHelper.fromMessageObject(message.getMessageObject()); - switch (message.type()) { - case ERROR: { - logger.error(element, message.getMessage()); - process = false; - break; - } - case WARN: { - logger.warn(element, message.getMessage()); - break; - } - default: { - logger.note(element, message.getMessage()); - } + if (message.printMessage(processingEnv.getMessager())) { + generate = false; } } - if (process) { + if (generate) { if (interfaceElement.getKind().isInterface() && !interfaceElement.getModifiers().contains(Modifier.PRIVATE)) { for (AbstractGenerator processor : generators) { @@ -182,7 +215,16 @@ } } } catch (ProcessingException e) { - logger.error(e.getElement(), e.getMessage()); + final AnnotationMirror a = e.getAnnotation(); + final AnnotationValue value = e.getAnnotationValue(); + final Element element = resolveElement(e.getElement()); + if (a == null) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), element); + } else if (value == null) { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), element, a); + } else { + processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage(), element, a, value); + } } } } catch (Throwable t) { @@ -190,6 +232,21 @@ } } } - return process; + } + + @SafeVarargs + private static Set createSupportedAnnotations(final Class... annotations) { + final Set supportedAnnotations = new HashSet<>(annotations.length); + for (Class c : annotations) { + supportedAnnotations.add(c.getName()); + } + return Collections.unmodifiableSet(supportedAnnotations); + } + + private static Element resolveElement(final Element element) { + if (element instanceof DelegatingElement) { + return ((DelegatingElement) element).getDelegate(); + } + return element; } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/MessageInterfaceFactory.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/MessageInterfaceFactory.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/MessageInterfaceFactory.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/MessageInterfaceFactory.java 2017-08-09 18:02:31.000000000 +0000 @@ -26,20 +26,22 @@ import static org.jboss.logging.processor.util.Objects.ToStringBuilder; import static org.jboss.logging.processor.util.Objects.areEqual; -import java.lang.annotation.Annotation; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; +import java.util.Objects; +import java.util.Properties; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.Elements; import javax.lang.model.util.Types; import org.jboss.logging.BasicLogger; @@ -70,31 +72,33 @@ * Creates a message interface from the {@link javax.lang.model.element.TypeElement} specified by the {@code * interfaceElement} parameter. * - * @param processingEnvironment the annotation processing environment. - * @param interfaceElement the interface element to parse. + * @param processingEnv the annotation processing environment. + * @param interfaceElement the interface element to parse. + * @param expressionProperties the properties used to resolve expressions * * @return a message interface for the interface element. */ - public static MessageInterface of(final ProcessingEnvironment processingEnvironment, final TypeElement interfaceElement) { - final Types types = processingEnvironment.getTypeUtils(); - final Elements elements = processingEnvironment.getElementUtils(); - if (types.isSameType(interfaceElement.asType(), elements.getTypeElement(BasicLogger.class.getName()).asType())) { + public static MessageInterface of(final ProcessingEnvironment processingEnv, final TypeElement interfaceElement, + final Properties expressionProperties, final boolean addGeneratedAnnotation) { + final Types types = processingEnv.getTypeUtils(); + if (types.isSameType(interfaceElement.asType(), ElementHelper.toType(processingEnv.getElementUtils(), BasicLogger.class))) { MessageInterface result = LOGGER_INTERFACE; if (result == null) { synchronized (LOCK) { result = LOGGER_INTERFACE; if (result == null) { - LOGGER_INTERFACE = LoggerInterface.of(elements, types); + LOGGER_INTERFACE = LoggerInterface.of(processingEnv); result = LOGGER_INTERFACE; } } } return result; } - final AptMessageInterface result = new AptMessageInterface(interfaceElement, types, elements); + final AptMessageInterface result = new AptMessageInterface(interfaceElement, processingEnv, expressionProperties, addGeneratedAnnotation); result.init(); for (TypeMirror typeMirror : interfaceElement.getInterfaces()) { - final MessageInterface extended = MessageInterfaceFactory.of(processingEnvironment, (TypeElement) types.asElement(typeMirror)); + final MessageInterface extended = MessageInterfaceFactory.of(processingEnv, (TypeElement) types.asElement(typeMirror), + expressionProperties, addGeneratedAnnotation); result.extendedInterfaces.add(extended); result.extendedInterfaces.addAll(extended.extendedInterfaces()); } @@ -104,11 +108,13 @@ /** * Message interface implementation. */ - private static class AptMessageInterface extends AbstractMessageObjectType implements MessageInterface { + private static class AptMessageInterface extends AbstractClassType implements MessageInterface { private final TypeElement interfaceElement; private final Set extendedInterfaces; private final List messageMethods; private final List validIdRanges; + private final Properties expressionProperties; + private final TypeElement generatedAnnotation; private String projectCode; private String packageName; private String simpleName; @@ -116,18 +122,30 @@ private String fqcn; private int idLen; - private AptMessageInterface(final TypeElement interfaceElement, final Types types, final Elements elements) { - super(elements, types, interfaceElement); + private AptMessageInterface(final TypeElement interfaceElement, final ProcessingEnvironment processingEnv, + final Properties expressionProperties, final boolean addGeneratedAnnotation) { + super(processingEnv, interfaceElement); this.interfaceElement = interfaceElement; - this.messageMethods = new LinkedList(); - this.extendedInterfaces = new LinkedHashSet(); + this.expressionProperties = expressionProperties; + this.messageMethods = new LinkedList<>(); + this.extendedInterfaces = new LinkedHashSet<>(); if (ElementHelper.isAnnotatedWith(interfaceElement, ValidIdRanges.class)) { validIdRanges = Arrays.asList(interfaceElement.getAnnotation(ValidIdRanges.class).value()); } else if (ElementHelper.isAnnotatedWith(interfaceElement, ValidIdRange.class)) { - validIdRanges = Arrays.asList(interfaceElement.getAnnotation(ValidIdRange.class)); + validIdRanges = Collections.singletonList(interfaceElement.getAnnotation(ValidIdRange.class)); } else { validIdRanges = Collections.emptyList(); } + // Determine the type for the generated annotation + TypeElement generatedAnnotation = null; + if (addGeneratedAnnotation) { + generatedAnnotation = processingEnv.getElementUtils().getTypeElement("javax.annotation.Generated"); + if (generatedAnnotation == null) { + // As of Java 9 the annotation has been moved to the javax.annotation.processing package + generatedAnnotation = processingEnv.getElementUtils().getTypeElement("javax.annotation.processing.Generated"); + } + } + this.generatedAnnotation = generatedAnnotation; } @Override @@ -147,7 +165,7 @@ @Override public int hashCode() { - return HashCodeBuilder.builder().add(name()).toHashCode(); + return Objects.hash(qualifiedName); } @Override @@ -166,15 +184,10 @@ } private void init() { - // Keeping below for now - final Collection methods = ElementFilter.methodsIn(interfaceElement.getEnclosedElements()); - final MessageMethodBuilder builder = MessageMethodBuilder.create(elements, types); - for (ExecutableElement param : methods) { - builder.add(param); - } + final MessageMethodBuilder builder = MessageMethodBuilder.create(processingEnv, expressionProperties) + .add(getMessageMethods(interfaceElement)); final Collection m = builder.build(); - if (m != null) - this.messageMethods.addAll(m); + this.messageMethods.addAll(m); final MessageBundle messageBundle = interfaceElement.getAnnotation(MessageBundle.class); final MessageLogger messageLogger = interfaceElement.getAnnotation(MessageLogger.class); if (messageBundle != null) { @@ -183,7 +196,9 @@ } else if (messageLogger != null) { projectCode = messageLogger.projectCode(); idLen = messageLogger.length(); - } // TODO (jrp) this should cause an error + } else { + throw new ProcessingException(interfaceElement, "Interface is not annotated with @MessageBundle or @MessageLogger"); + } qualifiedName = elements.getBinaryName(interfaceElement).toString(); final int lastDot = qualifiedName.lastIndexOf("."); if (lastDot > 0) { @@ -204,11 +219,6 @@ } @Override - public String type() { - return name(); - } - - @Override public String packageName() { return packageName; } @@ -229,16 +239,6 @@ } @Override - public AnnotatedType getAnnotatedType() { - if (ElementHelper.isAnnotatedWith(interfaceElement, MessageLogger.class)) { - return AnnotatedType.MESSAGE_LOGGER; - } else if (ElementHelper.isAnnotatedWith(interfaceElement, MessageBundle.class)) { - return AnnotatedType.MESSAGE_BUNDLE; - } - return AnnotatedType.NONE; - } - - @Override public List validIdRanges() { return validIdRanges; } @@ -248,16 +248,21 @@ return idLen; } + @Override - public boolean isAnnotatedWith(final Class annotation) { - return getAnnotation(annotation) != null; + public TypeElement getDelegate() { + return interfaceElement; } @Override - public A getAnnotation(final Class annotation) { - return interfaceElement.getAnnotation(annotation); + public TypeElement generatedAnnotation() { + return generatedAnnotation; } + @Override + public Properties expressionProperties() { + return expressionProperties; + } @Override public boolean equals(final Object obj) { @@ -278,37 +283,27 @@ } - @Override - public TypeElement reference() { - return interfaceElement; - } - - } - private static class LoggerInterface extends AbstractMessageObjectType implements MessageInterface { + private static class LoggerInterface extends AbstractClassType implements MessageInterface { private final TypeElement loggerInterface; private final Set messageMethods; - private LoggerInterface(final Elements elements, final Types types) { - // TODO (jrp) BasicLogger type can likely be initialized once - super(elements, types, elements.getTypeElement(BasicLogger.class.getName())); - messageMethods = new LinkedHashSet(); - this.loggerInterface = elements.getTypeElement(BasicLogger.class.getName()); + private LoggerInterface(final ProcessingEnvironment processingEnv, final TypeElement loggerInterface) { + super(processingEnv, loggerInterface.asType()); + messageMethods = new LinkedHashSet<>(); + this.loggerInterface = loggerInterface; } private void init() { - final MessageMethodBuilder builder = MessageMethodBuilder.create(elements, types); - List methods = ElementFilter.methodsIn(loggerInterface.getEnclosedElements()); - for (ExecutableElement method : methods) { - builder.add(method); - } + final MessageMethodBuilder builder = MessageMethodBuilder.create(processingEnv) + .add(getMessageMethods(loggerInterface)); final Collection m = builder.build(); this.messageMethods.addAll(m); } - static LoggerInterface of(final Elements elements, final Types types) { - final LoggerInterface result = new LoggerInterface(elements, types); + static LoggerInterface of(final ProcessingEnvironment processingEnv) { + final LoggerInterface result = new LoggerInterface(processingEnv, ElementHelper.toTypeElement(processingEnv, BasicLogger.class)); result.init(); return result; } @@ -354,11 +349,6 @@ } @Override - public AnnotatedType getAnnotatedType() { - return AnnotatedType.NONE; - } - - @Override public List validIdRanges() { return Collections.emptyList(); } @@ -369,21 +359,6 @@ } @Override - public boolean isAnnotatedWith(final Class annotation) { - return getAnnotation(annotation) != null; - } - - @Override - public A getAnnotation(final Class annotation) { - return loggerInterface.getAnnotation(annotation); - } - - @Override - public TypeElement reference() { - return loggerInterface; - } - - @Override public int hashCode() { return HashCodeBuilder.builder().add(name()).toHashCode(); } @@ -414,5 +389,17 @@ public String getComment() { return elements.getDocComment(loggerInterface); } + + @Override + public TypeElement getDelegate() { + return loggerInterface; + } + } + + private static Collection getMessageMethods(final TypeElement intf) { + return ElementFilter.methodsIn(intf.getEnclosedElements()) + .stream() + .filter(method -> !method.isDefault() && !method.getModifiers().contains(Modifier.STATIC)) + .collect(Collectors.toList()); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/MessageMethodBuilder.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/MessageMethodBuilder.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/MessageMethodBuilder.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/MessageMethodBuilder.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,40 +22,49 @@ package org.jboss.logging.processor.apt; -import static java.util.Collections.unmodifiableSet; -import static org.jboss.logging.processor.util.ElementHelper.findByName; -import static org.jboss.logging.processor.util.ElementHelper.inheritsMessage; -import static org.jboss.logging.processor.util.ElementHelper.isOverloaded; -import static org.jboss.logging.processor.util.ElementHelper.parameterCount; +import static org.jboss.logging.processor.util.ElementHelper.isAnnotatedWith; import static org.jboss.logging.processor.util.Objects.HashCodeBuilder; import static org.jboss.logging.processor.util.Objects.ToStringBuilder; import static org.jboss.logging.processor.util.Objects.areEqual; +import java.lang.annotation.Annotation; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.EnumMap; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; import org.jboss.logging.Logger; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.Field; import org.jboss.logging.annotations.LogMessage; import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.Message.Format; +import org.jboss.logging.annotations.Param; +import org.jboss.logging.annotations.Pos; +import org.jboss.logging.annotations.Property; +import org.jboss.logging.annotations.Suppressed; import org.jboss.logging.processor.model.MessageMethod; import org.jboss.logging.processor.model.Parameter; -import org.jboss.logging.processor.model.Parameter.ParameterType; import org.jboss.logging.processor.model.ReturnType; import org.jboss.logging.processor.model.ThrowableType; import org.jboss.logging.processor.util.Comparison; import org.jboss.logging.processor.util.ElementHelper; +import org.jboss.logging.processor.util.Expressions; /** * Date: 29.07.2011 @@ -66,21 +75,22 @@ private static final String MESSAGE_METHOD_SUFFIX = "$str"; private final List methods; - private final Elements elements; - private final Types types; + private final ProcessingEnvironment processingEnv; + private final Properties expressionProperties; - private MessageMethodBuilder(final Elements elements, final Types types) { - this.elements = elements; - this.types = types; + private MessageMethodBuilder(final ProcessingEnvironment processingEnv, final Properties expressionProperties) { + this.processingEnv = processingEnv; + this.expressionProperties = expressionProperties; methods = new LinkedList<>(); } - MessageMethodBuilder add(final ExecutableElement method) { - methods.add(method); + MessageMethodBuilder add(final Collection methods) { + this.methods.addAll(methods); return this; } Set build() { + final Elements elements = processingEnv.getElementUtils(); final Set result = new LinkedHashSet<>(); for (ExecutableElement elementMethod : methods) { final AptMessageMethod resultMethod = new AptMessageMethod(elements, elementMethod); @@ -88,11 +98,11 @@ resultMethod.message = findMessage(methods, elementMethod); resultMethod.isOverloaded = isOverloaded(methods, elementMethod); for (TypeMirror thrownType : elementMethod.getThrownTypes()) { - resultMethod.thrownTypes.add(ThrowableTypeFactory.of(elements, types, thrownType)); + resultMethod.thrownTypes.add(ThrowableTypeFactory.of(processingEnv, thrownType)); } // Create a list of parameters - for (Parameter parameter : ParameterFactory.of(elements, types, resultMethod.method)) { + for (Parameter parameter : ParameterFactory.of(processingEnv, resultMethod.method)) { resultMethod.add(parameter); } // Check to see if the method is overloaded @@ -104,7 +114,7 @@ resultMethod.translationKey = resultMethod.name(); } // Set the return type - resultMethod.returnType = ReturnTypeFactory.of(elements, types, elementMethod.getReturnType(), resultMethod); + resultMethod.returnType = ReturnTypeFactory.of(processingEnv, elementMethod.getReturnType(), resultMethod); result.add(resultMethod); } return Collections.unmodifiableSet(result); @@ -114,7 +124,7 @@ AptMessage result = null; Message message = method.getAnnotation(Message.class); if (message != null) { - result = new AptMessage(message); + result = new AptMessage(message, expressionProperties); result.hasId = hasMessageId(message); result.inheritsId = message.id() == Message.INHERIT; if (result.inheritsId()) { @@ -126,11 +136,11 @@ result.id = message.id(); } } else { - final Collection allMethods = findByName(methods, method.getSimpleName(), parameterCount(method.getParameters())); + final Collection allMethods = findByName(methods, method); for (ExecutableElement m : allMethods) { message = m.getAnnotation(Message.class); if (message != null) { - result = new AptMessage(message); + result = new AptMessage(message, expressionProperties); result.hasId = hasMessageId(message); result.inheritsId = message.id() == Message.INHERIT; if (result.inheritsId()) { @@ -166,8 +176,110 @@ return message != null && (message.id() != Message.NONE && message.id() != Message.INHERIT); } - static MessageMethodBuilder create(final Elements elements, final Types types) { - return new MessageMethodBuilder(elements, types); + private Collection findByName(final Collection methods, final ExecutableElement method) { + final Name methodName = method.getSimpleName(); + final List result = new ArrayList<>(); + final int paramCount = parameterCount(method.getParameters()); + for (ExecutableElement m : methods) { + if (methodName.equals(m.getSimpleName()) && parameterCount(m.getParameters()) == paramCount) { + result.add(m); + } + } + return result; + } + + + /** + * Returns a collection of methods with the same name. + * + * @param methods the methods to process. + * @param methodName the method name to findByName. + * + * @return a collection of methods with the same name. + */ + private Collection findByName(final Collection methods, final Name methodName) { + final List result = new ArrayList<>(); + for (ExecutableElement method : methods) { + if (methodName.equals(method.getSimpleName())) { + result.add(method); + } + } + return result; + } + + /** + * Checks to see if the method has or inherits a {@link org.jboss.logging.annotations.Message} + * annotation. + * + * @param methods the method to search. + * @param method the method to check. + * + * @return {@code true} if the method has or inherits a message annotation, otherwise {@code false}. + */ + + private boolean inheritsMessage(final Collection methods, final ExecutableElement method) { + if (isAnnotatedWith(method, Message.class)) { + return false; + } + final Collection allMethods = findByName(methods, method.getSimpleName()); + for (ExecutableElement m : allMethods) { + if (isAnnotatedWith(m, Message.class)) { + return true; + } + } + return false; + } + + /** + * Checks to see if the method is overloaded. An overloaded method has a different parameter count based on the + * format parameters only. Parameters annotated with {@link org.jboss.logging.annotations.Cause} or + * {@link org.jboss.logging.annotations.Param} + * are not counted. + * + * @param methods the method to search. + * @param method the method to check. + * + * @return {@code true} if the method is overloaded, otherwise {@code false}. + */ + private boolean isOverloaded(final Collection methods, final ExecutableElement method) { + final Collection allMethods = findByName(methods, method.getSimpleName()); + for (ExecutableElement m : allMethods) { + if (method.getSimpleName().equals(m.getSimpleName()) && parameterCount(method.getParameters()) != parameterCount(m.getParameters())) { + return true; + } + } + return false; + } + + /** + * Returns the number of parameters excluding the {@link org.jboss.logging.annotations.Cause} parameter + * and any {@link org.jboss.logging.annotations.Param} parameters if found. + * + * @param params the parameters to get the count for. + * + * @return the number of parameters. + */ + private int parameterCount(final Collection params) { + int result = params.size(); + boolean hasCause = false; + for (VariableElement param : params) { + if (isAnnotatedWith(param, Param.class) || isAnnotatedWith(param, Field.class) || + isAnnotatedWith(param, Property.class) || isAnnotatedWith(param, Suppressed.class)) { + --result; + } + if (isAnnotatedWith(param, Cause.class)) { + hasCause = true; + } + } + return (result - (hasCause ? 1 : 0)); + } + + static MessageMethodBuilder create(final ProcessingEnvironment processingEnv) { + return create(processingEnv, new Properties()); + } + + static MessageMethodBuilder create(final ProcessingEnvironment processingEnv, final Properties expressionProperties) { + return new MessageMethodBuilder(processingEnv, expressionProperties); } /** @@ -176,7 +288,7 @@ private static class AptMessageMethod implements MessageMethod { private final Elements elements; - private final Map> parameters; + private final Map> parameters; private final Set thrownTypes; private final ExecutableElement method; private ReturnType returnType; @@ -186,6 +298,7 @@ private Message message; private String messageMethodName; private String translationKey; + private int formatParameterCount; /** * Private constructor for the @@ -198,26 +311,36 @@ this.method = method; inheritsMessage = false; isOverloaded = false; - parameters = new EnumMap<>(ParameterType.class); + parameters = new HashMap<>(); thrownTypes = new LinkedHashSet<>(); + formatParameterCount = 0; } void add(final Parameter parameter) { - if (parameters.containsKey(ParameterType.ANY)) { - parameters.get(ParameterType.ANY).add(parameter); + if (parameter.isFormatParameter()) { + if (parameter.isAnnotatedWith(Pos.class)) { + formatParameterCount += parameter.getAnnotation(Pos.class).value().length; + } else { + formatParameterCount++; + } + } + if (parameters.containsKey(null)) { + parameters.get(null).add(parameter); } else { final Set any = new LinkedHashSet<>(); any.add(parameter); - parameters.put(ParameterType.ANY, any); + parameters.put(null, any); } - if (parameters.containsKey(parameter.parameterType())) { - parameters.get(parameter.parameterType()).add(parameter); - } else { - final Set set = new LinkedHashSet<>(); - set.add(parameter); - parameters.put(parameter.parameterType(), set); + for (AnnotationMirror a : parameter.getAnnotationMirrors()) { + if (parameters.containsKey(a.getAnnotationType())) { + parameters.get(a.getAnnotationType()).add(parameter); + } else { + final Set set = new LinkedHashSet<>(); + set.add(parameter); + parameters.put(a.getAnnotationType(), set); + } } - if (parameter.parameterType() == ParameterType.CAUSE) { + if (parameter.isAnnotatedWith(Cause.class)) { cause = parameter; } } @@ -228,25 +351,17 @@ } @Override - public Set parameters(final ParameterType parameterType) { - if (parameters.containsKey(parameterType)) { - return parameters.get(parameterType); + public Set parameters() { + if (parameters.containsKey(null)) { + return Collections.unmodifiableSet(parameters.get(null)); } return Collections.emptySet(); } @Override - public Set parameters(final ParameterType parameterType, final ParameterType... parameterTypes) { - final Set result = new LinkedHashSet(); - if (parameters.containsKey(parameterType)) { - result.addAll(parameters.get(parameterType)); - } - for (ParameterType pt : parameterTypes) { - if (parameters.containsKey(pt)) { - result.addAll(parameters.get(pt)); - } - } - return result; + public Set parametersAnnotatedWith(final Class annotation) { + final TypeElement type = ElementHelper.toTypeElement(elements, annotation); + return parameters.containsKey(type.asType()) ? Collections.unmodifiableSet(parameters.get(type.asType())) : Collections.emptySet(); } @Override @@ -256,7 +371,7 @@ @Override public Set thrownTypes() { - return unmodifiableSet(thrownTypes); + return Collections.unmodifiableSet(thrownTypes); } @Override @@ -317,27 +432,28 @@ @Override public int formatParameterCount() { - int result = parameters(ParameterType.FORMAT, ParameterType.TRANSFORM).size(); - for (Parameter params : parameters(ParameterType.POS)) { - result += params.pos().value().length; - } - return result; + return formatParameterCount; } @Override public boolean isLoggerMethod() { - return ElementHelper.isAnnotatedWith(method, LogMessage.class); + return isAnnotatedWith(LogMessage.class); } @Override public int hashCode() { return HashCodeBuilder.builder() .add(name()) - .add(parameters(ParameterType.ANY)) + .add(parameters()) .add(returnType()).toHashCode(); } @Override + public ExecutableElement getDelegate() { + return method; + } + + @Override public boolean equals(final Object obj) { if (obj == this) { return true; @@ -356,25 +472,20 @@ return ToStringBuilder.of(this) .add("name", name()) .add("returnType", returnType()) - .add("parameters", parameters(ParameterType.ANY)) + .add("parameters", parameters()) .add("loggerMethod", loggerMethod()).toString(); } @Override - public ExecutableElement reference() { - return method; - } - - @Override public int compareTo(final MessageMethod o) { int result = name().compareTo(o.name()); result = (result != Comparison.EQUAL) ? result : returnType.name().compareTo(o.returnType().name()); // Size does matter - result = (result != Comparison.EQUAL) ? result : parameters(ParameterType.ANY).size() - o.parameters(ParameterType.ANY).size(); + result = (result != Comparison.EQUAL) ? result : parameters().size() - o.parameters().size(); if (result == Comparison.EQUAL) { // Check element by element - final Iterator params1 = parameters(ParameterType.ANY).iterator(); - final Iterator params2 = o.parameters(ParameterType.ANY).iterator(); + final Iterator params1 = parameters().iterator(); + final Iterator params2 = o.parameters().iterator(); while (params1.hasNext()) { if (params2.hasNext()) { final Parameter param1 = params1.next(); @@ -399,12 +510,18 @@ private static class AptMessage implements MessageMethod.Message { private final Message message; + private final String messageValue; private int id; private boolean hasId; private boolean inheritsId; - private AptMessage(final Message message) { + private AptMessage(final Message message, final Properties expressionProperties) { this.message = message; + if (expressionProperties.isEmpty()) { + this.messageValue = message.value(); + } else { + this.messageValue = Expressions.resolve(expressionProperties, message.value()); + } } @Override @@ -424,7 +541,7 @@ @Override public String value() { - return message.value(); + return messageValue; } @Override diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ParameterFactory.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ParameterFactory.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ParameterFactory.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ParameterFactory.java 2017-08-09 18:02:31.000000000 +0000 @@ -28,19 +28,18 @@ import java.util.LinkedHashSet; import java.util.List; +import java.util.Objects; import java.util.Set; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; -import javax.lang.model.util.Elements; import javax.lang.model.util.Types; -import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.Field; import org.jboss.logging.annotations.FormatWith; -import org.jboss.logging.annotations.LoggingClass; -import org.jboss.logging.annotations.Param; import org.jboss.logging.annotations.Pos; import org.jboss.logging.annotations.Property; import org.jboss.logging.annotations.Transform; @@ -60,8 +59,9 @@ private ParameterFactory() { } - public static Set of(final Elements elements, final Types types, final ExecutableElement method) { - final Set result = new LinkedHashSet(); + public static Set of(final ProcessingEnvironment processingEnv, final ExecutableElement method) { + final Types types = processingEnv.getTypeUtils(); + final Set result = new LinkedHashSet<>(); final List params = method.getParameters(); int index = 0; for (VariableElement param : params) { @@ -81,200 +81,45 @@ } } if (method.isVarArgs()) { - result.add(new AptParameter(elements, types, qualifiedType, param, formatClass, (++index == params.size()))); + result.add(new AptParameter(processingEnv, qualifiedType, param, formatClass, (++index == params.size()))); } else { - result.add(new AptParameter(elements, types, qualifiedType, param, formatClass, false)); + result.add(new AptParameter(processingEnv, qualifiedType, param, formatClass, false)); } } return result; } public static Parameter forMessageMethod(final MessageMethod messageMethod) { - return new Parameter() { - - @Override - public String formatterClass() { - return null; - } - - @Override - public Class paramClass() { - return null; - } - - @Override - public String targetName() { - return ""; - } - - @Override - public Transform transform() { - return null; - } - - @Override - public Pos pos() { - return null; - } - - @Override - public String type() { - return String.class.getName(); - } - - @Override - public String name() { - return messageMethod.messageMethodName(); - } - - @Override - public boolean isArray() { - return false; - } - - @Override - public boolean isPrimitive() { - return false; - } - - @Override - public boolean isVarArgs() { - return false; - } - - @Override - public ParameterType parameterType() { - return ParameterType.MESSAGE; - } - - @Override - public int hashCode() { - return HashCodeBuilder.builder() - .add(type()) - .add(name()).toHashCode(); - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof AptParameter)) { - return false; - } - final AptParameter other = (AptParameter) obj; - return areEqual(type(), other.type()) && areEqual(name(), other.name()); - } - - @Override - public int compareTo(final Parameter other) { - return Comparison.begin() - .compare(this.type(), other.type()) - .compare(this.name(), other.name()).result(); - } - - @Override - public String toString() { - return ToStringBuilder.of(this) - .add("name", name()) - .add("type", type()).toString(); - } - - @Override - public MessageMethod reference() { - return messageMethod; - } - - @Override - public boolean isAssignableFrom(final Class type) { - return String.class.isAssignableFrom(type); - } - - @Override - public boolean isSubtypeOf(final Class type) { - return type.isAssignableFrom(String.class); - } - - @Override - public boolean isSameAs(final Class type) { - return type().equals(type.getName()); - } - }; + return new MessageMethodParameter(messageMethod); } - private static class AptParameter extends AbstractMessageObjectType implements Parameter { + private static class AptParameter extends AbstractClassType implements Parameter { private final VariableElement param; private final String qualifiedType; private final String formatterClass; - private final Class paramClass; private final boolean isVarArgs; - private final ParameterType parameterType; - private final Transform transform; - private final Pos pos; + private final boolean isFormatArg; /** * Only allow construction from within the parent class. * - * @param elements the element utilities from the annotation processor. - * @param types the type utilities from the annotation processor. - * @param qualifiedType the qualified type name of the parameter. - * @param param the parameter. - * @param formatterClass the formatter class, or {@code null} if none - * @param isVarArgs {@code true} if this is a vararg parameter, otherwise {@code false}. + * @param processingEnv the annotation processing environment. + * @param qualifiedType the qualified type name of the parameter. + * @param param the parameter. + * @param formatterClass the formatter class, or {@code null} if none + * @param isVarArgs {@code true} if this is a vararg parameter, otherwise {@code false}. */ - AptParameter(final Elements elements, final Types types, final String qualifiedType, final VariableElement param, final String formatterClass, final boolean isVarArgs) { - super(elements, types, param); + AptParameter(final ProcessingEnvironment processingEnv, final String qualifiedType, final VariableElement param, final String formatterClass, final boolean isVarArgs) { + super(processingEnv, param); this.qualifiedType = qualifiedType; this.param = param; this.formatterClass = formatterClass; - if (ElementHelper.isAnnotatedWith(param, Param.class)) { - paramClass = Object.class; - parameterType = ParameterType.CONSTRUCTION; - transform = null; - pos = null; - } else if (ElementHelper.isAnnotatedWith(param, Cause.class)) { - paramClass = null; - parameterType = ParameterType.CAUSE; - transform = null; - pos = null; - } else if (ElementHelper.isAnnotatedWith(param, Field.class)) { - paramClass = null; - parameterType = ParameterType.FIELD; - transform = null; - pos = null; - } else if (ElementHelper.isAnnotatedWith(param, Property.class)) { - paramClass = null; - parameterType = ParameterType.PROPERTY; - transform = null; - pos = null; - } else if (ElementHelper.isAnnotatedWith(param, LoggingClass.class)) { - paramClass = null; - parameterType = ParameterType.FQCN; - transform = null; - pos = null; - } else if (ElementHelper.isAnnotatedWith(param, Transform.class)) { - paramClass = null; - parameterType = ParameterType.TRANSFORM; - transform = param.getAnnotation(Transform.class); - pos = null; - } else if (ElementHelper.isAnnotatedWith(param, Pos.class)) { - paramClass = null; - parameterType = ParameterType.POS; - transform = null; - pos = param.getAnnotation(Pos.class); - } else { - parameterType = ParameterType.FORMAT; - paramClass = null; - transform = null; - pos = null; - } this.isVarArgs = isVarArgs; - } - - @Override - public String type() { - return qualifiedType; + isFormatArg = param.getAnnotationMirrors().isEmpty() || + ElementHelper.isAnnotatedWith(param, FormatWith.class) || + ElementHelper.isAnnotatedWith(param, Transform.class) || + ElementHelper.isAnnotatedWith(param, Pos.class); } @Override @@ -303,13 +148,8 @@ } @Override - public ParameterType parameterType() { - return parameterType; - } - - @Override - public Class paramClass() { - return paramClass; + public boolean isFormatParameter() { + return isFormatArg; } @Override @@ -337,16 +177,6 @@ } @Override - public Transform transform() { - return transform; - } - - @Override - public Pos pos() { - return pos; - } - - @Override public int hashCode() { return HashCodeBuilder.builder() .add(qualifiedType) @@ -368,7 +198,7 @@ @Override public int compareTo(final Parameter other) { return Comparison.begin() - .compare(this.type(), other.type()) + .compare(asType().toString(), other.asType().toString()) .compare(this.name(), other.name()).result(); } @@ -376,12 +206,112 @@ public String toString() { return ToStringBuilder.of(this) .add("name", name()) - .add("type", type()).toString(); + .add("type", asType()).toString(); } @Override - public VariableElement reference() { + public Element getDelegate() { return param; } } + + private static class MessageMethodParameter implements Parameter { + private final MessageMethod messageMethod; + + private MessageMethodParameter(final MessageMethod messageMethod) { + this.messageMethod = messageMethod; + } + + @Override + public Element getDelegate() { + return messageMethod; + } + + @Override + public String formatterClass() { + return null; + } + + @Override + public String targetName() { + return ""; + } + + @Override + public String name() { + return messageMethod.messageMethodName(); + } + + @Override + public boolean isArray() { + return false; + } + + @Override + public boolean isPrimitive() { + return false; + } + + @Override + public boolean isVarArgs() { + return false; + } + + @Override + public boolean isMessageMethod() { + return true; + } + + @Override + public int hashCode() { + return Objects.hash(messageMethod); + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MessageMethodParameter)) { + return false; + } + final MessageMethodParameter other = (MessageMethodParameter) obj; + return Objects.equals(messageMethod, other.messageMethod); + } + + @Override + public int compareTo(final Parameter other) { + if (other instanceof MessageMethodParameter) { + final MessageMethodParameter otherParameter = (MessageMethodParameter) other; + return messageMethod.compareTo(otherParameter.messageMethod); + } + // A little odd, but some kind of comparison should be done by default + return Comparison.begin() + .compare(asType().toString(), other.asType().toString()) + .compare(name(), other.name()) + .result(); + } + + @Override + public String toString() { + return ToStringBuilder.of(this) + .add("name", name()) + .add("type", asType()).toString(); + } + + @Override + public boolean isAssignableFrom(final Class type) { + return false; + } + + @Override + public boolean isSubtypeOf(final Class type) { + return false; + } + + @Override + public boolean isSameAs(final Class type) { + return false; + } + } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ProcessingException.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ProcessingException.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ProcessingException.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ProcessingException.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,6 +22,8 @@ package org.jboss.logging.processor.apt; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; /** @@ -31,6 +33,8 @@ */ public class ProcessingException extends RuntimeException { private final Element element; + private final AnnotationMirror annotation; + private final AnnotationValue annotationValue; /** * Creates a new exception. @@ -39,8 +43,33 @@ * @param message the message */ public ProcessingException(final Element element, final String message) { + this(element, null, null, message); + } + + /** + * Creates a new exception. + * + * @param element the element the error occurs on + * @param annotation the annotation the error occurred on + * @param message the message + */ + public ProcessingException(final Element element, final AnnotationMirror annotation, final String message) { + this(element, annotation, null, message); + } + + /** + * Creates a new exception. + * + * @param element the element the error occurs on + * @param annotation the annotation the error occurred on + * @param annotationValue the annotation value + * @param message the message + */ + public ProcessingException(final Element element, final AnnotationMirror annotation, final AnnotationValue annotationValue, final String message) { super(message); this.element = element; + this.annotation = annotation; + this.annotationValue = annotationValue; } /** @@ -51,8 +80,35 @@ * @param args the arguments for the format */ public ProcessingException(final Element element, final String format, final Object... args) { + this(element, null, null, format, args); + } + + /** + * Creates a new exception. + * + * @param element the element the error occurs on + * @param annotation the annotation the error occurred on + * @param format the format for the message + * @param args the arguments for the format + */ + public ProcessingException(final Element element, final AnnotationMirror annotation, final String format, final Object... args) { + this(element, annotation, null, format, args); + } + + /** + * Creates a new exception. + * + * @param element the element the error occurs on + * @param annotation the annotation the error occurred on + * @param annotationValue the annotation value + * @param format the format for the message + * @param args the arguments for the format + */ + public ProcessingException(final Element element, final AnnotationMirror annotation, final AnnotationValue annotationValue, final String format, final Object... args) { super(String.format(format, args)); this.element = element; + this.annotation = annotation; + this.annotationValue = annotationValue; } /** @@ -63,4 +119,22 @@ public Element getElement() { return element; } + + /** + * The annotation where the error occurred. + * + * @return the annotation or {@code null} if the error did not occur on an annotation + */ + public AnnotationMirror getAnnotation() { + return annotation; + } + + /** + * The value for the annotation that is invalid. + * + * @return the annotation value or {@code null} + */ + public AnnotationValue getAnnotationValue() { + return annotationValue; + } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/AsciidocReportWriter.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/AsciidocReportWriter.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/AsciidocReportWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/AsciidocReportWriter.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,147 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt.report; + +import java.io.BufferedWriter; +import java.io.IOException; + +import org.jboss.logging.processor.model.MessageInterface; +import org.jboss.logging.processor.model.MessageMethod; + +/** + * @author James R. Perkins + */ +class AsciidocReportWriter extends ReportWriter { + + private final BufferedWriter writer; + + AsciidocReportWriter(final MessageInterface messageInterface, final BufferedWriter writer) { + super(messageInterface); + this.writer = writer; + } + + @Override + public void writeHeader(final String title) throws IOException { + // Write the title for the document + final String escapedTitle; + if (title != null) { + escapedTitle = escape(title).toString(); + } else { + escapedTitle = "Messages"; + } + writer.write(escapedTitle); + writer.newLine(); + for (int i = 0; i < escapedTitle.length(); i++) { + writer.append('='); + } + writer.newLine(); + writer.newLine(); + + // Write the table title + writer.append('.').append(messageInterface.name()); + writer.newLine(); + // Write the table configuration, 4 columns + writer.write("[cols=\"1,5,^1,2m\"]"); + writer.newLine(); + // Write the table header + writer.write("|==="); + writer.newLine(); + writer.write("|Message Id |Message |Log Level |Return Type"); + writer.newLine(); + writer.newLine(); + } + + @Override + public void writeDetail(final MessageMethod messageMethod) throws IOException { + final MessageMethod.Message msg = messageMethod.message(); + final String id = (msg.hasId() ? String.format(messageIdFormat, msg.id()) : DEFAULT_ID); + final String url = getUrl(messageMethod, id); + if (url.isEmpty()) { + writer.append('|').append(escape(id)); + } else { + writer.append("|link:").append(url).append('[').append(id).append(']'); + } + writer.newLine(); + writer.append('|').append(escape(msg.value())); + writer.newLine(); + if (messageMethod.isLoggerMethod()) { + writer.append('|').append(getLogLevel(messageMethod)); + writer.newLine(); + writer.append("|void"); + } else { + writer.append("|--"); + writer.newLine(); + writer.append('|').append(messageMethod.returnType().name()); + } + writer.newLine(); + writer.newLine(); + } + + @Override + public void writeFooter() throws IOException { + // End the table + writer.write("|==="); + writer.newLine(); + } + + @Override + public void close() throws IOException { + writer.close(); + } + + @Override + ReportType getReportType() { + return ReportType.ASCIIDOC; + } + + private CharSequence escape(final CharSequence s) { + final StringBuilder sb = new StringBuilder(); + final int len = s.length(); + int aPos = -1; + int offset = 0; + char previous = 0x00; + for (int i = 0; i < len; i++) { + final char c = s.charAt(i); + switch (c) { + // Asterisks around text make it bold, unless there is a space after a beginning asterisk or a space + // before an ending asterisk + case '*': + if (aPos >= 0) { + if (previous != ' ') { + sb.insert(aPos + offset++, '\\'); + } + aPos = -1; + } else if ((i + 1) < len) { + final char next = s.charAt(i + 1); + if (next != ' ') { + aPos = i; + } + } + break; + } + previous = c; + sb.append(c); + } + return sb; + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/IndentingXmlWriter.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/IndentingXmlWriter.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/IndentingXmlWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/IndentingXmlWriter.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,293 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt.report; + +import java.util.Iterator; +import java.util.stream.Stream; +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +/** + * @author James R. Perkins + */ +class IndentingXmlWriter implements XMLStreamWriter, XMLStreamConstants { + + private static final String SPACES = " "; + + private final XMLStreamWriter delegate; + private int index; + private int state = START_DOCUMENT; + private boolean indentEnd; + + public IndentingXmlWriter(final XMLStreamWriter delegate) { + this.delegate = delegate; + index = 0; + indentEnd = false; + } + + private void indent() throws XMLStreamException { + final int index = this.index; + if (index > 0) { + for (int i = 0; i < index; i++) { + delegate.writeCharacters(SPACES); + } + } + + } + + private void newline() throws XMLStreamException { + delegate.writeCharacters(System.lineSeparator()); + } + + @Override + public void writeStartElement(final String localName) throws XMLStreamException { + newline(); + indent(); + delegate.writeStartElement(localName); + indentEnd = false; + state = START_ELEMENT; + index++; + } + + @Override + public void writeStartElement(final String namespaceURI, final String localName) throws XMLStreamException { + newline(); + indent(); + delegate.writeStartElement(namespaceURI, localName); + indentEnd = false; + state = START_ELEMENT; + index++; + } + + @Override + public void writeStartElement(final String prefix, final String localName, final String namespaceURI) throws XMLStreamException { + newline(); + indent(); + delegate.writeStartElement(prefix, localName, namespaceURI); + indentEnd = false; + state = START_ELEMENT; + index++; + } + + @Override + public void writeEmptyElement(final String namespaceURI, final String localName) throws XMLStreamException { + newline(); + indent(); + delegate.writeEmptyElement(namespaceURI, localName); + state = END_ELEMENT; + } + + @Override + public void writeEmptyElement(final String prefix, final String localName, final String namespaceURI) throws XMLStreamException { + newline(); + indent(); + delegate.writeEmptyElement(prefix, localName, namespaceURI); + state = END_ELEMENT; + } + + @Override + public void writeEmptyElement(final String localName) throws XMLStreamException { + newline(); + indent(); + delegate.writeEmptyElement(localName); + state = END_ELEMENT; + } + + @Override + public void writeEndElement() throws XMLStreamException { + index--; + if (state != CHARACTERS || indentEnd) { + newline(); + indent(); + indentEnd = false; + } + delegate.writeEndElement(); + state = END_ELEMENT; + } + + @Override + public void writeEndDocument() throws XMLStreamException { + delegate.writeEndDocument(); + state = END_DOCUMENT; + } + + @Override + public void close() throws XMLStreamException { + delegate.close(); + } + + @Override + public void flush() throws XMLStreamException { + delegate.flush(); + } + + @Override + public void writeAttribute(final String localName, final String value) throws XMLStreamException { + delegate.writeAttribute(localName, value); + } + + @Override + public void writeAttribute(final String prefix, final String namespaceURI, final String localName, final String value) throws XMLStreamException { + delegate.writeAttribute(prefix, namespaceURI, localName, value); + } + + @Override + public void writeAttribute(final String namespaceURI, final String localName, final String value) throws XMLStreamException { + delegate.writeAttribute(namespaceURI, localName, value); + } + + @Override + public void writeNamespace(final String prefix, final String namespaceURI) throws XMLStreamException { + delegate.writeNamespace(prefix, namespaceURI); + } + + @Override + public void writeDefaultNamespace(final String namespaceURI) throws XMLStreamException { + delegate.writeDefaultNamespace(namespaceURI); + } + + @Override + public void writeComment(final String data) throws XMLStreamException { + newline(); + indent(); + delegate.writeComment(data); + state = COMMENT; + } + + @Override + public void writeProcessingInstruction(final String target) throws XMLStreamException { + newline(); + indent(); + delegate.writeProcessingInstruction(target); + state = PROCESSING_INSTRUCTION; + } + + @Override + public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException { + newline(); + indent(); + delegate.writeProcessingInstruction(target, data); + state = PROCESSING_INSTRUCTION; + } + + @Override + public void writeCData(final String data) throws XMLStreamException { + delegate.writeCData(data); + state = CDATA; + } + + @Override + public void writeDTD(final String dtd) throws XMLStreamException { + newline(); + indent(); + delegate.writeDTD(dtd); + state = DTD; + } + + @Override + public void writeEntityRef(final String name) throws XMLStreamException { + delegate.writeEntityRef(name); + state = ENTITY_REFERENCE; + } + + @Override + public void writeStartDocument() throws XMLStreamException { + delegate.writeStartDocument(); + newline(); + state = START_DOCUMENT; + } + + @Override + public void writeStartDocument(final String version) throws XMLStreamException { + delegate.writeStartDocument(version); + newline(); + state = START_DOCUMENT; + } + + @Override + public void writeStartDocument(final String encoding, final String version) throws XMLStreamException { + delegate.writeStartDocument(encoding, version); + newline(); + state = START_DOCUMENT; + } + + @Override + public void writeCharacters(final String text) throws XMLStreamException { + indentEnd = false; + boolean first = true; + final Iterator iterator = Stream.of(text.split("\n")).iterator(); + while (iterator.hasNext()) { + final String t = iterator.next(); + // On first iteration if more than one line is required, skip to a new line and indent + if (first && iterator.hasNext()) { + first = false; + newline(); + indent(); + } + delegate.writeCharacters(t); + if (iterator.hasNext()) { + newline(); + indent(); + indentEnd = true; + } + } + state = CHARACTERS; + } + + @Override + public void writeCharacters(final char[] text, final int start, final int len) throws XMLStreamException { + delegate.writeCharacters(text, start, len); + } + + @Override + public String getPrefix(final String uri) throws XMLStreamException { + return delegate.getPrefix(uri); + } + + @Override + public void setPrefix(final String prefix, final String uri) throws XMLStreamException { + delegate.setPrefix(prefix, uri); + } + + @Override + public void setDefaultNamespace(final String uri) throws XMLStreamException { + delegate.setDefaultNamespace(uri); + } + + @Override + public void setNamespaceContext(final NamespaceContext context) throws XMLStreamException { + delegate.setNamespaceContext(context); + } + + @Override + public NamespaceContext getNamespaceContext() { + return delegate.getNamespaceContext(); + } + + @Override + public Object getProperty(final String name) throws IllegalArgumentException { + return delegate.getProperty(name); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportType.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportType.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt.report; + +/** + * Defines the report type for generating reports. + * + * @author James R. Perkins + */ +public enum ReportType { + ASCIIDOC(".adoc"), + XML(".xml"); + private final String extension; + + ReportType(final String extension) { + this.extension = extension; + } + + /** + * Returns the extension used for the file. + * + * @return the extension + */ + public String getExtension() { + return extension; + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportWriter.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportWriter.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/ReportWriter.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,183 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt.report; + +import java.io.BufferedWriter; +import java.io.Closeable; +import java.io.IOException; +import javax.xml.stream.XMLStreamException; + +import org.jboss.logging.annotations.BaseUrl; +import org.jboss.logging.annotations.ResolutionDoc; +import org.jboss.logging.processor.model.MessageInterface; +import org.jboss.logging.processor.model.MessageMethod; +import org.jboss.logging.processor.util.Expressions; + +/** + * Writes reports based on a {@link MessageInterface}. These reports could be used for documented messages from logging + * or message bundle interfaces. + * + * @author James R. Perkins + */ +public abstract class ReportWriter implements Closeable { + static final String DEFAULT_ID = "--"; + + private final String baseUrl; + final MessageInterface messageInterface; + final String messageIdFormat; + + ReportWriter(final MessageInterface messageInterface) { + this.messageInterface = messageInterface; + final int idLen = messageInterface.getIdLength(); + if (idLen > 0) { + messageIdFormat = messageInterface.projectCode() + "%0" + messageInterface.getIdLength() + "d"; + } else { + messageIdFormat = messageInterface.projectCode() + "%d"; + } + if (messageInterface.isAnnotatedWith(BaseUrl.class)) { + baseUrl = messageInterface.getAnnotation(BaseUrl.class).value(); + } else { + baseUrl = null; + } + } + + /** + * Creates a new report writer based on the report type. + * + * @param reportType the report type to create the writer for + * @param writer the used to write the contents to + * + * @return the report writer to use + * + * @throws IllegalStateException if there was an error creating the report writer + * @throws IllegalArgumentException if the {@code reportType} is invalid + */ + public static ReportWriter of(final ReportType reportType, final MessageInterface messageInterface, final BufferedWriter writer) { + if (reportType == ReportType.ASCIIDOC) { + return new AsciidocReportWriter(messageInterface, writer); + } else if (reportType == ReportType.XML) { + try { + return new XmlReportWriter(messageInterface, writer); + } catch (XMLStreamException e) { + throw new IllegalStateException("Failed to create XML report writer.", e); + } + } + throw new IllegalArgumentException("Type " + reportType + " is not a known report type."); + } + + /** + * Writes the header for the report. + * + * @param title the title of the header + * + * @throws IOException if an I/O error occurs + */ + public abstract void writeHeader(String title) throws IOException; + + /** + * Writes a detail line for the report. + * + * @param messageMethod the method to write the details for + * + * @throws IOException if an I/O error occurs + */ + public abstract void writeDetail(MessageMethod messageMethod) throws IOException; + + /** + * Writes the footer for the report. + * + * @throws IOException if an I/O error occurs + */ + public abstract void writeFooter() throws IOException; + + /** + * The report type for this writer. + * + * @return the report type + */ + abstract ReportType getReportType(); + + /** + * Gets the log level from the {@code @Message} annotation. + * + * @param method the method to get the log level from + * + * @return the log level or an empty string + */ + String getLogLevel(final MessageMethod method) { + if (method.isLoggerMethod()) { + final String logLevel = method.logLevel(); + final int index = logLevel.lastIndexOf('.'); + if (index > 0) { + return logLevel.substring(index + 1); + } + return logLevel; + } + return ""; + } + + String getUrl(final MessageMethod messageMethod, final String id) { + final ResolutionDoc resolutionDoc = getResolutionDoc(messageMethod); + if (resolutionDoc == null || resolutionDoc.skip() || DEFAULT_ID.equals(id)) { + return ""; + } + + final StringBuilder result = new StringBuilder(); + + String base = baseUrl == null ? "" : baseUrl; + final String path = resolutionDoc.path(); + final String suffix = resolutionDoc.suffix(); + final String url = resolutionDoc.url(); + if (!url.isEmpty()) { + base = url; + } + + if (!base.isEmpty()) { + result.append(base); + if (!base.endsWith("/") && !base.endsWith("#")) { + result.append('/'); + } + } + + if (path.isEmpty()) { + result.append(id); + } else { + result.append(path); + } + + if (suffix.isEmpty()) { + result.append(getReportType().getExtension()); + } else { + result.append(suffix); + } + + return Expressions.resolve(messageInterface.expressionProperties(), result.toString()); + } + + private ResolutionDoc getResolutionDoc(final MessageMethod messageMethod) { + if (messageMethod.isAnnotatedWith(ResolutionDoc.class)) { + return messageMethod.getAnnotation(ResolutionDoc.class); + } + return messageInterface.getAnnotation(ResolutionDoc.class); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/XmlReportWriter.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/XmlReportWriter.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/report/XmlReportWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/report/XmlReportWriter.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,115 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt.report; + +import java.io.BufferedWriter; +import java.io.IOException; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.jboss.logging.processor.model.MessageInterface; +import org.jboss.logging.processor.model.MessageMethod; + +/** + * @author James R. Perkins + */ +class XmlReportWriter extends ReportWriter { + private static final String NAMESPACE = "urn:jboss:logging:report:1.0"; + private final XMLStreamWriter xmlWriter; + + XmlReportWriter(final MessageInterface messageInterface, final BufferedWriter writer) throws XMLStreamException { + super(messageInterface); + final XMLOutputFactory factory = XMLOutputFactory.newInstance(); + xmlWriter = new IndentingXmlWriter(factory.createXMLStreamWriter(writer)); + } + + @Override + public void writeHeader(final String title) throws IOException { + try { + xmlWriter.writeStartDocument(); + xmlWriter.setDefaultNamespace(NAMESPACE); + xmlWriter.writeStartElement("report"); + xmlWriter.writeNamespace(null, NAMESPACE); + if (title != null) { + xmlWriter.writeAttribute("title", title); + } + xmlWriter.writeStartElement("messages"); + xmlWriter.writeAttribute("interface", messageInterface.name()); + } catch (XMLStreamException e) { + throw new IOException(e); + } + } + + @Override + public void writeDetail(final MessageMethod messageMethod) throws IOException { + try { + xmlWriter.writeStartElement("message"); + final MessageMethod.Message msg = messageMethod.message(); + final String url; + if (msg.hasId()) { + final String id = String.format(messageIdFormat, msg.id()); + xmlWriter.writeAttribute("id", id); + url = getUrl(messageMethod, id); + } else { + url = getUrl(messageMethod, DEFAULT_ID); + } + if (!url.isEmpty()) { + xmlWriter.writeAttribute("resolutionUrl", url); + } + if (messageMethod.isLoggerMethod()) { + xmlWriter.writeAttribute("logLevel", getLogLevel(messageMethod)); + } else { + xmlWriter.writeAttribute("returnType", messageMethod.returnType().name()); + } + xmlWriter.writeCharacters(msg.value()); + xmlWriter.writeEndElement(); + } catch (XMLStreamException e) { + throw new IOException(e); + } + } + + @Override + public void writeFooter() throws IOException { + try { + xmlWriter.writeEndElement(); // end + xmlWriter.writeEndElement(); // end + xmlWriter.writeEndDocument(); + } catch (XMLStreamException e) { + throw new IOException(e); + } + } + + @Override + public void close() throws IOException { + try { + if (xmlWriter != null) xmlWriter.close(); + } catch (XMLStreamException ignore) { + } + } + + @Override + ReportType getReportType() { + return ReportType.XML; + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ReportFileGenerator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ReportFileGenerator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ReportFileGenerator.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ReportFileGenerator.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,153 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.apt; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.Collection; +import java.util.Comparator; +import java.util.Locale; +import java.util.Map; +import java.util.TreeSet; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.SupportedOptions; +import javax.lang.model.element.TypeElement; +import javax.tools.StandardLocation; + +import org.jboss.logging.processor.apt.report.ReportType; +import org.jboss.logging.processor.apt.report.ReportWriter; +import org.jboss.logging.processor.model.MessageInterface; +import org.jboss.logging.processor.model.MessageMethod; + +/** + * Generates reports for logging interfaces and message bundles. + * + * @author James R. Perkins + */ +@SupportedOptions({ + ReportFileGenerator.REPORT_TYPE, + ReportFileGenerator.REPORT_PATH, + ReportFileGenerator.REPORT_TITLE +}) +public class ReportFileGenerator extends AbstractGenerator { + static final String REPORT_TYPE = "org.jboss.logging.tools.report.type"; + static final String REPORT_PATH = "org.jboss.logging.tools.report.path"; + static final String REPORT_TITLE = "org.jboss.logging.tools.report.title"; + + private final ReportType reportType; + private final String reportPath; + private final String reportTitle; + + ReportFileGenerator(final ProcessingEnvironment processingEnv) { + super(processingEnv); + Map options = processingEnv.getOptions(); + final String reportType = options.get(REPORT_TYPE); + reportPath = options.get(REPORT_PATH); + reportTitle = options.get(REPORT_TITLE); + if (reportType == null) { + this.reportType = null; + } else { + final String s = reportType.toLowerCase(Locale.ROOT); + if ("adoc".equals(s) || "asciidoc".equals(s)) { + this.reportType = ReportType.ASCIIDOC; + } else if ("xml".equals(s)) { + this.reportType = ReportType.XML; + } else { + this.reportType = null; + logger().warn(null, "Report type %s is invalid. No reports will be generated.", reportType); + } + } + + } + + @Override + public void processTypeElement(final TypeElement annotation, final TypeElement element, final MessageInterface messageInterface) { + if (reportType != null) { + try { + // Don't generate empty interfaces + if (messageInterface.methods().isEmpty()) { + logger().debug(element, "Skipping reports for interface %s with no methods.", messageInterface.name()); + return; + } + logger().debug(element, "Writing reports for interface %s.", messageInterface.name()); + + final String fileName = messageInterface.simpleName() + reportType.getExtension(); + try ( + final BufferedWriter writer = createWriter(messageInterface.packageName(), fileName); + final ReportWriter reportWriter = ReportWriter.of(reportType, messageInterface, writer) + ) { + reportWriter.writeHeader(reportTitle); + // Process the methods + for (MessageMethod messageMethod : getSortedMessageMethods(messageInterface)) { + reportWriter.writeDetail(messageMethod); + } + reportWriter.writeFooter(); + } + } catch (IOException e) { + logger().error(element, e, "Failed to generate %s report", reportType); + } + } + } + + private BufferedWriter createWriter(final String packageName, final String fileName) throws IOException { + if (reportPath == null) { + return new BufferedWriter(processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, packageName, fileName).openWriter()); + } + final Path outputPath = Paths.get(reportPath, packageName.replace(".", FileSystems.getDefault().getSeparator()), fileName); + Files.createDirectories(outputPath.getParent()); + return Files.newBufferedWriter(outputPath, StandardCharsets.UTF_8, StandardOpenOption.CREATE); + } + + /** + * Returns a sorted collection of the message methods on the interface. The methods are sorted by the message id. + * + * @param messageInterface the message interface to get the methods for + * + * @return a sorted collection of message methods + */ + private static Collection getSortedMessageMethods(final MessageInterface messageInterface) { + final Collection messageMethods = new TreeSet<>(MessageMethodSortComparator.INSTANCE); + messageMethods.addAll(messageInterface.methods()); + return messageMethods; + } + + private static class MessageMethodSortComparator implements Comparator { + static final MessageMethodSortComparator INSTANCE = new MessageMethodSortComparator(); + + @Override + public int compare(final MessageMethod o1, final MessageMethod o2) { + // First sort by message id, then message to ensure uniqueness + int result = Integer.compare(o1.message().id(), o2.message().id()); + if (result == 0) { + result = o1.message().value().compareTo(o2.message().value()); + } + return result; + } + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ReturnTypeFactory.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ReturnTypeFactory.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ReturnTypeFactory.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ReturnTypeFactory.java 2017-08-09 18:02:31.000000000 +0000 @@ -25,23 +25,18 @@ import static org.jboss.logging.processor.util.Objects.HashCodeBuilder; import static org.jboss.logging.processor.util.Objects.areEqual; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; +import java.util.function.Supplier; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; -import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; -import javax.lang.model.type.PrimitiveType; +import javax.lang.model.type.NoType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.Elements; import javax.lang.model.util.Types; import org.jboss.logging.annotations.ConstructType; import org.jboss.logging.processor.model.MessageMethod; -import org.jboss.logging.processor.model.Parameter; import org.jboss.logging.processor.model.ReturnType; import org.jboss.logging.processor.model.ThrowableType; import org.jboss.logging.processor.util.ElementHelper; @@ -60,11 +55,11 @@ } - public static ReturnType of(final Elements elements, final Types types, final TypeMirror returnType, final MessageMethod method) { + public static ReturnType of(final ProcessingEnvironment processingEnv, final TypeMirror returnType, final MessageMethod method) { if (returnType.getKind() == TypeKind.VOID) { - return ReturnType.VOID; + return VoidReturnType.getInstance(processingEnv.getTypeUtils()); } - final AptReturnType result = new AptReturnType(elements, types, returnType, method); + final AptReturnType result = new AptReturnType(processingEnv, returnType, method); result.init(); return result; } @@ -72,45 +67,51 @@ /** * Implementation of return type. */ - private static class AptReturnType extends AbstractMessageObjectType implements ReturnType { - private final Map fields; - private final Map methods; + private static class AptReturnType extends AbstractClassType implements ReturnType { private final TypeMirror returnType; private final MessageMethod method; + private final Element delegate; + private final TypeMirror resolvedType; + private final boolean isThrowable; private ThrowableType throwableType; - AptReturnType(final Elements elements, final Types types, final TypeMirror returnType, final MessageMethod method) { - super(elements, types, returnType); + AptReturnType(final ProcessingEnvironment processingEnv, final TypeMirror returnType, final MessageMethod method) { + super(processingEnv, returnType); this.returnType = returnType; this.method = method; + delegate = types.asElement(returnType); throwableType = null; - fields = new LinkedHashMap(); - methods = new LinkedHashMap(); + if (types.isSubtype(types.erasure(returnType), types.erasure(ElementHelper.toType(elements, Supplier.class)))) { + final List typeArgs = ElementHelper.getTypeArguments(returnType); + if (typeArgs.isEmpty()) { + resolvedType = elements.getTypeElement(Object.class.getCanonicalName()).asType(); + } else { + resolvedType = typeArgs.get(0); + } + } else { + resolvedType = returnType; + } + isThrowable = types.isSubtype(types.erasure(resolvedType), ElementHelper.toType(elements, Throwable.class)); } @Override - public boolean hasFieldFor(final Parameter parameter) { - return fields.containsKey(parameter.targetName()) && checkType(parameter, fields.get(parameter.targetName())); + public Element getDelegate() { + return delegate; } @Override - public boolean hasMethodFor(final Parameter parameter) { - return methods.containsKey(parameter.targetName()) && checkType(parameter, methods.get(parameter.targetName())); + public TypeMirror asType() { + return returnType; } @Override public boolean isThrowable() { - return isSubtypeOf(Throwable.class); - } - - @Override - public boolean isPrimitive() { - return returnType.getKind().isPrimitive(); + return isThrowable; } @Override public String name() { - return returnType.toString(); + return types.erasure(returnType).toString(); } @Override @@ -118,35 +119,27 @@ return throwableType; } + @Override + public TypeMirror resolvedType() { + return resolvedType; + } + private void init() { if (isThrowable()) { - TypeMirror returnType = this.returnType; - if (ElementHelper.isAnnotatedWith(method.reference(), ConstructType.class)) { - final TypeElement constructTypeValue = ElementHelper.getClassAnnotationValue(method.reference(), ConstructType.class); + // The resolved type needs to be used in cases where a Supplier is being returned + TypeMirror throwableReturnType = resolvedType; + if (method.isAnnotatedWith(ConstructType.class)) { + final TypeElement constructTypeValue = ElementHelper.getClassAnnotationValue(method, ConstructType.class); // Shouldn't be null if (constructTypeValue == null) { - throw new ProcessingException(method.reference(), "Class not defined for the ConstructType"); - } - returnType = constructTypeValue.asType(); - if (!types.isAssignable(returnType, this.returnType)) { - throw new ProcessingException(method.reference(), "The requested type %s can not be assigned to %s.", returnType, this.returnType); - } - } - throwableType = ThrowableTypeFactory.forReturnType(elements, types, returnType, method); - } - final Element e = types.asElement(returnType); - if (e instanceof TypeElement) { - final List returnTypeMethods = ElementFilter.methodsIn(elements.getAllMembers((TypeElement) e)); - for (ExecutableElement executableElement : returnTypeMethods) { - if (executableElement.getModifiers().contains(Modifier.PUBLIC) && executableElement.getParameters().size() == 1) { - methods.put(executableElement.getSimpleName().toString(), executableElement.getParameters().get(0).asType()); + throw new ProcessingException(method, "Class not defined for the ConstructType"); } - } - for (Element element : ElementFilter.fieldsIn(elements.getAllMembers((TypeElement) e))) { - if (element.getModifiers().contains(Modifier.PUBLIC) && !element.getModifiers().contains(Modifier.FINAL)) { - fields.put(element.getSimpleName().toString(), element.asType()); + throwableReturnType = constructTypeValue.asType(); + if (!types.isAssignable(throwableReturnType, resolvedType)) { + throw new ProcessingException(method, "The requested type %s can not be assigned to %s.", throwableReturnType, resolvedType); } } + throwableType = ThrowableTypeFactory.forReturnType(processingEnv, throwableReturnType, method); } } @@ -171,42 +164,83 @@ public String toString() { return Objects.ToStringBuilder.of(this) .add("name", name()) - .add("primitive", isPrimitive()) .add("throwable", isThrowable()) .add("throwableType", throwableType).toString(); } + } - @Override - public TypeMirror reference() { - return returnType; + private static class VoidReturnType implements ReturnType { + private static VoidReturnType INSTANCE = null; + private final Element voidElement; + private final NoType voidType; + private final int hash; + + private VoidReturnType(final Types types) { + voidType = types.getNoType(TypeKind.VOID); + voidElement = types.asElement(voidType); + hash = "void".hashCode(); } - private boolean checkType(final Parameter parameter, final TypeMirror type) { - if (parameter.isPrimitive()) { - if (type.getKind().isPrimitive()) { - return parameter.type().equalsIgnoreCase(type.getKind().name()); - } - return types.isAssignable(elements.getTypeElement(unbox(parameter)).asType(), type); + private static synchronized VoidReturnType getInstance(final Types types) { + if (INSTANCE == null) { + INSTANCE = new VoidReturnType(types); } - if (type.getKind().isPrimitive()) { - final TypeElement primitiveType = types.boxedClass((PrimitiveType) type); - return types.isAssignable(elements.getTypeElement(parameter.type()).asType(), primitiveType.asType()); - } - return types.isAssignable(elements.getTypeElement(parameter.type()).asType(), type); + return INSTANCE; } - private String unbox(final Parameter parameter) { - String result = parameter.type(); - if (parameter.isPrimitive()) { - if ("int".equals(result)) { - result = Integer.class.getName(); - } else if ("char".equals(result)) { - result = Character.class.getName(); - } else { - result = "java.lang." + Character.toUpperCase(result.charAt(0)) + result.substring(1); - } - } - return result; + @Override + public TypeMirror asType() { + return voidType; + } + + @Override + public boolean isThrowable() { + return false; + } + + @Override + public String name() { + return "void"; + } + + @Override + public ThrowableType throwableReturnType() { + return null; + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public boolean equals(final Object obj) { + return obj == this || obj instanceof VoidReturnType; + } + + @Override + public String toString() { + return "void"; + } + + @Override + public boolean isAssignableFrom(final Class type) { + return type == Void.class || type == void.class; + } + + @Override + public boolean isSubtypeOf(final Class type) { + return false; + } + + @Override + public boolean isSameAs(final Class type) { + return type == Void.class || type == void.class; + } + + @Override + public Element getDelegate() { + return voidElement; } } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ThrowableTypeFactory.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ThrowableTypeFactory.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ThrowableTypeFactory.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ThrowableTypeFactory.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,15 +22,16 @@ package org.jboss.logging.processor.apt; -import static org.jboss.logging.processor.model.Parameter.ParameterType; import static org.jboss.logging.processor.util.Objects.HashCodeBuilder; import static org.jboss.logging.processor.util.Objects.areEqual; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; @@ -38,12 +39,13 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; -import javax.lang.model.util.Elements; -import javax.lang.model.util.Types; +import org.jboss.logging.annotations.Param; +import org.jboss.logging.annotations.Signature; import org.jboss.logging.processor.model.MessageMethod; import org.jboss.logging.processor.model.Parameter; import org.jboss.logging.processor.model.ThrowableType; +import org.jboss.logging.processor.util.ElementHelper; import org.jboss.logging.processor.util.Objects; /** @@ -58,15 +60,14 @@ /** * Creates a new descriptor that is not primitive. * - * @param elements the element utilities from the annotation processor. - * @param types the type utilities from the annotation process. - * @param type the class name of the return type. - * @param messageMethod the message method. + * @param processingEnv the annotation processing environment. + * @param type the class name of the return type. + * @param messageMethod the message method. * * @return the return type descriptor. */ - public static ThrowableType forReturnType(final Elements elements, final Types types, final TypeMirror type, final MessageMethod messageMethod) { - final AptReturnThrowableType result = new AptReturnThrowableType(elements, types, messageMethod, type); + public static ThrowableType forReturnType(final ProcessingEnvironment processingEnv, final TypeMirror type, final MessageMethod messageMethod) { + final AptReturnThrowableType result = new AptReturnThrowableType(processingEnv, messageMethod, type); result.init(); return result; } @@ -74,22 +75,22 @@ /** * Creates a new descriptor that is not primitive. * - * @param elements the element utilities from the annotation processor. - * @param types the type utilities from the annotation process. - * @param type the class name of the return type. + * @param processingEnv the annotation processing environment. + * @param type the class name of the return type. * * @return the return type descriptor. */ - public static ThrowableType of(final Elements elements, final Types types, final TypeMirror type) { - final AptThrowableType result = new AptThrowableType(elements, types, type); + public static ThrowableType of(final ProcessingEnvironment processingEnv, final TypeMirror type) { + final AptThrowableType result = new AptThrowableType(processingEnv, type); result.init(); return result; } - private static class AptThrowableType extends AbstractMessageObjectType implements ThrowableType { + private static class AptThrowableType extends AbstractClassType implements ThrowableType { private final TypeMirror type; private final boolean isChecked; + private final Element delegate; private boolean defaultConstructor = false; private boolean stringConstructor = false; private boolean throwableConstructor = false; @@ -101,24 +102,24 @@ /** * Creates a new descriptor that is not primitive. * - * @param types the type utilities from the annotation processor. - * @param elements the element utilities from the annotation processor. - * @param type the class name of the return type. + * @param processingEnv the annotation processing environment. + * @param type the class name of the return type. */ - private AptThrowableType(final Elements elements, final Types types, final TypeMirror type) { - super(elements, types, type); + private AptThrowableType(final ProcessingEnvironment processingEnv, final TypeMirror type) { + super(processingEnv, type); this.type = type; - stringType = elements.getTypeElement(String.class.getName()).asType(); - throwableType = elements.getTypeElement(Throwable.class.getName()).asType(); - final TypeMirror runtimeException = elements.getTypeElement(RuntimeException.class.getName()).asType(); - final TypeMirror error = elements.getTypeElement(Error.class.getName()).asType(); + this.delegate = types.asElement(type); + stringType = ElementHelper.toType(elements, String.class); + throwableType = ElementHelper.toType(elements, Throwable.class); + final TypeMirror runtimeException = ElementHelper.toType(elements, RuntimeException.class); + final TypeMirror error = ElementHelper.toType(elements, Error.class); isChecked = !(types.isAssignable(runtimeException, type) && types.isAssignable(error, type)); } /** * Initializes the object. */ - protected final void init() { + protected void init() { if (!type.getKind().isPrimitive() && type.getKind() != TypeKind.VOID) { final Element element = types.asElement(type); final List constructors = ElementFilter.constructorsIn(element.getEnclosedElements()); @@ -164,6 +165,16 @@ } @Override + public Element getDelegate() { + return delegate; + } + + @Override + public TypeMirror asType() { + return type; + } + + @Override public boolean hasDefaultConstructor() { return defaultConstructor; } @@ -236,11 +247,6 @@ } @Override - public TypeMirror reference() { - return type; - } - - @Override public int compareTo(final ThrowableType o) { return name().compareTo(o.name()); } @@ -253,24 +259,67 @@ private final Set constructionParameters; private boolean useConstructionParameters = false; + private boolean causeSet = false; /** * Creates a new descriptor that is not primitive. * - * @param types the type utilities from the annotation processor. - * @param elements the element utilities from the annotation processor. - * @param messageMethod the message method. - * @param type the class name of the return type. + * @param processingEnv the annotation processing environment. + * @param messageMethod the message method. + * @param type the class name of the return type. */ - private AptReturnThrowableType(final Elements elements, final Types types, final MessageMethod messageMethod, final TypeMirror type) { - super(elements, types, type); + private AptReturnThrowableType(final ProcessingEnvironment processingEnv, final MessageMethod messageMethod, final TypeMirror type) { + super(processingEnv, type); this.messageMethod = messageMethod; - constructionParameters = new LinkedHashSet(); + constructionParameters = new LinkedHashSet<>(); + } + + @Override + protected void init() { + final ExecutableElement method = messageMethod; + final Signature signature = method.getAnnotation(Signature.class); + // If using the @Signature annotation we're attempting to use an exact constructor. + if (signature != null) { + final List args = ElementHelper.getClassArrayAnnotationValue(method, Signature.class, "value"); + // Validate the constructor exists + if (!ElementHelper.hasConstructor(types, this, args)) { + throw new ProcessingException(method, "Constructor of type %s could not be found with arguments %s", this.asType(), args); + } + final int causeIndex = signature.causeIndex(); + final int messageIndex = signature.messageIndex(); + // Note that the messageIndex is required and must be 0 or greater + if (messageIndex < 0) { + throw new ProcessingException(method, "A messageIndex of 0 or greater is required. Value %d is invalid.", messageIndex); + } + final List methodConstructorParameters = new ArrayList<>(messageMethod.parametersAnnotatedWith(Param.class)); + + constructionParameters.clear(); + useConstructionParameters = true; + causeSet = !messageMethod.hasCause(); + // The required length is the number of parameters plus the message and optional cause. + final int len = methodConstructorParameters.size() + (causeIndex < 0 ? 1 : 2); + int offset = 0; + for (int i = 0; i < len; i++) { + if (causeIndex == i) { + causeSet = true; + constructionParameters.add(messageMethod.cause()); + offset++; + } else if (messageIndex == i) { + constructionParameters.add(ParameterFactory.forMessageMethod(messageMethod)); + offset++; + } else { + constructionParameters.add(methodConstructorParameters.get(i - offset)); + } + } + + } else { + super.init(); + } } @Override protected void init(final List params) { - final Set methodConstructorParameters = messageMethod.parameters(ParameterType.CONSTRUCTION); + final Set methodConstructorParameters = messageMethod.parametersAnnotatedWith(Param.class); // If there are no construction parameters or a constructor was already found, no need to process if (methodConstructorParameters.isEmpty() || useConstructionParameters) { return; @@ -281,7 +330,7 @@ // Checks for the first constructor that can be used. The compiler will end-up determining the constructor // to use, so a best guess should work. final Iterator methodParameterIterator = methodConstructorParameters.iterator(); - final Set matchedParams = new LinkedHashSet(); + final Set matchedParams = new LinkedHashSet<>(); boolean match = false; boolean causeFound = false; boolean messageFound = false; @@ -299,10 +348,7 @@ if (methodParameterIterator.hasNext()) { final Parameter parameter = methodParameterIterator.next(); - if (parameter.reference() instanceof VariableElement) { - final VariableElement refType = (VariableElement) parameter.reference(); - match = types.isAssignable(refType.asType(), param.asType()); - } + match = types.isAssignable(parameter.asType(), param.asType()); if (match) { matchedParams.add(parameter); } @@ -315,6 +361,7 @@ constructionParameters.clear(); useConstructionParameters = true; constructionParameters.addAll(matchedParams); + causeSet = causeFound; } } } @@ -325,6 +372,11 @@ } @Override + public boolean causeSetInConstructor() { + return causeSet; + } + + @Override public Set constructionParameters() { return constructionParameters; } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ToolLogger.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ToolLogger.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/ToolLogger.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/ToolLogger.java 2017-08-09 18:02:31.000000000 +0000 @@ -33,6 +33,8 @@ import javax.lang.model.element.Element; import javax.tools.Diagnostic.Kind; +import org.jboss.logging.processor.model.DelegatingElement; + /** * A logger for logging messages for annotation processors. * @@ -287,7 +289,7 @@ if (element == null) { messager.printMessage(kind, message); } else { - messager.printMessage(kind, message, element); + messager.printMessage(kind, message, getElement(element)); } } @@ -299,14 +301,14 @@ if (element == null) { messager.printMessage(kind, message); } else { - messager.printMessage(kind, message, element); + messager.printMessage(kind, message, getElement(element)); } // Fail gracefully } catch (Throwable t) { if (element == null) { messager.printMessage(Kind.ERROR, "Error logging original message: " + messageFormat); } else { - messager.printMessage(Kind.ERROR, "Error logging original message: " + messageFormat, element); + messager.printMessage(Kind.ERROR, "Error logging original message: " + messageFormat, getElement(element)); } } } @@ -319,7 +321,7 @@ log(kind, element, stringCause); } else { String messageWithCause = messageFormat.concat(", cause : %s"); - List newArgs = new ArrayList(); + List newArgs = new ArrayList<>(); newArgs.addAll(Arrays.asList(args)); newArgs.add(stringCause); @@ -365,4 +367,9 @@ return stringWriter.toString(); } + private static Element getElement(final Element element) { + // We need to the delegate element as some implementations rely on private types + return (element instanceof DelegatingElement ? ((DelegatingElement) element).getDelegate() : element); + } + } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/TranslationClassGenerator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/TranslationClassGenerator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/TranslationClassGenerator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/TranslationClassGenerator.java 2017-08-09 18:02:31.000000000 +0000 @@ -42,18 +42,17 @@ import java.util.regex.Pattern; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.SupportedOptions; -import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.tools.FileObject; import javax.tools.StandardLocation; import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.processor.generator.model.ClassModel; import org.jboss.logging.processor.generator.model.ClassModelFactory; import org.jboss.logging.processor.model.MessageInterface; -import org.jboss.logging.processor.model.MessageInterface.AnnotatedType; import org.jboss.logging.processor.model.MessageMethod; -import org.jboss.logging.processor.util.ElementHelper; import org.jboss.logging.processor.validation.FormatValidator; import org.jboss.logging.processor.validation.FormatValidatorFactory; import org.jboss.logging.processor.validation.StringFormatValidator; @@ -126,7 +125,7 @@ } private Map> allInterfaceTranslations(final MessageInterface messageInterface, final List files) throws IOException { - final Map> validTranslations = new LinkedHashMap>(); + final Map> validTranslations = new LinkedHashMap<>(); for (MessageInterface superInterface : messageInterface.extendedInterfaces()) { validTranslations.putAll(allInterfaceTranslations(superInterface, findTranslationFiles(superInterface))); } @@ -150,7 +149,7 @@ //By default use the class output folder } else { - FileObject fObj = filer().getResource(StandardLocation.CLASS_OUTPUT, packageName, interfaceName); + FileObject fObj = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, packageName, interfaceName); classTranslationFilesPath = fObj.toUri().getPath().replace(interfaceName, ""); } final List result; @@ -183,25 +182,22 @@ * @return the valid translations messages */ private Map validateTranslationMessages(final MessageInterface messageInterface, final File file) { - Map validTranslations = new LinkedHashMap(); + Map validTranslations = new LinkedHashMap<>(); try { //Load translations Properties translations = new Properties(); translations.load(new InputStreamReader(new FileInputStream(file), "utf-8")); - final Set messageMethods = new LinkedHashSet(); + final Set messageMethods = new LinkedHashSet<>(); messageMethods.addAll(messageInterface.methods()); for (MessageInterface msgIntf : messageInterface.extendedInterfaces()) { - // Handle logger interface - if (msgIntf.getAnnotatedType() == AnnotatedType.NONE) { - continue; + if (msgIntf.isAnnotatedWith(MessageBundle.class) || msgIntf.isAnnotatedWith(MessageLogger.class)) { + messageMethods.addAll(msgIntf.methods()); } - messageMethods.addAll(msgIntf.methods()); } for (MessageMethod messageMethod : messageMethods) { final String key = messageMethod.translationKey(); - final Element methodElement = ElementHelper.fromMessageObject(messageMethod); if (translations.containsKey(key)) { final String translationMessage = translations.getProperty(key); if (!translationMessage.trim().isEmpty()) { @@ -210,19 +206,19 @@ if (validator.argumentCount() == messageMethod.formatParameterCount()) { validTranslations.put(messageMethod, translationMessage); } else { - logger().warn(methodElement, + logger().warn(messageMethod, "The parameter count for the format (%d) and the number of format parameters (%d) do not match.", validator.argumentCount(), messageMethod.formatParameterCount()); } } else { - logger().warn(methodElement, "%s Resource Bundle: %s", validator.summaryMessage(), file.getAbsolutePath()); + logger().warn(messageMethod, "%s Resource Bundle: %s", validator.summaryMessage(), file.getAbsolutePath()); } } else { - logger().warn(methodElement, "The translation message with key %s is ignored because value is empty or contains only whitespace", key); + logger().warn(messageMethod, "The translation message with key %s is ignored because value is empty or contains only whitespace", key); } } else { - logger().warn(methodElement, "The translation message with key %s have no corresponding messageMethod.", key); + logger().warn(messageMethod, "The translation message with key %s have no corresponding messageMethod.", key); } } @@ -251,7 +247,7 @@ } //Create source file - final ClassModel classModel = ClassModelFactory.translation(filer(), messageInterface, getTranslationClassNameSuffix(translationFile.getName()), translations); + final ClassModel classModel = ClassModelFactory.translation(processingEnv, messageInterface, getTranslationClassNameSuffix(translationFile.getName()), translations); try { classModel.generateAndWrite(); diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/TranslationFileGenerator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/TranslationFileGenerator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/apt/TranslationFileGenerator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/apt/TranslationFileGenerator.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,8 +22,6 @@ package org.jboss.logging.processor.apt; -import static org.jboss.logging.processor.util.ElementHelper.getPrimaryClassNamePrefix; - import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -43,16 +41,16 @@ import java.util.regex.Pattern; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.SupportedOptions; +import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; import javax.tools.FileObject; import javax.tools.StandardLocation; +import org.jboss.logging.annotations.Transform; import org.jboss.logging.annotations.Transform.TransformType; import org.jboss.logging.processor.model.MessageInterface; import org.jboss.logging.processor.model.MessageMethod; import org.jboss.logging.processor.model.Parameter; -import org.jboss.logging.processor.model.Parameter.ParameterType; -import org.jboss.logging.processor.util.Strings; /** * The generator of skeletal @@ -61,24 +59,25 @@ * @author Kevin Pollet - SERLI - (kevin.pollet@serli.com) * @author James R. Perkins */ -@SupportedOptions(TranslationFileGenerator.GENERATED_FILES_PATH_OPTION) +@SuppressWarnings("MagicNumber") +@SupportedOptions({TranslationFileGenerator.GENERATED_FILES_PATH_OPTION, TranslationFileGenerator.LEVEL_OPTION}) final class TranslationFileGenerator extends AbstractGenerator { - private static final Map levels = new HashMap(); + private static final Map levels = new HashMap<>(); private static final Pattern PATTERN = Pattern.compile("((@[a-zA-Z_0-9]+)\\s+([a-zA-Z_][a-zA-Z_0-9]*)\\s+([a-zA-Z_][a-zA-Z_0-9].*)\\s*)"); - public static final String EMPTY_STRING = ""; - public static final String JAVA_DOC_PARAM = "@param"; + private static final String EMPTY_STRING = ""; + private static final String JAVA_DOC_PARAM = "@param"; - public static final String GENERATED_FILES_PATH_OPTION = "generatedTranslationFilesPath"; + private static final String DEFAULT_FILE_EXTENSION = ".i18n.properties"; - public static final String LEVEL_OPTION = "org.jboss.logging.tools.level"; + private static final String DEFAULT_FILE_COMMENT = "# This file is for reference only, changes have no effect on the generated interface implementations."; - public static final String GENERATED_FILE_EXTENSION = ".i18n_locale_COUNTRY_VARIANT.properties"; + static final String GENERATED_FILES_PATH_OPTION = "generatedTranslationFilesPath"; - public static final String DEFAULT_FILE_EXTENSION = ".i18n.properties"; + static final String GENERATED_FILE_EXTENSION = ".i18n_locale_COUNTRY_VARIANT.properties"; - private static final String DEFAULT_FILE_COMMENT = "# This file is for reference only, changes have no effect on the generated interface implementations."; + static final String LEVEL_OPTION = "org.jboss.logging.tools.level"; static { @@ -106,7 +105,7 @@ * * @param processingEnv the processing env */ - public TranslationFileGenerator(final ProcessingEnvironment processingEnv) { + TranslationFileGenerator(final ProcessingEnvironment processingEnv) { super(processingEnv); Map options = processingEnv.getOptions(); this.generatedFilesPath = options.get(GENERATED_FILES_PATH_OPTION); @@ -133,7 +132,7 @@ public void processTypeElement(final TypeElement annotation, final TypeElement element, final MessageInterface messageInterface) { if (generatedFilesPath != null) { if (element.getKind().isInterface()) { - String packageName = elementUtils().getPackageOf(element).getQualifiedName().toString(); + String packageName = processingEnv.getElementUtils().getPackageOf(element).getQualifiedName().toString(); String relativePath = packageName.replace('.', File.separatorChar); String fileName = getPrimaryClassNamePrefix(element) + GENERATED_FILE_EXTENSION; @@ -152,7 +151,7 @@ * @param fileName the file name * @param messageInterface the message interface */ - void generateSkeletalTranslationFile(final String relativePath, final String fileName, final MessageInterface messageInterface) { + private void generateSkeletalTranslationFile(final String relativePath, final String fileName, final MessageInterface messageInterface) { if (messageInterface == null) { throw new IllegalArgumentException("The translations parameter cannot be null"); } @@ -166,7 +165,7 @@ try { writer = new BufferedWriter(new FileWriter(file)); - final Set processed = new HashSet(); + final Set processed = new HashSet<>(); for (MessageMethod messageMethod : messageInterface.methods()) { if (isMethodWritable(messageMethod)) { @@ -202,7 +201,7 @@ try { if (generatedFilesPath == null) { - final FileObject fileObject = filer().createResource(StandardLocation.CLASS_OUTPUT, messageInterface.packageName(), fileName); + final FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, messageInterface.packageName(), fileName); // Note the FileObject#openWriter() is used here. The FileObject#openOutputStream() returns an output stream // that writes each byte separately which results in poor performance. writer = new BufferedWriter(fileObject.openWriter()); @@ -214,18 +213,16 @@ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf-8")); } // Write comments - writer.write(Strings.fill("#", DEFAULT_FILE_COMMENT.length())); - writer.newLine(); + writeSeparatorLine(writer); writer.write("#"); writer.newLine(); writer.write(DEFAULT_FILE_COMMENT); writer.newLine(); writer.write("#"); writer.newLine(); - writer.write(Strings.fill("#", DEFAULT_FILE_COMMENT.length())); - writer.newLine(); + writeSeparatorLine(writer); writer.newLine(); - final Set processed = new HashSet(); + final Set processed = new HashSet<>(); for (MessageMethod messageMethod : messageInterface.methods()) { if (isMethodWritable(messageMethod)) { @@ -261,13 +258,12 @@ writer.write(String.format("# Message: %s", msg.value())); writer.newLine(); final Map parameterComments = parseParameterComments(messageMethod); - final Set parameters = messageMethod.parameters(ParameterType.FORMAT, ParameterType.TRANSFORM); int i = 0; - for (Parameter parameter : parameters) { + for (Parameter parameter : messageMethod.parameters()) { final String name = parameter.name(); final String comment = (parameterComments.containsKey(name) ? parameterComments.get(name) : EMPTY_STRING); - if (parameter.parameterType() == ParameterType.TRANSFORM) { - final List transformTypes = Arrays.asList(parameter.transform().value()); + if (parameter.isAnnotatedWith(Transform.class)) { + final List transformTypes = Arrays.asList(parameter.getAnnotation(Transform.class).value()); if (transformTypes.contains(TransformType.GET_CLASS)) { if (transformTypes.size() == 1) { writer.write(String.format("# @param class of %s - %s", name, comment)); @@ -288,7 +284,7 @@ } } writer.newLine(); - } else { + } else if (parameter.isFormatParameter()) { writer.write(String.format("# @param %d: %s - %s", ++i, name, comment)); writer.newLine(); } @@ -299,7 +295,7 @@ } private Map parseParameterComments(final MessageMethod messageMethod) throws IOException { - final Map result = new LinkedHashMap(); + final Map result = new LinkedHashMap<>(); final String comment = messageMethod.getComment(); if (comment != null) { final Matcher matcher = PATTERN.matcher(comment); @@ -318,6 +314,44 @@ return !(comparator != null && method.isLoggerMethod()) || (comparator.compareTo(method.logLevel()) >= 0); } + private static void writeSeparatorLine(final BufferedWriter writer) throws IOException { + final int len = DEFAULT_FILE_COMMENT.length(); + for (int i = 0; i < len; i++) { + writer.append('#'); + } + writer.newLine(); + } + + /** + * Returns the primary class simple name prefix for an element + * who represents a MessageBundle or MessageLogger interface. + * + * @param element the element + * + * @return the translation file name prefix + * + * @throws IllegalArgumentException if element is null or the element is not an interface + */ + private static String getPrimaryClassNamePrefix(final TypeElement element) { + if (element == null) { + throw new IllegalArgumentException("The element parameter cannot be null"); + } + if (!element.getKind().isInterface()) { + throw new IllegalArgumentException("The element parameter is not an interface"); + } + + String translationFileName = element.getSimpleName().toString(); + + //Check if it's an inner interface + Element enclosingElt = element.getEnclosingElement(); + while (enclosingElt != null && enclosingElt instanceof TypeElement) { + translationFileName = String.format("%s$%s", enclosingElt.getSimpleName().toString(), translationFileName); + enclosingElt = enclosingElt.getEnclosingElement(); + } + + return translationFileName; + } + private static final class LevelComparator implements Comparable { private final Integer levelIntValue; diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelFactory.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelFactory.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelFactory.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelFactory.java 2017-08-09 18:02:31.000000000 +0000 @@ -26,8 +26,10 @@ import static org.jboss.logging.processor.util.TranslationHelper.getEnclosingTranslationClassName; import java.util.Map; -import javax.annotation.processing.Filer; +import javax.annotation.processing.ProcessingEnvironment; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.processor.model.MessageInterface; import org.jboss.logging.processor.model.MessageMethod; @@ -48,21 +50,20 @@ /** * Creates an implementation code model from the message interface. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement * @param useLogging31 whether or not jboss-logging 3.1 or higher is used * * @return the class model used to implement the interface. * - * @throws IllegalArgumentException if {@link org.jboss.logging.processor.model.MessageInterface#getAnnotatedType()} - * returns {@link org.jboss.logging.processor.model.MessageInterface.AnnotatedType#NONE} + * @throws IllegalArgumentException if interface is not annotated with {@link MessageBundle @MessageBundle} or {@link MessageLogger @MessageLogger} */ - public static ClassModel implementation(final Filer filer, final MessageInterface messageInterface, final boolean useLogging31) throws IllegalArgumentException { - switch (messageInterface.getAnnotatedType()) { - case MESSAGE_BUNDLE: - return new MessageBundleImplementor(filer, messageInterface); - case MESSAGE_LOGGER: - return new MessageLoggerImplementor(filer, messageInterface, useLogging31); + public static ClassModel implementation(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface, final boolean useLogging31) throws IllegalArgumentException { + if (messageInterface.isAnnotatedWith(MessageBundle.class)) { + return new MessageBundleImplementor(processingEnv, messageInterface); + } + if (messageInterface.isAnnotatedWith(MessageLogger.class)) { + return new MessageLoggerImplementor(processingEnv, messageInterface, useLogging31); } throw new IllegalArgumentException(String.format("Message interface %s is not a valid message logger or message bundle.", messageInterface)); } @@ -72,26 +73,25 @@ *

* Note: The implementation class must exist before the translation implementations can be created. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. * @param translationSuffix the translation locale suffix. * @param translations a map of the translations for the methods. * * @return the class model used to create translation implementations of the interface. * - * @throws IllegalArgumentException if {@link org.jboss.logging.processor.model.MessageInterface#getAnnotatedType()} - * returns {@link org.jboss.logging.processor.model.MessageInterface.AnnotatedType#NONE} + * @throws IllegalArgumentException if interface is not annotated with {@link MessageBundle @MessageBundle} or {@link MessageLogger @MessageLogger} */ - public static ClassModel translation(final Filer filer, final MessageInterface messageInterface, final String translationSuffix, final Map translations) throws IllegalArgumentException { + public static ClassModel translation(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface, final String translationSuffix, final Map translations) throws IllegalArgumentException { final String generatedClassName = implementationClassName(messageInterface, translationSuffix); final String superClassName = getEnclosingTranslationClassName(generatedClassName); // The locale should be the same as the translationsSuffix minus the leading _ final String locale = translationSuffix.substring(1); - switch (messageInterface.getAnnotatedType()) { - case MESSAGE_BUNDLE: - return new MessageBundleTranslator(filer, messageInterface, generatedClassName, superClassName, locale, translations); - case MESSAGE_LOGGER: - return new MessageLoggerTranslator(filer, messageInterface, generatedClassName, superClassName, locale, translations); + if (messageInterface.isAnnotatedWith(MessageBundle.class)) { + return new MessageBundleTranslator(processingEnv, messageInterface, generatedClassName, superClassName, locale, translations); + } + if (messageInterface.isAnnotatedWith(MessageLogger.class)) { + return new MessageLoggerTranslator(processingEnv, messageInterface, generatedClassName, superClassName, locale, translations); } throw new IllegalArgumentException(String.format("Message interface %s is not a valid message logger or message bundle.", messageInterface)); } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelHelper.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelHelper.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelHelper.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModelHelper.java 2017-08-09 18:02:31.000000000 +0000 @@ -25,7 +25,10 @@ import java.text.SimpleDateFormat; import java.util.Date; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.processor.model.MessageInterface; +import org.jboss.logging.processor.util.ElementHelper; /** * Utilities for the code model. @@ -75,15 +78,12 @@ */ public static String implementationClassName(final MessageInterface messageInterface) throws IllegalArgumentException { final StringBuilder result = new StringBuilder(messageInterface.simpleName()); - switch (messageInterface.getAnnotatedType()) { - case MESSAGE_BUNDLE: - result.append("_$bundle"); - break; - case MESSAGE_LOGGER: - result.append("_$logger"); - break; - default: - throw new IllegalArgumentException(String.format("Message interface %s is not a message bundle or message logger.", messageInterface)); + if (messageInterface.isAnnotatedWith(MessageBundle.class)) { + result.append("_$bundle"); + } else if (messageInterface.isAnnotatedWith(MessageLogger.class)) { + result.append("_$logger"); + } else { + throw new IllegalArgumentException(String.format("Message interface %s is not a message bundle or message logger.", messageInterface)); } return result.toString(); } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModel.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModel.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModel.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ClassModel.java 2017-08-09 18:02:31.000000000 +0000 @@ -26,7 +26,6 @@ import static org.jboss.jdeparser.JMod.FINAL; import static org.jboss.jdeparser.JTypes.$t; import static org.jboss.jdeparser.JTypes.typeOf; -import static org.jboss.logging.processor.util.ElementHelper.typeToString; import java.io.IOException; import java.io.Serializable; @@ -34,9 +33,8 @@ import java.util.Locale; import java.util.Map; import java.util.Properties; -import javax.annotation.Generated; -import javax.annotation.processing.Filer; -import javax.lang.model.element.Element; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.TypeElement; import org.jboss.jdeparser.FormatPreferences; import org.jboss.jdeparser.JCall; @@ -50,7 +48,6 @@ import org.jboss.jdeparser.JSourceFile; import org.jboss.jdeparser.JSources; import org.jboss.jdeparser.JType; -import org.jboss.jdeparser.JTypes; import org.jboss.jdeparser.JVarDeclaration; import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.annotations.MessageLogger; @@ -73,7 +70,6 @@ private final JSources sources; private final JClassDef classDef; - protected final JSourceFile sourceFile; private final MessageInterface messageInterface; @@ -85,18 +81,23 @@ private final Map messageMethods; private final Map messageFields; + + final JSourceFile sourceFile; + final ProcessingEnvironment processingEnv; + /** * Construct a class model. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. * @param superClassName the super class used for the translation implementations. */ - ClassModel(final Filer filer, final MessageInterface messageInterface, final String className, final String superClassName) { + ClassModel(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface, final String className, final String superClassName) { + this.processingEnv = processingEnv; this.messageInterface = messageInterface; this.className = messageInterface.packageName() + "." + className; this.superClassName = superClassName; - sources = JDeparser.createSources(JFiler.newInstance(filer), new FormatPreferences(new Properties())); + sources = JDeparser.createSources(JFiler.newInstance(processingEnv.getFiler()), new FormatPreferences(new Properties())); sourceFile = sources.createSourceFile(messageInterface.packageName(), className); classDef = sourceFile._class(JMod.PUBLIC, className); final int idLen = messageInterface.getIdLength(); @@ -138,12 +139,15 @@ * @throws IllegalStateException if the class has already been defined. */ JClassDef generateModel() throws IllegalStateException { - // Add generated annotation - final JType generatedType = $t(Generated.class); - sourceFile._import(generatedType); - classDef.annotate(generatedType) - .value("value", getClass().getName()) - .value("date", JExprs.str(ClassModelHelper.generatedDateValue())); + // Add generated annotation if required + final TypeElement generatedAnnotation = messageInterface.generatedAnnotation(); + if (generatedAnnotation != null) { + final JType generatedType = typeOf(generatedAnnotation.asType()); + sourceFile._import(generatedType); + classDef.annotate(generatedType) + .value("value", getClass().getName()) + .value("date", JExprs.str(ClassModelHelper.generatedDateValue())); + } // Create the default JavaDoc classDef.docComment().text("Warning this class consists of generated code."); @@ -154,14 +158,12 @@ } // Always implement the interface - // TODO - Temporary fix for implementing nested interfaces. - classDef._implements(typeToString(messageInterface.name())); + classDef._implements(typeOf(messageInterface.asType())); //Add implements if (!messageInterface.extendedInterfaces().isEmpty()) { for (MessageInterface intf : messageInterface.extendedInterfaces()) { - // TODO - Temporary fix for implementing nested interfaces. - final JType interfaceName = $t(typeToString(intf.name())); + final JType interfaceName = typeOf(intf.asType()); sourceFile._import(interfaceName); classDef._implements(interfaceName); } @@ -263,7 +265,7 @@ * @return the read resolve method. */ protected JMethodDef createReadResolveMethod() { - final JType type = JTypes.typeOf(classDef); + final JType type = typeOf(classDef); final JVarDeclaration instance = classDef.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, type, INSTANCE_FIELD_NAME, type._new()); final JMethodDef readResolveMethod = classDef.method(JMod.PROTECTED, Object.class, GET_INSTANCE_METHOD_NAME); readResolveMethod.body()._return($v(instance)); @@ -359,7 +361,7 @@ // Split the locale final String[] parts = locale.split("_"); if (parts.length > 3) { - throw new ProcessingException((Element) messageInterface.reference(), "Failed to parse %s to a Locale.", locale); + throw new ProcessingException(messageInterface, "Failed to parse %s to a Locale.", locale); } for (String arg : parts) { newInstance.arg(JExprs.str(arg)); diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ImplementationClassModel.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ImplementationClassModel.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/ImplementationClassModel.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/ImplementationClassModel.java 2017-08-09 18:02:31.000000000 +0000 @@ -27,7 +27,6 @@ import static org.jboss.jdeparser.JMod.FINAL; import static org.jboss.jdeparser.JTypes.$t; import static org.jboss.logging.processor.generator.model.ClassModelHelper.implementationClassName; -import static org.jboss.logging.processor.model.Parameter.ParameterType; import java.text.FieldPosition; import java.text.MessageFormat; @@ -39,10 +38,17 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.processing.Filer; -import javax.lang.model.element.Element; -import javax.lang.model.type.DeclaredType; +import java.util.function.BiFunction; +import java.util.function.Supplier; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.SimpleAnnotationValueVisitor8; +import javax.lang.model.util.Types; import org.jboss.jdeparser.JAssignableExpr; import org.jboss.jdeparser.JBlock; @@ -52,19 +58,28 @@ import org.jboss.jdeparser.JExpr; import org.jboss.jdeparser.JExprs; import org.jboss.jdeparser.JIf; +import org.jboss.jdeparser.JLambda; import org.jboss.jdeparser.JMethodDef; import org.jboss.jdeparser.JMod; import org.jboss.jdeparser.JParamDeclaration; import org.jboss.jdeparser.JType; import org.jboss.jdeparser.JTypes; import org.jboss.jdeparser.JVarDeclaration; +import org.jboss.logging.annotations.Field; +import org.jboss.logging.annotations.Fields; import org.jboss.logging.annotations.Pos; +import org.jboss.logging.annotations.Producer; +import org.jboss.logging.annotations.Properties; +import org.jboss.logging.annotations.Property; +import org.jboss.logging.annotations.Suppressed; import org.jboss.logging.annotations.Transform; import org.jboss.logging.annotations.Transform.TransformType; +import org.jboss.logging.processor.apt.ProcessingException; import org.jboss.logging.processor.model.MessageInterface; import org.jboss.logging.processor.model.MessageMethod; import org.jboss.logging.processor.model.Parameter; import org.jboss.logging.processor.model.ThrowableType; +import org.jboss.logging.processor.util.ElementHelper; /** * An abstract code model to create the source file that implements the @@ -79,16 +94,19 @@ * @author James R. Perkins */ abstract class ImplementationClassModel extends ClassModel { + private final AtomicBoolean messageFormatMethodGenerated = new AtomicBoolean(false); + private final TypeMirror stringType; /** * Class constructor. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. */ - ImplementationClassModel(final Filer filer, final MessageInterface messageInterface) { - super(filer, messageInterface, implementationClassName(messageInterface), null); + ImplementationClassModel(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface) { + super(processingEnv, messageInterface, implementationClassName(messageInterface), null); + stringType = ElementHelper.toType(processingEnv, String.class); } /** @@ -100,16 +118,22 @@ void createBundleMethod(final JClassDef classDef, final JCall localeGetter, final MessageMethod messageMethod) { // Add the message messageMethod. addMessageMethod(messageMethod); - final JType returnType = $t(messageMethod.returnType().name()); - sourceFile._import(returnType); + final TypeMirror returnTypeMirror = messageMethod.returnType().asType(); + final JType returnType = JTypes.typeOf(returnTypeMirror); final JMethodDef method = classDef.method(JMod.PUBLIC | FINAL, returnType, messageMethod.name()); method.annotate(Override.class); addThrownTypes(messageMethod, method); + addMethodTypeParameters(method, returnTypeMirror); + + // If this a declared type we should import it + if (returnTypeMirror.getKind() == TypeKind.DECLARED) { + sourceFile._import(returnType); + } + // Create the body of the method and add the text final JBlock body = method.body(); final MessageMethod.Message message = messageMethod.message(); final JCall formatterCall; - final boolean noFormatParameters = messageMethod.parameters(ParameterType.FORMAT).isEmpty(); switch (message.format()) { case MESSAGE_FORMAT: { @@ -133,7 +157,7 @@ // Create maps for the fields and properties. Key is the field or setter method, value is the parameter to set // the value to. - final Set allParameters = messageMethod.parameters(ParameterType.ANY); + final Set allParameters = messageMethod.parameters(); final Map fields = new LinkedHashMap<>(); final Map properties = new LinkedHashMap<>(); @@ -147,27 +171,9 @@ for (Parameter param : allParameters) { final JParamDeclaration var = addMethodParameter(method, param); final String formatterClass = param.formatterClass(); - switch (param.parameterType()) { - case FORMAT: { - if (formatterCall == null) { - // This should never happen, but let's safe guard against it - throw new IllegalStateException("No format parameters are allowed when NO_FORMAT is specified."); - } else { - if (formatterClass == null) { - if (param.isArray() || param.isVarArgs()) { - final JType arrays = $t(Arrays.class); - sourceFile._import(arrays); - args.add(arrays.call("toString").arg($v(var))); - } else { - args.add($v(var)); - } - } else { - args.add($t(formatterClass)._new().arg($v(var))); - } - } - break; - } - case TRANSFORM: { + if (param.isFormatParameter()) { + boolean added = false; + if (param.isAnnotatedWith(Transform.class)) { if (formatterCall == null) { // This should never happen, but let's safe guard against it throw new IllegalStateException("No format parameters are allowed when NO_FORMAT is specified."); @@ -179,14 +185,14 @@ args.add($t(formatterClass)._new().arg(transformVar)); } } - break; + added = true; } - case POS: { + if (param.isAnnotatedWith(Pos.class)) { if (formatterCall == null) { // This should never happen, but let's safe guard against it throw new IllegalStateException("No format parameters are allowed when NO_FORMAT is specified."); } else { - final Pos pos = param.pos(); + final Pos pos = param.getAnnotation(Pos.class); final int[] positions = pos.value(); final Transform[] transform = pos.transform(); for (int i = 0; i < positions.length; i++) { @@ -207,41 +213,64 @@ } } } - break; - } - case FIELD: { - fields.put(param.targetName(), var); - break; + added = true; } - case PROPERTY: { - properties.put(param.targetName(), var); - break; + if (!added) { + if (formatterCall == null) { + // This should never happen, but let's safe guard against it + throw new ProcessingException(messageMethod, "No format parameters are allowed when NO_FORMAT is specified."); + } else { + if (formatterClass == null) { + if (param.isArray() || param.isVarArgs()) { + final JType arrays = $t(Arrays.class); + sourceFile._import(arrays); + args.add(arrays.call("toString").arg($v(var))); + } else { + args.add($v(var)); + } + } else { + args.add($t(formatterClass)._new().arg($v(var))); + } + } } } + if (param.isAnnotatedWith(Field.class)) { + fields.put(param.targetName(), var); + } + if (param.isAnnotatedWith(Property.class)) { + properties.put(param.targetName(), var); + } } // If a format method, add the arguments for (JExpr arg : args) { formatterCall.arg(arg); } + final boolean isSupplier = messageMethod.returnType().isSubtypeOf(Supplier.class); // Setup the return type final JExpr result; if (messageMethod.returnType().isThrowable()) { - result = $v(createReturnType(messageMethod, body, formatterCall)); + if (isSupplier) { + final JLambda lambda = JExprs.lambda(); + final JBlock lambdaBody = lambda.body(); + lambdaBody._return(createReturnType(messageMethod, lambdaBody, formatterCall, fields, properties)); + result = lambda; + } else { + result = createReturnType(messageMethod, body, formatterCall, fields, properties); + } } else { - result = formatterCall; - } - // Set the fields and properties of the return type - for (Map.Entry entry : fields.entrySet()) { - body.assign(result.field(entry.getKey()), $v(entry.getValue())); - } - for (Map.Entry entry : properties.entrySet()) { - body.add(result.call(entry.getKey()).arg($v(entry.getValue()))); + if (isSupplier) { + final JLambda lambda = JExprs.lambda(); + lambda.body()._return(formatterCall); + result = lambda; + } else { + result = formatterCall; + } } body._return(result); } JAssignableExpr createTransformVar(final List parameterNames, final JBlock methodBody, final Parameter param, final JExpr var) { - return createTransformVar(parameterNames, methodBody, param, param.transform(), var); + return createTransformVar(parameterNames, methodBody, param, param.getAnnotation(Transform.class), var); } JAssignableExpr createTransformVar(final List parameterNames, final JBlock methodBody, final Parameter param, final Transform transform, final JExpr var) { @@ -335,55 +364,140 @@ return result; } - private JVarDeclaration createReturnType(final MessageMethod messageMethod, final JBlock body, final JCall format) { + private void addMethodTypeParameters(final JMethodDef method, final TypeMirror type) { + final Types types = processingEnv.getTypeUtils(); + if (type.getKind() == TypeKind.TYPEVAR) { + // Determine the extended type + final TypeMirror resolved = types.erasure(type); + final JType resolvedType = JTypes.typeOf(resolved); + sourceFile._import(resolvedType); + method.typeParam(type.toString())._extends(resolvedType); + } else if (type.getKind() == TypeKind.DECLARED) { + final List typeArgs = ElementHelper.getTypeArguments(type); + for (TypeMirror typeArg : typeArgs) { + addMethodTypeParameters(method, typeArg); + } + } + } + + private JExpr createReturnType(final MessageMethod messageMethod, final JBlock body, final JCall format, final Map fields, final Map properties) { boolean callInitCause = false; - final ThrowableType returnType = messageMethod.returnType().throwableReturnType(); - final JType type = $t(returnType.name()); - // Import once more as the throwable return type may be different than the actual return type - sourceFile._import(type); - final JCall result = type._new(); - final JVarDeclaration resultField = body.var(FINAL, type, "result", result); - if (returnType.useConstructionParameters()) { - for (Parameter param : returnType.constructionParameters()) { - switch (param.parameterType()) { - case MESSAGE: + final Set producers = messageMethod.parametersAnnotatedWith(Producer.class); + final JType type; + final JVarDeclaration resultField; + + // If there are no producers we need to construct a new return type + if (producers.isEmpty()) { + final ThrowableType returnType = messageMethod.returnType().throwableReturnType(); + type = JTypes.typeOf(returnType.asType()); + // Import once more as the throwable return type may be different than the actual return type + sourceFile._import(type); + final JCall result = type._new(); + resultField = body.var(FINAL, type, "result", result); + if (returnType.useConstructionParameters()) { + for (Parameter param : returnType.constructionParameters()) { + if (param.isMessageMethod()) { result.arg(format); - break; - default: + } else { result.arg($v(param.name())); - break; - + } } - } - } else if (returnType.hasStringAndThrowableConstructor() && messageMethod.hasCause()) { - result.arg(format).arg($v(messageMethod.cause().name())); - } else if (returnType.hasThrowableAndStringConstructor() && messageMethod.hasCause()) { - result.arg($v(messageMethod.cause().name())).arg(format); - } else if (returnType.hasStringConstructor()) { - result.arg(format); - if (messageMethod.hasCause()) { + callInitCause = messageMethod.hasCause() && !returnType.causeSetInConstructor(); + } else if (returnType.hasStringAndThrowableConstructor() && messageMethod.hasCause()) { + result.arg(format).arg($v(messageMethod.cause().name())); + } else if (returnType.hasThrowableAndStringConstructor() && messageMethod.hasCause()) { + result.arg($v(messageMethod.cause().name())).arg(format); + } else if (returnType.hasStringConstructor()) { + result.arg(format); + if (messageMethod.hasCause()) { + callInitCause = true; + } + } else if (returnType.hasThrowableConstructor() && messageMethod.hasCause()) { + result.arg($v(messageMethod.cause().name())); + } else if (returnType.hasStringAndThrowableConstructor() && !messageMethod.hasCause()) { + result.arg(format).arg(NULL); + } else if (returnType.hasThrowableAndStringConstructor() && !messageMethod.hasCause()) { + result.arg(NULL).arg(format); + } else if (messageMethod.hasCause()) { callInitCause = true; } - } else if (returnType.hasThrowableConstructor() && messageMethod.hasCause()) { - result.arg($v(messageMethod.cause().name())); - } else if (returnType.hasStringAndThrowableConstructor() && !messageMethod.hasCause()) { - result.arg(format).arg(NULL); - } else if (returnType.hasThrowableAndStringConstructor() && !messageMethod.hasCause()) { - result.arg(NULL).arg(format); - } else if (messageMethod.hasCause()) { - callInitCause = true; + } else { + final TypeMirror returnType = messageMethod.returnType().resolvedType(); + // Should only be one producer + final Parameter producer = producers.iterator().next(); + type = JTypes.typeOf(returnType); + JCall result = $v(producer.name()).call("apply"); + + // For a BiFunction we pass both the cause, even if null, and the message + if (producer.isSubtypeOf(BiFunction.class)) { + // Get the type arguments of the BiFunction to determine the order to pass parameters + final List typeArguments = ElementHelper.getTypeArguments(producer); + // If we don't have any type arguments assume String, Throwable + if (typeArguments.isEmpty()) { + result = result.arg(format); + result = result.arg($v(messageMethod.cause().name())); + } else { + // Just get the first type argument an decide the order based on it + final TypeMirror typeArg = typeArguments.get(0); + if (processingEnv.getTypeUtils().isAssignable(typeArg, stringType)) { + result = result.arg(format); + if (messageMethod.hasCause()) { + result = result.arg($v(messageMethod.cause().name())); + } else { + result = result.arg(JExpr.NULL); + } + } else { + if (messageMethod.hasCause()) { + result = result.arg($v(messageMethod.cause().name())); + } else { + result = result.arg(JExpr.NULL); + } + result = result.arg(format); + } + } + } else { // Assume this must be a Function + // Pass the message as the argument to the function + result = result.arg(format); + callInitCause = messageMethod.hasCause(); + } + resultField = body.var(FINAL, type, "result", result); } // Assign the result field the result value if (callInitCause) { body.add($v(resultField).call("initCause").arg($v(messageMethod.cause().name()))); } + // Get the @Property or @Properties annotation values + addDefultProperties(messageMethod, ElementHelper.getAnnotations(messageMethod, Properties.class, Property.class), body, $v(resultField), false); + addDefultProperties(messageMethod, ElementHelper.getAnnotations(messageMethod, Fields.class, Field.class), body, $v(resultField), true); + // Remove this caller from the stack trace final JType arrays = $t(Arrays.class); sourceFile._import(arrays); final JVarDeclaration st = body.var(FINAL, $t(StackTraceElement.class).array(), "st", $v(resultField).call("getStackTrace")); body.add($v(resultField).call("setStackTrace").arg(arrays.call("copyOfRange").arg($v(st)).arg(JExpr.ONE).arg($v(st).field("length")))); - return resultField; + + // Add any suppressed messages + final Set suppressed = messageMethod.parametersAnnotatedWith(Suppressed.class); + for (Parameter p : suppressed) { + if (p.isArray() || p.isVarArgs()) { + final String name = String.format("$%sVar", p.name()); + // TODO (jrp) the " " can be removed after an upgrade to JDeparser2; this is a workaround for a formatting bug + body.forEach(0, JTypes.typeOf(((ArrayType) p.asType()).getComponentType()), " " + name, $v(p.name())) + .block(Braces.REQUIRED) + .add($v(resultField).call("addSuppressed").arg($v(name))); + } else if (p.isAssignableFrom(Collection.class)) { + final String name = String.format("$%sVar", p.name()); + body.add($v(p.name()).call("forEach").arg(JExprs.lambda().param(name).body($v(resultField).call("addSuppressed").arg($v(name))))); + } else { + body.add($v(resultField).call("addSuppressed").arg($v(p.name()))); + } + } + // Add the possible fields and properties to be set on the returned exception + final JExpr resultExpr = $v(resultField); + fields.forEach((key, value) -> body.assign(resultExpr.field(key), $v(value))); + properties.forEach((key, value) -> body.add(resultExpr.call(key).arg($v(value)))); + return resultExpr; } protected final void addThrownTypes(final MessageMethod messageMethod, final JMethodDef jMethod) { @@ -401,28 +515,46 @@ * @return the reference to the parameter on the method */ protected JParamDeclaration addMethodParameter(final JMethodDef method, final Parameter param) { - final JParamDeclaration var; - JType paramType = $t(param.type()); + final JType paramType = JTypes.typeOf(param.asType()); if (!param.isPrimitive()) { sourceFile._import(paramType); } if (param.isVarArgs()) { - var = method.varargParam(FINAL, paramType, param.name()); - } else if (param.isArray()) { - var = method.param(JMod.FINAL, paramType.array(), param.name()); - } else { - final TypeMirror t = ((Element) param.reference()).asType(); - if (t instanceof DeclaredType) { - final Collection genericTypes = ((DeclaredType) t).getTypeArguments(); - for (TypeMirror tm : genericTypes) { - final JType gt = JTypes.typeOf(tm); - sourceFile._import(gt); - paramType = paramType.typeArg(gt); + return method.varargParam(FINAL, paramType.elementType(), param.name()); + } + return method.param(FINAL, paramType, param.name()); + } + + private void addDefultProperties(final MessageMethod messageMethod, final Collection annotations, final JBlock body, final JAssignableExpr resultField, final boolean field) { + for (AnnotationMirror propertyAnnotation : annotations) { + String name = null; + AnnotationValue annotationValue = null; + for (Map.Entry entry : propertyAnnotation.getElementValues().entrySet()) { + final ExecutableElement attribute = entry.getKey(); + final AnnotationValue attributeValue = entry.getValue(); + if ("name".contentEquals(attribute.getSimpleName())) { + name = String.valueOf(attributeValue.getValue()); + } else { + annotationValue = attributeValue; } } - var = method.param(FINAL, paramType, param.name()); + if (name == null) { + throw new ProcessingException(messageMethod, propertyAnnotation, "The name attribute is required for the annotation."); + } + if (annotationValue == null || annotationValue.getValue() == null) { + throw new ProcessingException(messageMethod, propertyAnnotation, "A value for one of the default attributes is required."); + } + final JExpr resultValue = annotationValue.accept(JExprAnnotationValueVisitor.INSTANCE, null); + if (resultValue == null) { + final Object value = annotationValue.getValue(); + throw new ProcessingException(messageMethod, propertyAnnotation, annotationValue, "Could not resolve value type for %s (%s)", value, value.getClass()); + } + if (field) { + body.add(resultField.field(name).assign(resultValue)); + } else { + body.add(resultField.call("set" + Character.toUpperCase(name.charAt(0)) + name.substring(1)).arg(resultValue)); + } } - return var; } /** @@ -476,4 +608,60 @@ return JExprs.call(methodName); } + + private static class JExprAnnotationValueVisitor extends SimpleAnnotationValueVisitor8 { + private static final JExprAnnotationValueVisitor INSTANCE = new JExprAnnotationValueVisitor(); + + @Override + public JExpr visitBoolean(final boolean b, final Void v) { + return b ? JExpr.TRUE : JExpr.FALSE; + } + + @Override + public JExpr visitByte(final byte b, final Void v) { + return JExprs.decimal(b).cast(JType.BYTE); + } + + @Override + public JExpr visitChar(final char c, final Void v) { + return JExprs.ch(c); + } + + @Override + public JExpr visitDouble(final double d, final Void v) { + // TODO (jrp) this is fixed in upstream JDeparser, but for now we need to use this + // setterValue = JExprs.hex(d); + return JExprs.$v(String.format("%ad", d)); + } + + @Override + public JExpr visitFloat(final float f, final Void v) { + return JExprs.hex(f); + } + + @Override + public JExpr visitInt(final int i, final Void v) { + return JExprs.decimal(i); + } + + @Override + public JExpr visitLong(final long i, final Void v) { + return JExprs.decimal(i); + } + + @Override + public JExpr visitShort(final short s, final Void v) { + return JExprs.decimal((int) s).cast(JType.SHORT); + } + + @Override + public JExpr visitString(final String s, final Void v) { + return JExprs.str(s); + } + + @Override + public JExpr visitType(final TypeMirror t, final Void v) { + return JExprs.$v(t.toString() + ".class"); + } + } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleImplementor.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleImplementor.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleImplementor.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleImplementor.java 2017-08-09 18:02:31.000000000 +0000 @@ -24,14 +24,16 @@ import java.util.LinkedHashSet; import java.util.Set; -import javax.annotation.processing.Filer; +import javax.annotation.processing.ProcessingEnvironment; import org.jboss.jdeparser.JCall; import org.jboss.jdeparser.JClassDef; import org.jboss.jdeparser.JMod; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.processor.model.MessageInterface; -import org.jboss.logging.processor.model.MessageInterface.AnnotatedType; import org.jboss.logging.processor.model.MessageMethod; +import org.jboss.logging.processor.util.ElementHelper; /** * Used to generate a message bundle implementation. @@ -47,11 +49,11 @@ /** * Creates a new message bundle code model. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. */ - public MessageBundleImplementor(final Filer filer, final MessageInterface messageInterface) { - super(filer, messageInterface); + public MessageBundleImplementor(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface) { + super(processingEnv, messageInterface); } @Override @@ -61,14 +63,12 @@ classDef.constructor(JMod.PROTECTED); createReadResolveMethod(); final JCall localeGetter = createLocaleGetter(null, false); - final Set messageMethods = new LinkedHashSet(); + final Set messageMethods = new LinkedHashSet<>(); messageMethods.addAll(messageInterface().methods()); for (MessageInterface messageInterface : messageInterface().extendedInterfaces()) { - // Handle logger interface - if (messageInterface.getAnnotatedType() == AnnotatedType.NONE) { - continue; + if (messageInterface.isAnnotatedWith(MessageBundle.class) || messageInterface.isAnnotatedWith(MessageLogger.class)) { + messageMethods.addAll(messageInterface.methods()); } - messageMethods.addAll(messageInterface.methods()); } // Process the method descriptors and add to the model before // writing. diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleTranslator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleTranslator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleTranslator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageBundleTranslator.java 2017-08-09 18:02:31.000000000 +0000 @@ -26,7 +26,7 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import javax.annotation.processing.Filer; +import javax.annotation.processing.ProcessingEnvironment; import org.jboss.jdeparser.JClassDef; import org.jboss.jdeparser.JMethodDef; @@ -50,16 +50,15 @@ /** * Create a MessageBundle with super class and interface. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. * @param className the implementation class name. * @param superClassName the super class name * @param locale the locale used to override the default locale * @param translations the translation map. */ - public MessageBundleTranslator(final Filer filer, final MessageInterface messageInterface, final String className, final String superClassName, final String locale, final Map translations) { - super(filer, messageInterface, className, superClassName); - + public MessageBundleTranslator(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface, final String className, final String superClassName, final String locale, final Map translations) { + super(processingEnv, messageInterface, className, superClassName); this.locale = locale; if (translations != null) { this.translations = translations; diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerImplementor.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerImplementor.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerImplementor.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerImplementor.java 2017-08-09 18:02:31.000000000 +0000 @@ -26,7 +26,6 @@ import static org.jboss.jdeparser.JExpr.THIS; import static org.jboss.jdeparser.JExprs.$v; import static org.jboss.jdeparser.JTypes.$t; -import static org.jboss.logging.processor.model.Parameter.ParameterType; import java.util.ArrayList; import java.util.Arrays; @@ -38,7 +37,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import javax.annotation.processing.Filer; +import javax.annotation.processing.ProcessingEnvironment; import org.jboss.jdeparser.JAssignableExpr; import org.jboss.jdeparser.JBlock; @@ -54,12 +53,14 @@ import org.jboss.jdeparser.JVarDeclaration; import org.jboss.logging.DelegatingBasicLogger; import org.jboss.logging.Logger; +import org.jboss.logging.annotations.LoggingClass; import org.jboss.logging.annotations.Message.Format; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.annotations.Once; import org.jboss.logging.annotations.Pos; import org.jboss.logging.annotations.Transform; import org.jboss.logging.processor.model.MessageInterface; -import org.jboss.logging.processor.model.MessageInterface.AnnotatedType; import org.jboss.logging.processor.model.MessageMethod; import org.jboss.logging.processor.model.Parameter; import org.jboss.logging.processor.util.ElementHelper; @@ -84,12 +85,12 @@ /** * Creates a new message logger code model. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. * @param useLogging31 {@code true} to use logging 3.1, {@code false} to remain compatible with 3.0 */ - public MessageLoggerImplementor(final Filer filer, final MessageInterface messageInterface, final boolean useLogging31) { - super(filer, messageInterface); + public MessageLoggerImplementor(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface, final boolean useLogging31) { + super(processingEnv, messageInterface); this.useLogging31 = useLogging31; } @@ -144,18 +145,15 @@ constructorBody.assign(THIS.field(logVar.name()), $v(constructorParam)); logger = $v(logVar); } - final JCall localeGetter = createLocaleGetter(null, false); // Process the method descriptors and add to the model before writing. - final Set messageMethods = new LinkedHashSet(); + final Set messageMethods = new LinkedHashSet<>(); messageMethods.addAll(messageInterface().methods()); for (MessageInterface messageInterface : messageInterface().extendedInterfaces()) { - // Handle logger interface - if (messageInterface.getAnnotatedType() == AnnotatedType.NONE) { - continue; + if (messageInterface.isAnnotatedWith(MessageBundle.class) || messageInterface.isAnnotatedWith(MessageLogger.class)) { + messageMethods.addAll(messageInterface.methods()); } - messageMethods.addAll(messageInterface.methods()); } for (MessageMethod messageMethod : messageMethods) { @@ -424,7 +422,7 @@ // Check for the @Once annotation final JBlock body; - if (ElementHelper.isAnnotatedWith(messageMethod.reference(), Once.class) && messageMethod.isLoggerMethod()) { + if (messageMethod.isAnnotatedWith(Once.class) && messageMethod.isLoggerMethod()) { final JType atomicBoolean = $t(AtomicBoolean.class); sourceFile._import(atomicBoolean); // The variable will be shared with overloaded methods @@ -438,9 +436,9 @@ } body = method.body()._if( logger.call("isEnabled").arg($v(messageMethod.logLevel())).and( - $v(var).call("compareAndSet").arg(JExpr.FALSE).arg(JExpr.TRUE))) + $v(var).call("compareAndSet").arg(JExpr.FALSE).arg(JExpr.TRUE))) .block(Braces.REQUIRED); - } else if (!messageMethod.parameters(ParameterType.TRANSFORM).isEmpty()) { + } else if (!messageMethod.parametersAnnotatedWith(Transform.class).isEmpty()) { body = method.body()._if(logger.call("isEnabled").arg($v(messageMethod.logLevel()))).block(Braces.REQUIRED); } else { body = method.body(); @@ -448,10 +446,11 @@ // Determine which logger method to invoke final JCall logCaller = logger.call(messageMethod.loggerMethod()); - if (messageMethod.parameters(ParameterType.FQCN).isEmpty()) { + final Set fqcnParameters = messageMethod.parametersAnnotatedWith(LoggingClass.class); + if (fqcnParameters.isEmpty()) { logCaller.arg($v(FQCN_FIELD_NAME)); } else { - logCaller.arg($v(params.get(messageMethod.parameters(ParameterType.FQCN).iterator().next())).call("getName")); + logCaller.arg($v(params.get(fqcnParameters.iterator().next())).call("getName")); } // Use static imports for the levels final String levelName = messageMethod.logLevel(); @@ -487,28 +486,20 @@ final Parameter param = entry.getKey(); final String formatterClass = param.formatterClass(); final JParamDeclaration var = entry.getValue(); - switch (param.parameterType()) { - case FORMAT: - if (formatterClass == null) { - if (param.isArray() || param.isVarArgs()) { - args.add($t(Arrays.class).call("toString").arg($v(var))); - } else { - args.add($v(var)); - } - } else { - args.add($t(formatterClass)._new().arg($v(var))); - } - break; - case TRANSFORM: + + boolean added = false; + if (param.isFormatParameter()) { + if (param.isAnnotatedWith(Transform.class)) { final JAssignableExpr transformVar = createTransformVar(parameterNames, body, param, $v(var)); if (formatterClass == null) { args.add(transformVar); } else { args.add($t(formatterClass)._new().arg(transformVar)); } - break; - case POS: - final Pos pos = param.pos(); + added = true; + } + if (param.isAnnotatedWith(Pos.class)) { + final Pos pos = param.getAnnotation(Pos.class); final int[] positions = pos.value(); final Transform[] transform = pos.transform(); for (int i = 0; i < positions.length; i++) { @@ -528,7 +519,20 @@ } } } - break; + added = true; + } + + if (!added) { + if (formatterClass == null) { + if (param.isArray() || param.isVarArgs()) { + args.add($t(Arrays.class).call("toString").arg($v(var))); + } else { + args.add($v(var)); + } + } else { + args.add($t(formatterClass)._new().arg($v(var))); + } + } } } for (JExpr arg : args) { @@ -541,7 +545,7 @@ private Map createParameters(final MessageMethod messageMethod, final JMethodDef method) { final Map result = new LinkedHashMap<>(); // Create the parameters - for (Parameter param : messageMethod.parameters(ParameterType.ANY)) { + for (Parameter param : messageMethod.parameters()) { final JParamDeclaration var = addMethodParameter(method, param); result.put(param, var); } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerTranslator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerTranslator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerTranslator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/generator/model/MessageLoggerTranslator.java 2017-08-09 18:02:31.000000000 +0000 @@ -29,7 +29,7 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import javax.annotation.processing.Filer; +import javax.annotation.processing.ProcessingEnvironment; import org.jboss.jdeparser.JBlock; import org.jboss.jdeparser.JClassDef; @@ -61,16 +61,15 @@ /** * Create a MessageLogger with super class and interface. * - * @param filer the filer used to create the source file + * @param processingEnv the processing environment * @param messageInterface the message interface to implement. * @param className the implementation class name. * @param superClassName the super class name - * @param locale the locale used to override the default locale + * @param locale the locale used to override the default locale * @param translations the translation map. */ - public MessageLoggerTranslator(final Filer filer, final MessageInterface messageInterface, final String className, final String superClassName, final String locale, final Map translations) { - super(filer, messageInterface, className, superClassName); - + public MessageLoggerTranslator(final ProcessingEnvironment processingEnv, final MessageInterface messageInterface, final String className, final String superClassName, final String locale, final Map translations) { + super(processingEnv, messageInterface, className, superClassName); this.locale = locale; if (translations != null) { this.translations = translations; diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/ClassType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/ClassType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/ClassType.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/ClassType.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.model; + +import javax.lang.model.AnnotatedConstruct; + +/** + * Date: 23.08.2011 + * + * @author James R. Perkins + */ +public interface ClassType extends AnnotatedConstruct { + + /** + * Determines if this type is either the same as, or is a supertype of, the class represented by the {@code type} + * parameter. If this type is assignable from the class {@code true} is returned, otherwise {@code false}. + * + * @param type the class type to check. + * + * @return {@code true} if this type is the same as or a superclass of the class, otherwise {@code false}. + */ + boolean isAssignableFrom(Class type); + + /** + * Determines if this type is a subtype of the class represented by the {@code type} parameter. If this type is a + * subtype of the class {@code true} is returned, otherwise {@code false}. + * + * @param type the class type to check. + * + * @return {@code true} if this type is a subtype of the class, otherwise {@code false}. + */ + boolean isSubtypeOf(Class type); + + /** + * Determines if this type is the same type as the class represented by the {@code type} parameter. If this type is + * the same type as the class {@code true} is returned, otherwise {@code false}. + * + * @param type the class type to check. + * + * @return {@code true} if this type is the same type as the class, otherwise {@code false}. + */ + boolean isSameAs(Class type); +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/DelegatingElement.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/DelegatingElement.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/DelegatingElement.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/DelegatingElement.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,111 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.model; + +import java.lang.annotation.Annotation; +import java.util.List; +import java.util.Set; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ElementVisitor; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.Name; +import javax.lang.model.type.TypeMirror; + +/** + * A delegating {@link Element} interface. All methods are invoked on the {@linkplain #getDelegate() delegate element} + * by default. + * + * @author James R. Perkins + */ +public interface DelegatingElement extends Element { + + /** + * The element to delegate the default methods to. + * + * @return the delegate + */ + Element getDelegate(); + + @Override + default TypeMirror asType() { + return getDelegate().asType(); + } + + @Override + default ElementKind getKind() { + return getDelegate().getKind(); + } + + @Override + default Set getModifiers() { + return getDelegate().getModifiers(); + } + + @Override + default Name getSimpleName() { + return getDelegate().getSimpleName(); + } + + @Override + default Element getEnclosingElement() { + return getDelegate().getEnclosingElement(); + } + + @Override + default List getEnclosedElements() { + return getDelegate().getEnclosedElements(); + } + + @Override + default A getAnnotation(final Class annotationType) { + return getDelegate().getAnnotation(annotationType); + } + + @Override + default List getAnnotationMirrors() { + return getDelegate().getAnnotationMirrors(); + } + + @Override + default R accept(final ElementVisitor v, final P p) { + return getDelegate().accept(v, p); + } + + @Override + default A[] getAnnotationsByType(final Class annotationType) { + return getDelegate().getAnnotationsByType(annotationType); + } + + /** + * Checks whether or not the annotation is present on the element. + * + * @param annotation the annotation to check for + * + * @return {@code true} if the annotation is present, otherwise {@code false} + */ + default boolean isAnnotatedWith(Class annotation) { + return getAnnotation(annotation) != null; + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/DelegatingExecutableElement.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/DelegatingExecutableElement.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/DelegatingExecutableElement.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/DelegatingExecutableElement.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,88 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.model; + +import java.util.List; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeParameterElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.TypeMirror; + +/** + * A delegating {@link ExecutableElement} interface. All methods are invoked on the {@linkplain #getDelegate() delegate element} + * by default. + * + * @author James R. Perkins + */ +public interface DelegatingExecutableElement extends ExecutableElement, DelegatingElement { + + @Override + ExecutableElement getDelegate(); + + @Override + default List getTypeParameters() { + return getDelegate().getTypeParameters(); + } + + @Override + default TypeMirror getReturnType() { + return getDelegate().getReturnType(); + } + + @Override + default List getParameters() { + return getDelegate().getParameters(); + } + + @Override + default TypeMirror getReceiverType() { + return getDelegate().getReceiverType(); + } + + @Override + default boolean isVarArgs() { + return getDelegate().isVarArgs(); + } + + @Override + default boolean isDefault() { + return getDelegate().isDefault(); + } + + @Override + default List getThrownTypes() { + return getDelegate().getThrownTypes(); + } + + @Override + default AnnotationValue getDefaultValue() { + return getDelegate().getDefaultValue(); + } + + @Override + default Name getSimpleName() { + return getDelegate().getSimpleName(); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/DelegatingTypeElement.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/DelegatingTypeElement.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/DelegatingTypeElement.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/DelegatingTypeElement.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,83 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.model; + +import java.util.List; +import javax.lang.model.element.Element; +import javax.lang.model.element.Name; +import javax.lang.model.element.NestingKind; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.TypeParameterElement; +import javax.lang.model.type.TypeMirror; + +/** + * A delegating {@link TypeElement} interface. All methods are invoked on the {@linkplain #getDelegate() delegate element} + * by default. + * + * @author James R. Perkins + */ +public interface DelegatingTypeElement extends TypeElement, DelegatingElement { + + @Override + TypeElement getDelegate(); + + @Override + default List getEnclosedElements() { + return getDelegate().getEnclosedElements(); + } + + @Override + default NestingKind getNestingKind() { + return getDelegate().getNestingKind(); + } + + @Override + default Name getQualifiedName() { + return getDelegate().getQualifiedName(); + } + + @Override + default Name getSimpleName() { + return getDelegate().getSimpleName(); + } + + @Override + default TypeMirror getSuperclass() { + return getDelegate().getSuperclass(); + } + + @Override + default List getInterfaces() { + return getDelegate().getInterfaces(); + } + + @Override + default List getTypeParameters() { + return getDelegate().getTypeParameters(); + } + + @Override + default Element getEnclosingElement() { + return getDelegate().getEnclosingElement(); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageInterface.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageInterface.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageInterface.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageInterface.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,11 +22,14 @@ package org.jboss.logging.processor.model; -import java.lang.annotation.Annotation; import java.util.Collection; import java.util.List; +import java.util.Properties; import java.util.Set; +import javax.lang.model.element.TypeElement; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.annotations.ValidIdRange; /** @@ -34,23 +37,7 @@ * * @author James R. Perkins */ -public interface MessageInterface extends Comparable, MessageObject, MessageObjectType, JavaDocComment { - - - public enum AnnotatedType { - /** - * Indicates the interface is annotated with {@code @MessageBundle} - */ - MESSAGE_BUNDLE, - /** - * Indicates the interface is annotated with {@code @MessageLogger} - */ - MESSAGE_LOGGER, - /** - * Indicates the interface is not annotated with {@code MessageBundle} or {@code @MessageLogger} - */ - NONE, - } +public interface MessageInterface extends Comparable, ClassType, JavaDocComment, DelegatingTypeElement { /** * Checks the interface to see if the {@link org.jboss.logging.BasicLogger logger interface} is being extended in @@ -75,10 +62,11 @@ Collection methods(); /** - * The project code for the message interface or {@code null} if {@link #getAnnotatedType()} returns {@link - * AnnotatedType#NONE}. + * The project code for the message interface or {@code null} if not annotated with + * {@link MessageBundle @MessageBundle} or {@link MessageLogger @MessageLogger}. * - * @return the project code or {@code null} if {@link #getAnnotatedType()} returns {@link AnnotatedType#NONE} + * @return the project code or {@code null} if not annotated with + * {@link MessageBundle @MessageBundle} or {@link MessageLogger @MessageLogger} */ String projectCode(); @@ -87,7 +75,6 @@ * * @return the qualified name. */ - @Override String name(); /** @@ -113,13 +100,6 @@ String loggingFQCN(); /** - * Returns the annotation type on the interface. - * - * @return the annotated type - */ - AnnotatedType getAnnotatedType(); - - /** * Returns a list of {@link ValidIdRange valid id ranges}. * * @return a list of valid id ranges or an empty list @@ -134,21 +114,21 @@ int getIdLength(); /** - * Indicates whether or not an annotation is present on the message interface. - * - * @param annotation the annotation to check for + * Returns the type to use for the {@code @Generated} annotation. This may return {@code null} of the implementation + * should not be annotated. * - * @return {@code true} if the annotation is present, otherwise {@code false} + * @return the type for the generated annotation or {@code null} if no annotation is wanted */ - boolean isAnnotatedWith(Class annotation); + default TypeElement generatedAnnotation() { + return null; + } /** - * Returns the annotation present on this interface. If the annotation is not present {@code null} is returned. + * The properties used to resolve expressions. * - * @param annotation the annotation to check for - * @param the annotation type - * - * @return the annotation or {@code null} if the annotation was not present on the interface + * @return the properties used to resolve expressions */ - A getAnnotation(final Class annotation); + default Properties expressionProperties() { + return new Properties(); + } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageMethod.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageMethod.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageMethod.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageMethod.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,46 +22,40 @@ package org.jboss.logging.processor.model; +import java.lang.annotation.Annotation; import java.util.Set; -import javax.lang.model.element.ExecutableElement; - import org.jboss.logging.annotations.Message.Format; -import org.jboss.logging.processor.model.Parameter.ParameterType; /** * Date: 29.07.2011 * * @author James R. Perkins */ -public interface MessageMethod extends Comparable, MessageObject, JavaDocComment { +public interface MessageMethod extends Comparable, JavaDocComment, DelegatingExecutableElement { /** * Returns the method name. * * @return the method name. */ - @Override String name(); /** - * Returns an unmodifiable collection of the parameters specified by the parameter type or an empty set. - * - * @param parameterType the parameter type to look-up the parameters for. + * Returns the parameters for the method. * - * @return a collection of the parameters or an empty set. + * @return the parameters for the method */ - Set parameters(ParameterType parameterType); + Set parameters(); /** * Returns an unmodifiable collection of the parameters specified by the parameter type or an empty set. * - * @param parameterType the parameter type to look-up the parameters for. - * @param parameterTypes an array of types to look-up parameters for. + * @param annotation the annotation to get the parameters for * * @return a collection of the parameters or an empty set. */ - Set parameters(ParameterType parameterType, ParameterType... parameterTypes); + Set parametersAnnotatedWith(Class annotation); /** * Returns the return type for the method. @@ -144,7 +138,7 @@ * Returns the log level parameter associated with the method only if {@link #isLoggerMethod()} returns * {@code true}. * - * @return the log level annotation + * @return the enum name of the {@linkplain org.jboss.logging.Logger.Level log level} */ String logLevel(); @@ -162,13 +156,10 @@ */ boolean isLoggerMethod(); - @Override - ExecutableElement reference(); - /** * Represents a {@link org.jboss.logging.annotations.Message} annotation on a method. */ - public interface Message { + interface Message { /** * The message id for the message to use. Any id less than 0 will be ignored. diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageObject.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageObject.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageObject.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageObject.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.logging.processor.model; - -/** - * A generic interface for returning basic information about parts of a message bundle or message logger interface. - * - * @author James R. Perkins - */ -public interface MessageObject { - - /** - * Returns a name for the object. - *

- * For an interface or class this will return the qualified class name. For a method this will return the name of - * the method. For a parameter the name of the parameter will be returned. - * - * @return the name of the object. - */ - String name(); - - /** - * The object used to extract information for the message logger or message bundle, if applicable. The reference is - * not used for the implementation and is provided for convenience. - *

- * For example, in an annotation processor implementation a {@link javax.lang.model.element.ExecutableElement} - * might be returned. - * - * @return the reference object used to extract information. - */ - Object reference(); -} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageObjectType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageObjectType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/MessageObjectType.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/MessageObjectType.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.logging.processor.model; - -/** - * Date: 23.08.2011 - * - * @author James R. Perkins - */ -public interface MessageObjectType extends MessageObject { - - /** - * Returns the qualified type name of the object. - *

- * Equivalent to {@code Object.class.getName()} - * - * @return the qualified class name. - */ - String type(); - - /** - * Determines if this type is either the same as, or is a supertype of, the class represented by the {@code type} - * parameter. If this type is assignable from the class {@code true} is returned, otherwise {@code false}. - * - * @param type the class type to check. - * - * @return {@code true} if this type is the same as or a superclass of the class, otherwise {@code false}. - */ - boolean isAssignableFrom(Class type); - - /** - * Determines if this type is a subtype of the class represented by the {@code type} parameter. If this type is a - * subtype of the class {@code true} is returned, otherwise {@code false}. - * - * @param type the class type to check. - * - * @return {@code true} if this type is a subtype of the class, otherwise {@code false}. - */ - boolean isSubtypeOf(Class type); - - /** - * Determines if this type is the same type as the class represented by the {@code type} parameter. If this type is - * the same type as the class {@code true} is returned, otherwise {@code false}. - * - * @param type the class type to check. - * - * @return {@code true} if this type is the same type as the class, otherwise {@code false}. - */ - boolean isSameAs(Class type); -} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/Parameter.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/Parameter.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/Parameter.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/Parameter.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,82 +22,16 @@ package org.jboss.logging.processor.model; -import org.jboss.logging.annotations.Pos; -import org.jboss.logging.annotations.Transform; - /** * @author James R. Perkins - 20.Feb.2011 */ -public interface Parameter extends Comparable, MessageObjectType { - - /** - * The types of parameters. - */ - public enum ParameterType { - /** - * Indicates the parameter can be any other type. All parameters fall under this category. - */ - ANY, - /** - * Indicates the parameter is a cause parameter and needs to be set in the {@link Throwable throwable} return - * type. - */ - CAUSE, - /** - * Indicates the parameter should be used as a format parameter. - */ - FORMAT, - /** - * Indicates the parameter should be used as the fully qualified class name for the logger. - */ - FQCN, - /** - * Indicates the parameter is the message. - */ - MESSAGE, - /** - * Indicates the parameter should be used in the construction of a {@link Throwable throwable} return type. - */ - CONSTRUCTION, - /** - * Indicates the parameter is a instance field that should be set in the {@link Throwable throwable} return - * type. - */ - FIELD, - /** - * Indicates the parameter is a property and should be set via its setter in the {@link Throwable throwable} - * return type. - */ - PROPERTY, - - /** - * Transforms the parameter using the {@link org.jboss.logging.annotations.Transform.TransformType transform - * type}. - */ - TRANSFORM, - - /** - * Indicates the parameter is a positional parameter. - */ - POS, - } - - /** - * The full type name of the parameter. For example - * {@code java.lang.String} if the parameter is a string. If the - * parameter is a primitive, the primitive name is returned. - * - * @return the qualified type of the parameter. - */ - @Override - String type(); +public interface Parameter extends Comparable, ClassType, DelegatingElement { /** * The variable name of the parameter. * * @return the variable name of the parameter. */ - @Override String name(); /** @@ -122,58 +56,37 @@ boolean isVarArgs(); /** - * Returns the {@link ParameterType parameter type} of the parameter. + * Indicates whether or not the parameter is used a format parameter for the message. * - * @return the parameter type of the parameter. + * @return {@code true} if this parameter that should used as a format parameter for the message */ - ParameterType parameterType(); + default boolean isFormatParameter() { + return true; + } /** - * The formatter class, or {@code null} if there is none. + * Indicates whether or not this parameter represents the message method. * - * @return the formatter class + * @return {@code true} if this is the message method parameter */ - String formatterClass(); + default boolean isMessageMethod() { + return false; + } /** - * Returns the class if the parameter is annotated with {@link org.jboss.logging.annotations.Param}. - * If the annotation is not present, {@code null} is returned. + * The formatter class, or {@code null} if there is none. * - * @return the parameter class or {@code null}. + * @return the formatter class */ - Class paramClass(); + String formatterClass(); /** - * Returns the name of the target field or method. For example if the {@link #parameterType()} returns - * {@link ParameterType#FIELD}, the target name is the name of the field to set on the + * Returns the name of the target field or method. For example if the parameter is annotated with + * {@link org.jboss.logging.annotations.Field @Field} the target name is the name of the field to set on the * {@link org.jboss.logging.processor.model.ReturnType return type}. If no target name is defined an empty String - * is - * returned. + * is returned. * * @return the target field name, method name or an empty string. */ String targetName(); - - /** - * The transform type if this the {@link #parameterType()} is {@link ParameterType#TRANSFORM}. - * - * @return the transform annotation or {@code null} if not a transform parameter - */ - Transform transform(); - - /** - * The position annotation if this the {@link #parameterType()} is {@link ParameterType#POS}. - *

- * This works the same way the {@link java.util.Formatter formatter} positional characters work. - *

- *

-     *      String.format("Numeric value %1$d (%1$x)");
-     *
-     *      @Message(""Numeric value %d (%x)"")
-     *      void logNumericValue(@Pos(1) int value);
-     * 
- * - * @return the position annotation or {@code null} if not a position parameter - */ - Pos pos(); } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/ReturnType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/ReturnType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/ReturnType.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/ReturnType.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,62 +22,34 @@ package org.jboss.logging.processor.model; -import static org.jboss.logging.processor.util.Objects.HashCodeBuilder; -import static org.jboss.logging.processor.util.Objects.ToStringBuilder; -import static org.jboss.logging.processor.util.Objects.areEqual; +import java.util.List; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.TypeMirror; + +import org.jboss.logging.processor.util.ElementHelper; /** * Date: 29.07.2011 * * @author James R. Perkins */ -public interface ReturnType extends MessageObject, MessageObjectType { - - public static final ReturnType VOID = new VoidReturnType(); - - /** - * Checks to see if the return type has a field with the name with the same name and type as the - * {@link Parameter parameter}. - * - * @param parameter the parameter to check. - * - * @return {@code true} if the field exists, is accessible, mutable and is assignable from the type otherwise - * {@code false}. - */ - boolean hasFieldFor(final Parameter parameter); +public interface ReturnType extends ClassType, DelegatingElement { /** - * Checks to see if the return type has a method with the name with the same name and parameter type as the - * {@link Parameter parameter}. - * - * @param parameter the parameter to check. + * Checks to see if the return type is an exception, extends Throwable or the value of a + * {@link java.util.function.Supplier} is a Throwable type. * - * @return {@code true} if the method exists, is accessible and its parameter is assignable from the type, otherwise - * {@code false}. - */ - boolean hasMethodFor(final Parameter parameter); - - /** - * Checks to see if the return type is an exception, extends Throwable. + * @return {@code true} if the return type is an exception, otherwise {@code false}. * - * @return {@code true} if the return type is an exception, otherwise - * {@code false}. + * @see #resolvedType() */ boolean isThrowable(); /** - * Indicates whether or not the return type is a primitive. - * - * @return {@code true} if a primitive, otherwise {@code false}. - */ - boolean isPrimitive(); - - /** * Returns the qualified class name of the return type. * * @return the qualified class name fo the return type. */ - @Override String name(); /** @@ -89,88 +61,22 @@ ThrowableType throwableReturnType(); /** - * Default type if the return type is void. - */ - final static class VoidReturnType implements ReturnType { - - private VoidReturnType() { - } - - @Override - public boolean hasFieldFor(final Parameter parameter) { - return false; - } - - @Override - public boolean hasMethodFor(final Parameter parameter) { - return false; - } - - @Override - public boolean isThrowable() { - return false; - } - - @Override - public boolean isPrimitive() { - return false; - } - - @Override - public String name() { - return "void"; - } - - @Override - public ThrowableType throwableReturnType() { - return null; - } - - @Override - public int hashCode() { - return HashCodeBuilder.builder().add(name()).toHashCode(); - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof VoidReturnType)) { - return false; - } - final VoidReturnType other = (VoidReturnType) obj; - return areEqual(this.name(), other.name()); - } - - @Override - public String toString() { - return ToStringBuilder.of(this).add(name()).toString(); - } - - @Override - public Class reference() { - return Void.TYPE; - } - - @Override - public String type() { - return "void"; - } - - @Override - public boolean isAssignableFrom(final Class type) { - return type.equals(Void.TYPE); - } - - @Override - public boolean isSubtypeOf(final Class type) { - return false; - } - - @Override - public boolean isSameAs(final Class type) { - return type.equals(Void.TYPE); + * Checks this {@linkplain #asType() type} to see if there are any + * {@linkplain DeclaredType#getTypeArguments() type arguments}. If any type arguments are found the first type is + * returned and assumed to be the resolved type. Otherwise this {@linkplain #asType() type} is returned. + *

+ * This is useful for the {@link java.util.function.Supplier Supplier} return type. + *

+ * + * @return the resolved return type + */ + default TypeMirror resolvedType() { + final TypeMirror type = asType(); + final List typeArgs = ElementHelper.getTypeArguments(type); + if (typeArgs.isEmpty()) { + return type; } + // Assume the first type only + return typeArgs.get(0); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/ThrowableType.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/ThrowableType.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/model/ThrowableType.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/model/ThrowableType.java 2017-08-09 18:02:31.000000000 +0000 @@ -29,7 +29,7 @@ * * @author James R. Perkins */ -public interface ThrowableType extends MessageObject, MessageObjectType, Comparable { +public interface ThrowableType extends ClassType, Comparable, DelegatingElement { /** * Checks to see the throwable has a default constructor. @@ -78,6 +78,16 @@ boolean useConstructionParameters(); /** + * Indicates whether or not the {@linkplain org.jboss.logging.annotations.Cause cause} was set in the constructor. + * + * @return {@code true} if the cause was set in the constructor, {@code false} if the + * {@link Throwable#initCause(Throwable)} should be executed + */ + default boolean causeSetInConstructor() { + return false; + } + + /** * The parameters needed to construct the throwable, if not using the default constructor. If the default * constructor should be used an empty set should be returned. *

@@ -100,6 +110,5 @@ * * @return the qualified class name fo the return type. */ - @Override String name(); } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/ElementHelper.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/ElementHelper.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/ElementHelper.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/ElementHelper.java 2017-08-09 18:02:31.000000000 +0000 @@ -28,21 +28,19 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.AnnotatedConstruct; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.Name; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.DeclaredType; - -import org.jboss.logging.annotations.Cause; -import org.jboss.logging.annotations.Field; -import org.jboss.logging.annotations.Message; -import org.jboss.logging.annotations.Param; -import org.jboss.logging.annotations.Property; -import org.jboss.logging.processor.model.MessageObject; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; /** * An utility class to work with element. @@ -59,211 +57,49 @@ } /** - * Check if an element is annotated with the given annotation. + * Returns the type arguments for the element. If the elements {@linkplain Element#asType() type} is not a + * {@link DeclaredType} or the element does not have any type arguments an empty list is returned. * - * @param element the element to look for the annotation on. - * @param clazz the annotation class + * @param element the element to get the type arguments for * - * @return {@code true} if the element is annotated, otherwise {@code false} - * - * @throws IllegalArgumentException if element parameter is null + * @return the type arguments or an empty list */ - public static boolean isAnnotatedWith(final Element element, final Class clazz) { - if (element == null) { - throw new IllegalArgumentException("The element parameter is null"); - } - - Annotation annotation = element.getAnnotation(clazz); - return (annotation != null); - } - - /** - * Returns the primary class simple name prefix for an element - * who represents a MessageBundle or MessageLogger interface. - * - * @param element the element - * - * @return the translation file name prefix - * - * @throws IllegalArgumentException if element is null or the element is not an interface - */ - public static String getPrimaryClassNamePrefix(final TypeElement element) { - if (element == null) { - throw new IllegalArgumentException("The element parameter cannot be null"); - } - if (!element.getKind().isInterface()) { - throw new IllegalArgumentException("The element parameter is not an interface"); - } - - String translationFileName = element.getSimpleName().toString(); - - //Check if it's an inner interface - Element enclosingElt = element.getEnclosingElement(); - while (enclosingElt != null && enclosingElt instanceof TypeElement) { - translationFileName = String.format("%s$%s", enclosingElt.getSimpleName().toString(), translationFileName); - enclosingElt = enclosingElt.getEnclosingElement(); - } - - return translationFileName; - } - - - /** - * Returns a collection of methods with the same name. - * - * @param methods the methods to process. - * @param methodName the method name to find. - * - * @return a collection of methods with the same name. - */ - public static Collection findByName(final Collection methods, final Name methodName) { - final List result = new ArrayList(); - for (ExecutableElement method : methods) { - if (methodName.equals(method.getSimpleName())) { - result.add(method); - } - } - return result; - } - - - /** - * Returns a collection of methods with the same name. - * - * @param methods the methods to process. - * @param methodName the method name to find. - * @param paramCount the number of parameters the method must have. - * - * @return a collection of methods with the same name. - */ - public static Collection findByName(final Collection methods, final Name methodName, final int paramCount) { - final List result = new ArrayList(); - for (ExecutableElement method : methods) { - if (methodName.equals(method.getSimpleName()) && parameterCount(method.getParameters()) == paramCount) { - result.add(method); - } - } - return result; + public static List getTypeArguments(final Element element) { + return getTypeArguments(element.asType()); } /** - * Checks to see if there is a cause parameter. + * Returns the type arguments for the type. If the type is not a {@link DeclaredType} or the type does not have any + * type arguments an empty list is returned. * - * @param params the parameters to check. + * @param type the type to get the type arguments for * - * @return {@code true} if there is a cause, otherwise {@code false}. + * @return the type arguments or an empty list */ - public static boolean hasCause(final Collection params) { - // Look for cause - for (VariableElement param : params) { - if (isAnnotatedWith(param, Cause.class)) { - return true; - } + public static List getTypeArguments(final TypeMirror type) { + if (type instanceof DeclaredType) { + return ((DeclaredType) type).getTypeArguments(); } - return false; + return Collections.emptyList(); } /** - * Returns the number of parameters excluding the {@link org.jboss.logging.annotations.Cause} parameter - * and any {@link org.jboss.logging.annotations.Param} parameters if found. + * Check if an element is annotated with the given annotation. * - * @param params the parameters to get the count for. + * @param annotatedConstruct the object to look for the annotation on. + * @param clazz the annotation class * - * @return the number of parameters. - */ - public static int parameterCount(final Collection params) { - int result = params.size(); - for (VariableElement param : params) { - if (isAnnotatedWith(param, Param.class) || isAnnotatedWith(param, Field.class) || - isAnnotatedWith(param, Property.class)) { - --result; - } - } - return (result - (hasCause(params) ? 1 : 0)); - } - - /** - * Checks to see if the method has or inherits a {@link org.jboss.logging.annotations.Message} - * annotation. - * - * @param methods the method to search. - * @param method the method to check. + * @return {@code true} if the element is annotated, otherwise {@code false} * - * @return {@code true} if the method has or inherits a message annotation, otherwise {@code false}. + * @throws IllegalArgumentException if element parameter is null */ - public static boolean inheritsMessage(final Collection methods, final ExecutableElement method) { - if (isAnnotatedWith(method, Message.class)) { - return false; - } - final Collection allMethods = findByName(methods, method.getSimpleName()); - for (ExecutableElement m : allMethods) { - if (isAnnotatedWith(m, Message.class)) { - return true; - } - } - return false; - } - - /** - * Checks to see if the method is overloaded. An overloaded method has a different parameter count based on the - * format parameters only. Parameters annotated with {@link org.jboss.logging.annotations.Cause} or - * {@link org.jboss.logging.annotations.Param} - * are not counted. - * - * @param methods the method to search. - * @param method the method to check. - * - * @return {@code true} if the method is overloaded, otherwise {@code false}. - */ - public static boolean isOverloaded(final Collection methods, final ExecutableElement method) { - final Collection allMethods = findByName(methods, method.getSimpleName()); - for (ExecutableElement m : allMethods) { - if (method.getSimpleName().equals(m.getSimpleName()) && parameterCount(method.getParameters()) != parameterCount(m.getParameters())) { - return true; - } + public static boolean isAnnotatedWith(final AnnotatedConstruct annotatedConstruct, final Class clazz) { + if (annotatedConstruct == null) { + throw new IllegalArgumentException("The element parameter is null"); } - return false; - } - - /** - * Converts a class type to a string recognizable by the - * {@link javax.lang.model.util.Elements#getTypeElement(CharSequence)}. Essentially replaces any {@literal $}'s to - * {@literal .} (dots). - * - * @param type the type to convert. - * - * @return the qualified name of the type. - */ - public static String typeToString(final Class type) { - return typeToString(type.getName()); - } - /** - * Converts a qualified type name to a string recognizable by the - * {@link javax.lang.model.util.Elements#getTypeElement(CharSequence)}. Essentially replaces any {@literal $}'s to - * {@literal .} (dots). - * - * @param qualifiedType the qualified type name. - * - * @return the qualified name of the type. - */ - public static String typeToString(final String qualifiedType) { - return qualifiedType.replace("$", "."); - } - - /** - * If the {@link org.jboss.logging.processor.model.MessageObject#reference()} is an instance of {@link - * Element}, then the value is returned, otherwise {@code null} is returned. - * - * @param object the object to check the reference on - * - * @return the element reference or {@code null} - */ - public static Element fromMessageObject(final MessageObject object) { - if (object.reference() instanceof Element) { - return (Element) object.reference(); - } - return null; + Annotation annotation = annotatedConstruct.getAnnotation(clazz); + return (annotation != null); } /** @@ -296,6 +132,7 @@ * @return a {@link TypeElement} representing the value for the annotation attribute or {@code null} if the * attribute was not found */ + @SuppressWarnings({"StaticMethodOnlyUsedInOneClass", "SameParameterValue"}) public static TypeElement getClassAnnotationValue(final Element element, final Class annotation, final String attributeName) { for (AnnotationMirror mirror : element.getAnnotationMirrors()) { final DeclaredType annotationType = mirror.getAnnotationType(); @@ -318,9 +155,9 @@ * @param annotation the annotation to get the value from * @param attributeName the name of the attribute to retrieve the class value array for * - * @return a list of {@link TypeElement} representing the value for the annotation attribute or an empty list + * @return a list of {@link TypeMirror} representing the value for the annotation attribute or an empty list */ - public static List getClassArrayAnnotationValue(final Element element, final Class annotation, final String attributeName) { + public static List getClassArrayAnnotationValue(final Element element, final Class annotation, @SuppressWarnings("SameParameterValue") final String attributeName) { for (AnnotationMirror mirror : element.getAnnotationMirrors()) { final DeclaredType annotationType = mirror.getAnnotationType(); if (annotationType.toString().equals(annotation.getName())) { @@ -329,9 +166,9 @@ if (key.getSimpleName().contentEquals(attributeName)) { @SuppressWarnings("unchecked") final List annotationValues = (List) map.get(key).getValue(); - final List result = new ArrayList<>(annotationValues.size()); + final List result = new ArrayList<>(annotationValues.size()); for (AnnotationValue value : annotationValues) { - result.add((TypeElement) ((DeclaredType) value.getValue()).asElement()); + result.add((TypeMirror) value.getValue()); } return result; } @@ -340,4 +177,141 @@ } return Collections.emptyList(); } + + /** + * Returns annotations that are associated with the element that match the {@code annotation} parameter type. If the + * {@code groupedAnnotation} is not {@code null} then any repeated annotations that math the {@code annotation} + * parameter type are also returned. + *

+ *

+ * The {@code groupedAnnotation} must have a value attribute that includes an array of annotations that math the + * {@code annotation} parameter type. + *

+ * + * @param element the element to search for annotations + * @param groupedAnnotation the grouped annotation, e.g. collector for repeatable annotations, or {@code null} if not a repeatable annotation + * @param annotation the annotation to search for + * + * @return a collection matched annotations + */ + public static Collection getAnnotations(final Element element, final Class groupedAnnotation, final Class annotation) { + final Collection result = new ArrayList<>(); + final List annotations = element.getAnnotationMirrors(); + for (AnnotationMirror annotationMirror : annotations) { + if (isSameType(groupedAnnotation, annotationMirror.getAnnotationType())) { + result.addAll(getContainingAnnotations(annotationMirror)); + } else if (isSameType(annotation, annotationMirror.getAnnotationType())) { + result.add(annotationMirror); + } + } + return result; + } + + /** + * Checks whether or not a constructor matching the parameters exists. + * + * @param types the type utility used to compare the type arguments + * @param element the element that contains the constructors + * @param args the arguments the constructor should match + * + * @return {@code true} if a matching constructor was found otherwise {@code false} + */ + public static boolean hasConstructor(final Types types, final Element element, final List args) { + final int len = args.size(); + final List constructors = ElementFilter.constructorsIn(element.getEnclosedElements()); + for (ExecutableElement constructor : constructors) { + final List parameters = constructor.getParameters(); + if (len == parameters.size()) { + boolean match = false; + for (int i = 0; i < len; i++) { + final TypeMirror type = args.get(i); + final VariableElement parameter = parameters.get(i); + if (types.isSameType(type, parameter.asType())) { + match = true; + } else { + match = false; + break; + } + } + if (match) { + return true; + } + } + } + return false; + } + + /** + * Returns the type as a {@link TypeMirror}. + * + * @param processingEnv the processing environment to get the elements utility + * @param type the type to create the {@link TypeMirror} for + * + * @return the type + */ + public static TypeElement toTypeElement(final ProcessingEnvironment processingEnv, final Class type) { + return toTypeElement(processingEnv.getElementUtils(), type); + } + + /** + * Returns the type as a {@link TypeMirror}. + * + * @param elements the element utility used to generate the tye type + * @param type the type to create the {@link TypeMirror} for + * + * @return the type + */ + public static TypeElement toTypeElement(final Elements elements, final Class type) { + return elements.getTypeElement(type.getCanonicalName()); + } + + /** + * Returns the type as a {@link TypeMirror}. + * + * @param processingEnv the processing environment to get the elements utility + * @param type the type to create the {@link TypeMirror} for + * + * @return the type + */ + public static TypeMirror toType(final ProcessingEnvironment processingEnv, final Class type) { + return toType(processingEnv.getElementUtils(), type); + } + + /** + * Returns the type as a {@link TypeMirror}. + * + * @param elements the element utility used to generate the tye type + * @param type the type to create the {@link TypeMirror} for + * + * @return the type + */ + public static TypeMirror toType(final Elements elements, final Class type) { + return toTypeElement(elements, type).asType(); + } + + private static boolean isSameType(final Class c, final TypeMirror type) { + return c != null && c.getCanonicalName().equals(type.toString()); + } + + @SuppressWarnings("unchecked") + private static Collection getContainingAnnotations(final AnnotationMirror annotation) { + final Collection result = new ArrayList<>(); + // Return any child annotations + final Map childAnnotations = annotation.getElementValues(); + childAnnotations.entrySet().stream().filter(entry -> entry.getKey().getSimpleName().contentEquals("value")).forEach(entry -> { + final Object value = entry.getValue().getValue(); + if (value instanceof List) { + final List values = (List) value; + for (AnnotationValue subValue : values) { + if (subValue instanceof AnnotationMirror) { + result.add((AnnotationMirror) subValue); + } else { + result.add((AnnotationMirror) subValue.getValue()); + } + } + } + }); + + return result; + } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/Expressions.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/Expressions.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/Expressions.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/Expressions.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,151 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.util; + +import java.util.Properties; + +/** + * @author James R. Perkins + */ +public class Expressions { + + private static final int INITIAL = 0; + private static final int GOT_DOLLAR = 1; + private static final int GOT_OPEN_BRACE = 2; + private static final int RESOLVED = 3; + private static final int DEFAULT = 4; + + public static String resolve(final Properties props, final String expression) { + if (expression == null) return null; + final StringBuilder builder = new StringBuilder(); + final char[] chars = expression.toCharArray(); + final int len = chars.length; + int state = 0; + int start = -1; + int nameStart = -1; + for (int i = 0; i < len; i++) { + char ch = chars[i]; + switch (state) { + case INITIAL: { + switch (ch) { + case '$': { + state = GOT_DOLLAR; + continue; + } + default: { + builder.append(ch); + continue; + } + } + // not reachable + } + case GOT_DOLLAR: { + switch (ch) { + case '$': { + builder.append(ch); + state = INITIAL; + continue; + } + case '{': { + start = i + 1; + nameStart = start; + state = GOT_OPEN_BRACE; + continue; + } + default: { + // invalid; emit and resume + builder.append('$').append(ch); + state = INITIAL; + continue; + } + } + // not reachable + } + case GOT_OPEN_BRACE: { + switch (ch) { + case ':': + case '}': + case ',': { + final String name = expression.substring(nameStart, i).trim(); + final String val; + if (name.startsWith("env.")) { + val = System.getenv(name.substring(4)); + } else if (name.startsWith("sys.")) { + val = System.getProperty(name.substring(4)); + } else { + val = props.getProperty(name); + } + if (val != null) { + builder.append(val); + state = ch == '}' ? INITIAL : RESOLVED; + continue; + } else if (ch == ',') { + nameStart = i + 1; + continue; + } else if (ch == ':') { + start = i + 1; + state = DEFAULT; + continue; + } else { + builder.append(expression.substring(start - 2, i + 1)); + state = INITIAL; + continue; + } + } + default: { + continue; + } + } + // not reachable + } + case RESOLVED: { + if (ch == '}') { + state = INITIAL; + } + continue; + } + case DEFAULT: { + if (ch == '}') { + state = INITIAL; + builder.append(expression.substring(start, i)); + } + continue; + } + default: + throw new IllegalStateException(); + } + } + switch (state) { + case GOT_DOLLAR: { + builder.append('$'); + break; + } + case DEFAULT: + case GOT_OPEN_BRACE: { + builder.append(expression.substring(start - 2)); + break; + } + } + return builder.toString(); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/Objects.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/Objects.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/Objects.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/Objects.java 2017-08-09 18:02:31.000000000 +0000 @@ -369,7 +369,7 @@ */ public static class ToStringBuilder { - private final List fieldValue = new ArrayList(); + private final List fieldValue = new ArrayList<>(); private final String className; diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/Strings.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/Strings.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/Strings.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/Strings.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.logging.processor.util; - -/** - * Date: 19.09.2011 - * - * @author James R. Perkins - */ -public class Strings { - private Strings() { - } - - /** - * Creates a string filled with the with the value of the {@code filler} parameter with a length defined by the - * {@code len} parameter. - * - * @param filler the filler character. - * @param len the length to fill. - * - * @return the generated string. - */ - public static String fill(final char filler, final int len) { - final StringBuilder result = new StringBuilder(len); - for (int i = 0; i < len; i++) { - result.append(filler); - } - return result.toString(); - } - - - /** - * Creates a string filled with the with the value of the {@code filler} parameter with a length defined by the - * {@code len} parameter. - * - * @param filler the filler sequence. - * @param len the length to fill. - * - * @return the generated string. - */ - public static String fill(final CharSequence filler, final int len) { - final StringBuilder result = new StringBuilder((filler.length() * len)); - for (int i = 0; i < len; i++) { - result.append(filler); - } - return result.toString(); - } -} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/VersionComparator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/VersionComparator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/util/VersionComparator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/util/VersionComparator.java 2017-08-09 18:02:31.000000000 +0000 @@ -77,7 +77,7 @@ } private static List convert(final String[] version, final int len) { - final List result = new ArrayList(len); + final List result = new ArrayList<>(len); for (int i = 0; i < len; i++) { if (i < version.length) { final String s = version[i]; diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/IdLengthValidator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/IdLengthValidator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/IdLengthValidator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/IdLengthValidator.java 2017-08-09 18:02:31.000000000 +0000 @@ -36,10 +36,10 @@ * @author James R. Perkins */ public class IdLengthValidator { - private final Map lengths = new HashMap(); + private final Map lengths = new HashMap<>(); public Collection validate(final MessageInterface messageInterface) { - final List messages = new LinkedList(); + final List messages = new LinkedList<>(); final String projectCode = messageInterface.projectCode(); final int idLength = messageInterface.getIdLength(); if ((idLength > 0 && idLength < 3) || idLength > 8) { diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/IdRangeValidator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/IdRangeValidator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/IdRangeValidator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/IdRangeValidator.java 2017-08-09 18:02:31.000000000 +0000 @@ -41,10 +41,10 @@ */ public class IdRangeValidator { - private final Map> processed = new HashMap>(); + private final Map> processed = new HashMap<>(); public Collection validate(final MessageInterface messageInterface) { - final List messages = new LinkedList(); + final List messages = new LinkedList<>(); for (ValidIdRange validIdRange : messageInterface.validIdRanges()) { if (validIdRange.min() > validIdRange.max()) { messages.add(createError(messageInterface, "Minimum id value (%d) cannot be greater than the maximum value (%d).", @@ -75,7 +75,7 @@ } private Map findAll(final MessageInterface messageInterface) { - final Map result = new HashMap(); + final Map result = new HashMap<>(); for (ValidIdRange validIdRange : messageInterface.validIdRanges()) { result.put(validIdRange, messageInterface); } @@ -93,7 +93,7 @@ if (processed.containsKey(projectCode)) { return processed.get(projectCode); } - final Map result = new HashMap(); + final Map result = new HashMap<>(); processed.put(projectCode, result); return result; } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/MessageFormatValidator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/MessageFormatValidator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/MessageFormatValidator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/MessageFormatValidator.java 2017-08-09 18:02:31.000000000 +0000 @@ -40,8 +40,8 @@ class MessageFormatValidator extends AbstractFormatValidator { public static final Pattern PATTERN = Pattern.compile("\\{}|\\{.+?}"); - private final Set formatParts = new TreeSet(); - private final Set formats = new TreeSet(); + private final Set formatParts = new TreeSet<>(); + private final Set formats = new TreeSet<>(); private int argumentCount; private boolean valid; private final String format; @@ -145,7 +145,7 @@ break; } } - final Set counted = new HashSet(); + final Set counted = new HashSet<>(); // Initialize the argument count for (MessageFormatPart messageFormatPart : formats) { if (messageFormatPart.index() >= 0) { diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/MessageIdValidator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/MessageIdValidator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/MessageIdValidator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/MessageIdValidator.java 2017-08-09 18:02:31.000000000 +0000 @@ -44,13 +44,13 @@ */ public final class MessageIdValidator { - private final Map usedMessageIds = new HashMap(); + private final Map usedMessageIds = new HashMap<>(); MessageIdValidator() { } public Collection validate(final MessageInterface messageInterface, final MessageMethod messageMethod) { - final List messages = new LinkedList(); + final List messages = new LinkedList<>(); final MessageMethod.Message message = messageMethod.message(); if (message == null) { messages.add(createError(messageMethod, "No message annotation found.")); diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/PropertyValidator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/PropertyValidator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/PropertyValidator.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/PropertyValidator.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,280 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.validation; + +import static org.jboss.logging.processor.validation.ValidationMessageFactory.createError; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.ElementFilter; +import javax.lang.model.util.Elements; +import javax.lang.model.util.SimpleAnnotationValueVisitor8; +import javax.lang.model.util.Types; + +import org.jboss.logging.annotations.Field; +import org.jboss.logging.annotations.Fields; +import org.jboss.logging.annotations.Properties; +import org.jboss.logging.annotations.Property; +import org.jboss.logging.processor.model.MessageMethod; +import org.jboss.logging.processor.model.Parameter; +import org.jboss.logging.processor.util.ElementHelper; + +/** + * Validates property annotations on methods. + *

+ * Valid property annotations are: + *

    + *
  • {@link Properties}
  • + *
  • {@link Property}
  • + *
  • {@link Fields}
  • + *
  • {@link Field}
  • + *
+ *

+ * + * @author James R. Perkins + */ +class PropertyValidator { + private static final List> VALIDATING_ANNOTATIONS = Arrays.asList(Properties.class, Property.class, Fields.class, Field.class); + private final Elements elements; + private final Types types; + private final MessageMethod method; + private final TypeMirror resultType; + private final Collection messages; + + private PropertyValidator(final ProcessingEnvironment processingEnv, final MessageMethod method, final TypeMirror resultType, final Collection messages) { + elements = processingEnv.getElementUtils(); + types = processingEnv.getTypeUtils(); + this.method = method; + this.resultType = resultType; + this.messages = messages; + } + + /** + * Validates the message method property annotations. + * + * @param processingEnv the annotation processing environment + * @param messageMethod the method to validate + * + * @return a collection of validation messages + */ + static Collection validate(final ProcessingEnvironment processingEnv, final MessageMethod messageMethod) { + boolean continueValidation = !(messageMethod.parametersAnnotatedWith(Field.class).isEmpty() && messageMethod.parametersAnnotatedWith(Property.class).isEmpty()); + for (Class annotation : VALIDATING_ANNOTATIONS) { + if (messageMethod.isAnnotatedWith(annotation)) { + continueValidation = true; + break; + } + } + if (continueValidation) { + // Use the resolved return type to validate if parameters can be assigned to the type + final TypeMirror returnType = processingEnv.getTypeUtils().erasure(messageMethod.returnType().resolvedType()); + final List result = new ArrayList<>(); + if (returnType.getKind() == TypeKind.DECLARED) { + final PropertyValidator validator = new PropertyValidator(processingEnv, messageMethod, returnType, result); + validator.validate(); + } else { + result.add(createError(messageMethod, "The return type is invalid for property annotations.")); + } + return result; + } + return Collections.emptyList(); + } + + private void validate() { + final Map> fields = new HashMap<>(); + final Map> methods = new HashMap<>(); + final TypeElement e = (TypeElement) types.asElement(resultType); + for (ExecutableElement executableElement : ElementFilter.methodsIn(elements.getAllMembers(e))) { + if (executableElement.getModifiers().contains(Modifier.PUBLIC) && executableElement.getParameters().size() == 1) { + final String methodName = executableElement.getSimpleName().toString(); + // Only add setters and use a property style name + if (methodName.startsWith("set")) { + final String name = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); + final Set types = methods.computeIfAbsent(name, (key -> new HashSet<>())); + types.add(executableElement.getParameters().get(0).asType()); + } + } + } + for (Element element : ElementFilter.fieldsIn(elements.getAllMembers(e))) { + if (element.getModifiers().contains(Modifier.PUBLIC) && !element.getModifiers().contains(Modifier.FINAL)) { + final Set types = fields.computeIfAbsent(element.getSimpleName().toString(), (key -> new HashSet<>())); + types.add(element.asType()); + } + } + // Validate default properties + ElementHelper.getAnnotations(method, Fields.class, Field.class).forEach(a -> validateAnnotation(a, fields)); + ElementHelper.getAnnotations(method, Properties.class, Property.class).forEach(a -> validateAnnotation(a, methods)); + + // Validate fields + for (Parameter parameter : method.parametersAnnotatedWith(Field.class)) { + final Set propertyTypes = fields.get(resolveFieldName(parameter)); + final TypeMirror valueType = parameter.asType(); + if (!assignablePropertyFound(valueType, propertyTypes)) { + messages.add(createError(parameter, "No target field found in %s with name %s with type %s.", resultType, parameter.targetName(), valueType)); + } + validateCommonAnnotation(parameter, Field.class); + } + // Validate properties + for (Parameter parameter : method.parametersAnnotatedWith(Property.class)) { + final Set propertyTypes = methods.get(resolveSetterName(parameter)); + final TypeMirror valueType = parameter.asType(); + if (!assignablePropertyFound(valueType, propertyTypes)) { + messages.add(createError(parameter, "No method found in %s with signature %s(%s).", resultType, parameter.targetName(), valueType)); + } + validateCommonAnnotation(parameter, Property.class); + } + } + + private void validateCommonAnnotation(final Parameter parameter, final Class annotation) { + final Collection annotations = ElementHelper.getAnnotations(parameter, null, annotation); + // There should only be one annotation + if (annotations.size() != 1) { + messages.add(createError(parameter, "Parameters can contain only a single @%s annotation.", annotation.getName())); + } else { + // We should have a name value and one other value + final AnnotationMirror annotationMirror = annotations.iterator().next(); + final Map map = annotationMirror.getElementValues(); + if (!map.isEmpty()) { + // Look for the name attribute and a single value + for (Map.Entry entry : map.entrySet()) { + final ExecutableElement attribute = entry.getKey(); + final AnnotationValue attributeValue = entry.getValue(); + if (!"name".contentEquals(attribute.getSimpleName())) { + messages.add(createError(parameter, annotationMirror, attributeValue, + "Default values are not allowed for parameters annotated with @%s. %s", annotation.getName(), annotationMirror)); + } + } + } + } + } + + private void validateAnnotation(final AnnotationMirror annotationMirror, final Map> properties) { + // We should have a name value and one other value + final Map map = annotationMirror.getElementValues(); + final int size = map.size(); + if (size < 2) { + messages.add(createError(method, annotationMirror, "The name attribute and at least one default value are required: %s", annotationMirror)); + } else if (size > 2) { + messages.add(createError(method, annotationMirror, "Only the name attribute and one default attribute are allowed to be defined: %s", annotationMirror)); + } else { + // Look for the name attribute and a single value + String name = null; + AnnotationValue value = null; + for (Map.Entry entry : map.entrySet()) { + final ExecutableElement attribute = entry.getKey(); + final AnnotationValue attributeValue = entry.getValue(); + if ("name".contentEquals(attribute.getSimpleName())) { + name = String.valueOf(attributeValue.getValue()); + } else { + value = attributeValue; + } + } + if (name == null) { + messages.add(createError(method, annotationMirror, "The name attribute is required on %s", annotationMirror)); + } else if (value == null) { + messages.add(createError(method, annotationMirror, "No value could be determined for %s", annotationMirror)); + } else { + final Set propertyTypes = properties.get(name); + if (propertyTypes == null) { + messages.add(createError(method, annotationMirror, value, "Could not find property %s on %s.", name, resultType)); + } else { + final TypeMirror defaultValueType = value.accept(ValueTypeAnnotationValueVisitor.INSTANCE, elements); + if (!assignablePropertyFound(defaultValueType, propertyTypes)) { + messages.add(createError(method, annotationMirror, value, "Expected property with type %s found with type %s", + defaultValueType, propertyTypes)); + } + } + } + } + } + + private boolean assignablePropertyFound(final TypeMirror valueType, final Set propertyTypes) { + if (propertyTypes != null) { + for (TypeMirror propertyType : propertyTypes) { + if (types.isAssignable(types.erasure(valueType), types.erasure(propertyType))) { + return true; + } + } + } + return false; + } + + private String resolveFieldName(final Parameter parameter) { + String result = ""; + final Field field = parameter.getAnnotation(Field.class); + if (field != null) { + final String name = field.name(); + if (name.isEmpty()) { + result = parameter.getSimpleName().toString(); + } else { + result = name; + } + } + return result; + } + + private String resolveSetterName(final Parameter parameter) { + String result = ""; + final Property property = parameter.getAnnotation(Property.class); + if (property != null) { + final String name = property.name(); + if (name.isEmpty()) { + result = parameter.getSimpleName().toString(); + } else { + result = name; + } + } + return result; + } + + private static class ValueTypeAnnotationValueVisitor extends SimpleAnnotationValueVisitor8 { + private static final ValueTypeAnnotationValueVisitor INSTANCE = new ValueTypeAnnotationValueVisitor(); + + @Override + protected TypeMirror defaultAction(final Object o, final Elements elements) { + return ElementHelper.toType(elements, o.getClass()); + } + + @Override + public TypeMirror visitType(final TypeMirror t, final Elements elements) { + return ElementHelper.toType(elements, Class.class); + } + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatPart.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatPart.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatPart.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatPart.java 2017-08-09 18:02:31.000000000 +0000 @@ -56,7 +56,7 @@ * @param position the position in the string format. */ private StringFormatPart(final int position) { - this.flags = new LinkedHashSet(); + this.flags = new LinkedHashSet<>(); this.position = position; } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatValidator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatValidator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatValidator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/StringFormatValidator.java 2017-08-09 18:02:31.000000000 +0000 @@ -53,8 +53,8 @@ public static final Pattern PATTERN = Pattern.compile("%(\\d+\\$)?([-#+ 0,(\\<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])"); - private final Set formatParts = new TreeSet(); - private final Set formats = new TreeSet(); + private final Set formatParts = new TreeSet<>(); + private final Set formats = new TreeSet<>(); private int argumentCount; private boolean valid; private final String format; @@ -144,14 +144,14 @@ if (initPart.conversion() != translationPart.conversion()) { translationResult.valid = false; translationResult.setDetailMessage("The translated message format (%s) does not match the initial message format (%s).", translationFormat, format); - translationResult.setSummaryMessage("The translated message format does not match the initial message format."); + translationResult.setSummaryMessage("The translated message format (%s) does not match the initial message format (%s).", translationFormat, format); break; } } } else { translationResult.valid = false; translationResult.setDetailMessage("The translated message format (%s) does not match the initial message format (%s).", translationFormat, format); - translationResult.setSummaryMessage("The translated message format does not match the initial message format."); + translationResult.setSummaryMessage("The translated message format (%s) does not match the initial message format (%s).", translationFormat, format); } return translationResult; @@ -223,7 +223,7 @@ setDetailMessage("The original is '%s' and the reconstructed format is '%s'. This is likely an internal error and should be reported.", format, asFormat()); } else { // Create a multimap to hold the parameter values for sorting - final Map> paramMap = new TreeMap>(); + final Map> paramMap = new TreeMap<>(); int counter = 0; int index = 0; // Initialize the argument count @@ -246,7 +246,7 @@ continue; } } else { - params = new ArrayList(); + params = new ArrayList<>(); paramMap.put(index, params); } counter++; @@ -290,7 +290,7 @@ if (valid) { try { // Copy the results in order to a new list. - final List params = new ArrayList(); + final List params = new ArrayList<>(); for (Map.Entry> entry : paramMap.entrySet()) { params.addAll(entry.getValue()); } @@ -320,8 +320,8 @@ String.format(format, parameters); } catch (final IllegalFormatException e) { valid = false; - setSummaryMessage("Invalid format for '%s' with parameters '%s'. java.util.Formatter Error: %s", format, Arrays.asList(parameters), e.getMessage()); - setDetailMessage("Format '%s' with parameters '%s' is invalid. StringFormatValidator: %s", format, Arrays.asList(parameters), this); + setSummaryMessage("Invalid format for '%s' with parameters '%s'. java.util.Formatter Error: %s", format, Arrays.toString(parameters), e.getMessage()); + setDetailMessage("Format '%s' with parameters '%s' is invalid. StringFormatValidator: %s", format, Arrays.toString(parameters), this); } } } @@ -393,7 +393,7 @@ break; } } - final Set counted = new HashSet(); + final Set counted = new HashSet<>(); int count = 1; // Initialize the argument count for (StringFormatPart stringFormatPart : formats) { diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessageFactory.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessageFactory.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessageFactory.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessageFactory.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,7 +22,9 @@ package org.jboss.logging.processor.validation; -import org.jboss.logging.processor.model.MessageObject; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; /** * Date: 12.08.2011 @@ -38,46 +40,76 @@ } - public static ValidationMessage createError(final MessageObject messageObject, final String message) { - return new ValidationErrorMessage(messageObject, message); + public static ValidationMessage createError(final Element element, final String message) { + return new ValidationErrorMessage(element, message, null, null); } - public static ValidationMessage createError(final MessageObject messageObject, final String format, final Object... args) { - return new ValidationErrorMessage(messageObject, String.format(format, args)); + public static ValidationMessage createError(final Element element, final String format, final Object... args) { + return new ValidationErrorMessage(element, String.format(format, args), null, null); } - public static ValidationMessage createWarning(final MessageObject messageObject, final String message) { - return new ValidationWarningMessage(messageObject, message); + public static ValidationMessage createError(final Element element, final AnnotationMirror annotationMirror, final String message) { + return new ValidationErrorMessage(element, message, annotationMirror, null); } - public static ValidationMessage createWarning(final MessageObject messageObject, final String format, final Object... args) { - return new ValidationWarningMessage(messageObject, String.format(format, args)); + public static ValidationMessage createError(final Element element, final AnnotationMirror annotationMirror, final String format, final Object... args) { + return new ValidationErrorMessage(element, String.format(format, args), annotationMirror, null); + } + + public static ValidationMessage createError(final Element element, final AnnotationMirror annotationMirror, final AnnotationValue annotationValue, final String message) { + return new ValidationErrorMessage(element, message, annotationMirror, annotationValue); + } + + public static ValidationMessage createError(final Element element, final AnnotationMirror annotationMirror, final AnnotationValue annotationValue, final String format, final Object... args) { + return new ValidationErrorMessage(element, String.format(format, args), annotationMirror, annotationValue); + } + + public static ValidationMessage createWarning(final Element element, final String message) { + return new ValidationWarningMessage(element, message, null, null); + } + + public static ValidationMessage createWarning(final Element element, final String format, final Object... args) { + return new ValidationWarningMessage(element, String.format(format, args), null, null); } private static abstract class AbstractValidationMessage implements ValidationMessage { - private final MessageObject messageObject; + private final Element element; private final String message; + private final AnnotationMirror annotationMirror; + private final AnnotationValue annotationValue; - AbstractValidationMessage(final MessageObject messageObject, final String message) { - this.messageObject = messageObject; + AbstractValidationMessage(final Element element, final String message, final AnnotationMirror annotationMirror, final AnnotationValue annotationValue) { + this.element = element; this.message = message; + this.annotationMirror = annotationMirror; + this.annotationValue = annotationValue; } @Override - public final MessageObject getMessageObject() { - return messageObject; + public final Element getElement() { + return element; } @Override public final String getMessage() { return message; } + + @Override + public AnnotationMirror getAnnotationMirror() { + return annotationMirror; + } + + @Override + public AnnotationValue getAnnotationValue() { + return annotationValue; + } } private static class ValidationErrorMessage extends AbstractValidationMessage { - private ValidationErrorMessage(final MessageObject messageObject, final String message) { - super(messageObject, message); + private ValidationErrorMessage(final Element element, final String message, final AnnotationMirror annotationMirror, final AnnotationValue annotationValue) { + super(element, message, annotationMirror, annotationValue); } @Override @@ -88,8 +120,8 @@ private static class ValidationWarningMessage extends AbstractValidationMessage { - private ValidationWarningMessage(final MessageObject messageObject, final String message) { - super(messageObject, message); + private ValidationWarningMessage(final Element element, final String message, final AnnotationMirror annotationMirror, final AnnotationValue annotationValue) { + super(element, message, annotationMirror, annotationValue); } @Override diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessage.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessage.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessage.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/ValidationMessage.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,7 +22,13 @@ package org.jboss.logging.processor.validation; -import org.jboss.logging.processor.model.MessageObject; +import javax.annotation.processing.Messager; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.AnnotationValue; +import javax.lang.model.element.Element; +import javax.tools.Diagnostic; + +import org.jboss.logging.processor.model.DelegatingElement; /** * Date: 12.08.2011 @@ -34,7 +40,7 @@ /** * Validation message type enum. */ - public enum Type { + enum Type { ERROR, WARN } @@ -47,11 +53,25 @@ Type type(); /** - * Returns the message object that caused the error. + * Returns the element that caused the error. + * + * @return the element that caused the error. + */ + Element getElement(); + + /** + * The annotation the error occurred on. * - * @return the message object that caused the error. + * @return the annotation the error occurred on or {@code null} if this was not an annotation error */ - MessageObject getMessageObject(); + AnnotationMirror getAnnotationMirror(); + + /** + * The value of the annotation which caused the error. + * + * @return the value of the annotation or {@code null} + */ + AnnotationValue getAnnotationValue(); /** * Returns the error message. @@ -59,4 +79,34 @@ * @return the error message. */ String getMessage(); + + /** + * Prints the message and returns {@code true} if the message was an error message. + * + * @param messager the messager used to print the message + * + * @return {@code true} if this was an error message otherwise {@code false} + */ + default boolean printMessage(final Messager messager) { + boolean error = false; + Element element = getElement(); + element = (element instanceof DelegatingElement ? ((DelegatingElement) element).getDelegate() : element); + final AnnotationMirror annotationMirror = getAnnotationMirror(); + final AnnotationValue annotationValue = getAnnotationValue(); + final Diagnostic.Kind kind; + if (type() == Type.ERROR) { + kind = Diagnostic.Kind.ERROR; + error = true; + } else { + kind = Diagnostic.Kind.WARNING; + } + if (annotationMirror == null) { + messager.printMessage(kind, getMessage(), element); + } else if (annotationValue == null) { + messager.printMessage(kind, getMessage(), element, annotationMirror); + } else { + messager.printMessage(kind, getMessage(), element, annotationMirror, annotationValue); + } + return error; + } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/Validator.java jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/Validator.java --- jboss-logging-tools-2.0.2/processor/src/main/java/org/jboss/logging/processor/validation/Validator.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/java/org/jboss/logging/processor/validation/Validator.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,7 +22,6 @@ package org.jboss.logging.processor.validation; -import static org.jboss.logging.processor.model.Parameter.ParameterType; import static org.jboss.logging.processor.validation.ValidationMessageFactory.createError; import static org.jboss.logging.processor.validation.ValidationMessageFactory.createWarning; @@ -38,16 +37,31 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.function.BiFunction; +import java.util.function.Function; +import javax.annotation.processing.ProcessingEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; +import javax.lang.model.util.Types; +import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.ConstructType; +import org.jboss.logging.annotations.LoggingClass; import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.annotations.Once; +import org.jboss.logging.annotations.Param; import org.jboss.logging.annotations.Pos; +import org.jboss.logging.annotations.Producer; +import org.jboss.logging.annotations.Signature; +import org.jboss.logging.annotations.Suppressed; import org.jboss.logging.annotations.Transform; import org.jboss.logging.annotations.Transform.TransformType; import org.jboss.logging.processor.model.MessageInterface; -import org.jboss.logging.processor.model.MessageInterface.AnnotatedType; import org.jboss.logging.processor.model.MessageMethod; import org.jboss.logging.processor.model.Parameter; import org.jboss.logging.processor.model.ReturnType; @@ -66,11 +80,17 @@ private final MessageIdValidator messageIdValidator; private final IdLengthValidator idLengthValidator; private final IdRangeValidator idRangeValidator; + private final ProcessingEnvironment processingEnv; + private final Elements elements; + private final Types types; - public Validator() { + public Validator(final ProcessingEnvironment processingEnv) { messageIdValidator = new MessageIdValidator(); idLengthValidator = new IdLengthValidator(); idRangeValidator = new IdRangeValidator(); + this.processingEnv = processingEnv; + this.elements = processingEnv.getElementUtils(); + this.types = processingEnv.getTypeUtils(); } /** @@ -81,27 +101,22 @@ * @return a collection of validation messages or an empty collection. */ public final Collection validate(final MessageInterface messageInterface) { - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); String locale = null; - switch (messageInterface.getAnnotatedType()) { - case MESSAGE_BUNDLE: { - // Get all messageMethods except logger interface messageMethods - final Set messageMethods = getAllMethods(messageInterface); - messages.addAll(validateCommon(messageInterface, messageMethods)); - messages.addAll(validateBundle(messageMethods)); - locale = messageInterface.getAnnotation(MessageBundle.class).rootLocale(); - break; - } - case MESSAGE_LOGGER: { - // Get all messageMethods except logger interface messageMethods - final Set messageMethods = getAllMethods(messageInterface); - messages.addAll(validateCommon(messageInterface, messageMethods)); - messages.addAll(validateLogger(messageMethods)); - locale = messageInterface.getAnnotation(MessageLogger.class).rootLocale(); - break; - } - default: - messages.add(createError(messageInterface, "Message interface %s is not a message bundle or message logger.", messageInterface.name())); + if (messageInterface.isAnnotatedWith(MessageBundle.class)) { + // Get all messageMethods except logger interface messageMethods + final Set messageMethods = getAllMethods(messageInterface); + messages.addAll(validateCommon(messageInterface, messageMethods)); + messages.addAll(validateBundle(messageMethods)); + locale = messageInterface.getAnnotation(MessageBundle.class).rootLocale(); + } else if (messageInterface.isAnnotatedWith(MessageLogger.class)) { + // Get all messageMethods except logger interface messageMethods + final Set messageMethods = getAllMethods(messageInterface); + messages.addAll(validateCommon(messageInterface, messageMethods)); + messages.addAll(validateLogger(messageMethods)); + locale = messageInterface.getAnnotation(MessageLogger.class).rootLocale(); + } else { + messages.add(createError(messageInterface, "Message interface %s is not a message bundle or message logger.", messageInterface.name())); } // Check the locale is in the list of available locales @@ -122,8 +137,8 @@ * @return a collection of validation messages. */ private Collection validateCommon(final MessageInterface messageInterface, final Set messageMethods) { - final List messages = new ArrayList(); - final Map methodNames = new HashMap(); + final List messages = new ArrayList<>(); + final Map methodNames = new HashMap<>(); messages.addAll(idLengthValidator.validate(messageInterface)); messages.addAll(idRangeValidator.validate(messageInterface)); @@ -155,21 +170,17 @@ if (messageMethod.formatParameterCount() != formatValidator.argumentCount()) { messages.add(createError(messageMethod, "Parameter count does not match for format '%s'. Required: %d Provided: %d", formatValidator.format(), formatValidator.argumentCount(), paramCount)); } - // Validate the transform parameter - if (!messageMethod.parameters(ParameterType.TRANSFORM).isEmpty()) { - final Set parameters = messageMethod.parameters(ParameterType.TRANSFORM); - // Validate each parameter - for (Parameter parameter : parameters) { - validateTransform(messages, parameter, parameter.transform()); + final Map positions = new TreeMap<>(); + boolean validatePositions = false; + for (Parameter parameter : messageMethod.parameters()) { + // Validate the transform parameter + if (parameter.isAnnotatedWith(Transform.class)) { + validateTransform(messages, parameter, parameter.getAnnotation(Transform.class)); } - } - // Validate the POS annotated parameters - if (!messageMethod.parameters(ParameterType.POS).isEmpty()) { - final Map positions = new TreeMap(); - final Set parameters = messageMethod.parameters(ParameterType.POS); - // Validate each parameter - for (Parameter parameter : parameters) { - final Pos pos = parameter.pos(); + // Validate the POS annotated parameters + if (parameter.isAnnotatedWith(Pos.class)) { + validatePositions = true; + final Pos pos = parameter.getAnnotation(Pos.class); final Transform[] transforms = pos.transform(); if (transforms != null && transforms.length > 0) { if (pos.value().length != transforms.length) { @@ -181,7 +192,7 @@ } } // Validate the positions - final Set usedPositions = new HashSet(); + final Set usedPositions = new HashSet<>(); for (int position : pos.value()) { if (usedPositions.contains(position)) { messages.add(createError(parameter, "Position '%d' already used for this parameter.", position)); @@ -195,7 +206,19 @@ } } } - // Check for missing indexed parameters + + // Validate the @Suppressed parameter is on a message bundle, the return type is an exception and the parameter is an exception + if (parameter.isAnnotatedWith(Suppressed.class)) { + if (!messageMethod.returnType().isThrowable()) { + messages.add(createError(messageMethod, "The @Suppressed parameter annotation can only be used with message bundle methods that return an exception.")); + } + if (!isTypeAssignableFrom(parameter, Throwable.class)) { + messages.add(createError(parameter, "The parameter annotated with @Suppressed must be assignable to a Throwable type.")); + } + } + } + // Check for missing indexed parameters + if (validatePositions) { for (int i = 0; i < messageMethod.formatParameterCount(); i++) { final int positionIndex = i + 1; if (!positions.containsKey(positionIndex)) { @@ -219,6 +242,8 @@ } // Validate the parameters messages.addAll(validateParameters(messageMethod)); + // Validate property annotations + messages.addAll(PropertyValidator.validate(processingEnv, messageMethod)); } return messages; } @@ -239,46 +264,104 @@ } else if (transformTypes.contains(TransformType.SIZE)) { if (!(parameter.isArray() || parameter.isVarArgs() || parameter.isSubtypeOf(Map.class) || parameter.isSubtypeOf(Collection.class) || parameter.isSubtypeOf(CharSequence.class))) { - messages.add(createError(parameter, "Invalid type (%s) for %s. Must be an array, %s, %s or %s.", parameter.type(), + messages.add(createError(parameter, "Invalid type (%s) for %s. Must be an array, %s, %s or %s.", parameter.asType(), TransformType.SIZE, Collection.class.getName(), Map.class.getName(), CharSequence.class.getName())); } } } private Collection validateParameters(final MessageMethod messageMethod) { - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); boolean foundCause = false; - final ReturnType returnType = messageMethod.returnType(); - for (Parameter parameter : messageMethod.parameters(ParameterType.ANY)) { - switch (parameter.parameterType()) { - case CAUSE: { - if (foundCause) { - messages.add(createError(messageMethod, "Only one cause parameter is allowed.")); - } else { - foundCause = true; - } - break; + boolean producerFound = false; + for (Parameter parameter : messageMethod.parameters()) { + if (parameter.isAnnotatedWith(Cause.class)) { + if (foundCause) { + messages.add(createError(messageMethod, "Only one cause parameter is allowed.")); + } else { + foundCause = true; } - case FQCN: - if (!parameter.type().equals(Class.class.getName())) { - messages.add(createError(parameter, "Parameter %s annotated with @LoggingClass on method %s must be of type %s.", parameter.name(), messageMethod.name(), Class.class.getName())); + } + if (parameter.isAnnotatedWith(LoggingClass.class)) { + if (!parameter.isSameAs(Class.class)) { + messages.add(createError(parameter, "Parameter %s annotated with @LoggingClass on method %s must be of type %s.", parameter.name(), messageMethod.name(), Class.class.getName())); + } + } + if (parameter.isAnnotatedWith(Producer.class)) { + final boolean isFunction = parameter.isSubtypeOf(Function.class); + final boolean isBiFunction = parameter.isSubtypeOf(BiFunction.class); + + // Check the type arguments + final TypeMirror requiredReturnType = messageMethod.returnType().resolvedType(); + final List typeArgs = ElementHelper.getTypeArguments(parameter); + final int size = typeArgs.size(); + if (isFunction) { + if (size == 2) { + final TypeMirror message = typeArgs.get(0); + final TypeMirror returnType = typeArgs.get(1); + if (!isTypeAssignableFrom(message, String.class)) { + messages.add(createError(parameter, "The type %s must be assignable to a String.", + message)); + } + if (!isTypeAssignableFrom(returnType, requiredReturnType)) { + messages.add(createError(parameter, "The return type parameter of the function " + + "must be assignable from %s", requiredReturnType)); + } + } else { + messages.add(createError(parameter, "The type parameters could not be validated for the " + + "function. The first type argument of the function must be a String and the second type " + + "parameter must be the same as or a super type of %s.", requiredReturnType)); } - break; - case FIELD: { - if (!returnType.hasFieldFor(parameter)) { - messages.add(createError(parameter, "No target field found in %s with name %s with type %s.", returnType.type(), parameter.targetName(), parameter.type())); + } else if (isBiFunction) { + if (size == 3) { + final TypeMirror returnType = typeArgs.get(2); + final TypeMirror first = typeArgs.get(0); + final TypeMirror second = typeArgs.get(1); + if (!isTypeAssignableFrom(first, String.class) && !types.isSubtype(first, ElementHelper.toType(elements, Throwable.class))) { + messages.add(createError(parameter, "The first type type parameter for %s " + + "must be assignable to a String or a super type of a Throwable.", parameter.asType())); + } + if (!isTypeAssignableFrom(second, String.class) && !types.isSubtype(second, ElementHelper.toType(elements, Throwable.class))) { + messages.add(createError(parameter, "The second type parameter for %s " + + "must be assignable to a String or a super type of a Throwable.", parameter.asType())); + } + if (!isTypeAssignableFrom(returnType, requiredReturnType)) { + messages.add(createError(parameter, "The return type parameter of the function " + + "must be assignable from %s", requiredReturnType)); + } + if (messageMethod.hasCause()) { + // Make sure the cause parameter can be assigned to the cause parameter for the BiFunction + if (types.isSubtype(first, ElementHelper.toType(elements, Throwable.class)) && !isTypeAssignableFrom(messageMethod.cause().asType(), first)) { + messages.add(createError(parameter, "The first parameter type, %s, of the BiFunction must be assignable to the cause %s.", + first, messageMethod.cause().asType())); + } + if (types.isSubtype(second, ElementHelper.toType(elements, Throwable.class)) && !isTypeAssignableFrom(messageMethod.cause().asType(), second)) { + messages.add(createError(parameter, "The second parameter type, %s, of the BiFunction must be assignable to the cause %s.", + second, messageMethod.cause().asType())); + } + } else { + messages.add(createWarning(messageMethod, "No @Cause parameter was found on the method. " + + "A null value will always be passed as the cause parameter to the BiFunction.")); + } + } else { + messages.add(createError(parameter, "The type parameters could not be validated for the " + + "function. The first and second type arguments of the function must be a String " + + "or a super type of Throwable. The third type parameter must be the same as or " + + "a super type of %s.", + requiredReturnType)); } - break; + } else { + messages.add(createError(parameter, "Parameter annotated with %s must be a %s or %s type", + Producer.class.getName(), Function.class.getName(), BiFunction.class.getName())); } - case PROPERTY: { - if (!returnType.hasMethodFor(parameter)) { - messages.add(createError(parameter, "No method found in %s with signature %s(%s).", returnType.type(), parameter.targetName(), parameter.type())); - } - break; + + if (producerFound) { + messages.add(createError(messageMethod, + "Only one parameter is allowed to be annotated with %s.", Producer.class.getName())); } + producerFound = true; } } - // TODO - Check all parameter counts return messages; } @@ -290,7 +373,7 @@ * @return a collection of the validation messages. */ private Collection validateBundle(final Set messageMethods) { - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); for (MessageMethod messageMethod : messageMethods) { messages.addAll(validateBundleMethod(messageMethod)); } @@ -298,34 +381,72 @@ } private Collection validateBundleMethod(final MessageMethod messageMethod) { - final List messages = new ArrayList(); - // The return type must be a Throwable or String + final List messages = new ArrayList<>(); + // The return type must be a Throwable, String or a Supplier that returns a Throwable or String final ReturnType returnType = messageMethod.returnType(); - if (returnType.equals(ReturnType.VOID) || returnType.isPrimitive()) { + final TypeMirror returnTypeMirror = returnType.asType(); + final TypeMirror resolvedReturnType = returnType.resolvedType(); + if (returnTypeMirror.getKind() == TypeKind.VOID || returnTypeMirror.getKind().isPrimitive()) { messages.add(createError(messageMethod, "Message bundle messageMethod %s has an invalid return type. Cannot be void or a primitive.", messageMethod.name())); } else if (returnType.isThrowable()) { final ThrowableType throwableReturnType = returnType.throwableReturnType(); if (throwableReturnType.useConstructionParameters()) { - // TODO - Check the return type constructor. Currently handled via the ThrowableReturnTypeFactory. - } else if (!throwableReturnType.useConstructionParameters() && !messageMethod.parameters(ParameterType.CONSTRUCTION).isEmpty()) { + // Check for a matching constructor + final Signature signature = messageMethod.getAnnotation(Signature.class); + if (signature != null) { + final List args = ElementHelper.getClassArrayAnnotationValue(messageMethod, Signature.class, "value"); + // Validate the constructor exists + if (!ElementHelper.hasConstructor(types, returnType, args)) { + messages.add(createError(messageMethod, "Could not find constructor for %s with arguments %s", messageMethod.asType(), args)); + } + final int messageIndex = signature.messageIndex(); + // Note that the messageIndex is required and must be 0 or greater + if (messageIndex < 0) { + messages.add(createError(messageMethod, "A messageIndex of 0 or greater is required. Value %d is invalid.", messageIndex)); + } + } + // Validate the construct type is valid + if (messageMethod.isAnnotatedWith(ConstructType.class)) { + final TypeElement constructTypeValue = ElementHelper.getClassAnnotationValue(messageMethod, ConstructType.class); + // Shouldn't be null + if (constructTypeValue == null) { + messages.add(createError(messageMethod, "Class not defined for the ConstructType")); + } else { + if (!types.isAssignable(constructTypeValue.asType(), returnType.asType())) { + messages.add(createError(messageMethod, "The requested type %s can not be assigned to %s.", constructTypeValue.asType(), returnType.asType())); + } + } + } + } else if (!throwableReturnType.useConstructionParameters() && !messageMethod.parametersAnnotatedWith(Param.class).isEmpty()) { messages.add(createError(messageMethod, "MessageMethod does not have an usable constructor for the return type %s.", returnType.name())); } else { final boolean hasMessageConstructor = (throwableReturnType.hasStringAndThrowableConstructor() || throwableReturnType.hasThrowableAndStringConstructor() || throwableReturnType.hasStringConstructor()); final boolean usableConstructor = (throwableReturnType.hasDefaultConstructor() || throwableReturnType.hasStringAndThrowableConstructor() || throwableReturnType.hasStringConstructor() || throwableReturnType.hasThrowableAndStringConstructor() || throwableReturnType.hasThrowableConstructor()); - if (!usableConstructor) { + if (!messageMethod.parametersAnnotatedWith(Producer.class).isEmpty()) { + if (messageMethod.isAnnotatedWith(ConstructType.class)) { + messages.add(createError(messageMethod, "Method annotated with %s cannot have a parameter annotated with %s.", + ConstructType.class.getName(), Producer.class.getName())); + } + final TypeMirror erasure = types.erasure(resolvedReturnType); + if (!isTypeAssignableFrom(erasure, Throwable.class)) { + messages.add(createError(messageMethod, "The return type must be a subclass of a java.lang.Throwable")); + } + } else if (!usableConstructor) { messages.add(createError(messageMethod, "MessageMethod does not have an usable constructor for the return type %s.", returnType.name())); } else if (!hasMessageConstructor) { // Check to see if there is no message constructor messages.add(createWarning(messageMethod, "The message cannot be set via the throwable constructor and will be ignored.")); } } } else { - if (!returnType.isAssignableFrom(String.class)) { - messages.add(createError(messageMethod, "Message bundle method (%s) has an invalid return type of %s.", messageMethod.name(), returnType.name())); + if (!isTypeAssignableFrom(resolvedReturnType, String.class) && !returnType.isThrowable()) { + messages.add(createError(messageMethod, "Message bundle method (%s) has an invalid return type of %s. " + + "Return types must be a String, a subtype of Throwable or a java.util.function.Supplier which " + + "returns a String or a subtype of Throwable.", messageMethod.name(), returnTypeMirror)); } - if (ElementHelper.isAnnotatedWith(messageMethod.reference(), ConstructType.class)) { - messages.add(createError(messageMethod, "ConstructType annotation requires a throwable return type")); + if (messageMethod.isAnnotatedWith(ConstructType.class)) { + messages.add(createError(messageMethod, "ConstructType annotation requires a throwable or supplier which produces a throwable return type")); } } return messages; @@ -339,13 +460,13 @@ * @return a collection of the validation messages. */ private Collection validateLogger(final Set messageMethods) { - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); for (MessageMethod messageMethod : messageMethods) { if (messageMethod.isLoggerMethod()) { messages.addAll(validateLoggerMethod(messageMethod)); } else { messages.addAll(validateBundleMethod(messageMethod)); - if (ElementHelper.isAnnotatedWith(messageMethod.reference(), Once.class)) { + if (messageMethod.isAnnotatedWith(Once.class)) { messages.add(createError(messageMethod, "Only @LogMessage method can be annoted with @Once")); } } @@ -354,9 +475,9 @@ } private Collection validateLoggerMethod(final MessageMethod messageMethod) { - final List messages = new ArrayList(); + final List messages = new ArrayList<>(); // The return type must be void - if (!ReturnType.VOID.equals(messageMethod.returnType())) { + if (messageMethod.returnType().asType().getKind() != TypeKind.VOID) { messages.add(createError(messageMethod, "Message logger methods can only have a void return type.")); } return messages; @@ -370,16 +491,63 @@ * @return a set of all the methods (exception logger interface methods) the interface must implement. */ private Set getAllMethods(final MessageInterface messageInterface) { - if (messageInterface.getAnnotatedType() == AnnotatedType.NONE) { - return Collections.emptySet(); - } - final Set messageMethods = new LinkedHashSet(); - for (MessageMethod messageMethod : messageInterface.methods()) { - messageMethods.add(messageMethod); + if (messageInterface.isAnnotatedWith(MessageBundle.class) || messageInterface.isAnnotatedWith(MessageLogger.class)) { + final Set messageMethods = new LinkedHashSet<>(); + for (MessageMethod messageMethod : messageInterface.methods()) { + messageMethods.add(messageMethod); + } + for (MessageInterface msgInterface : messageInterface.extendedInterfaces()) { + messageMethods.addAll(getAllMethods(msgInterface)); + } + return messageMethods; } - for (MessageInterface msgInterface : messageInterface.extendedInterfaces()) { - messageMethods.addAll(getAllMethods(msgInterface)); + return Collections.emptySet(); + } + + /** + * Checks the element type, if an array the type of the array is checked, against the class. If the element type is + * assignable to the class type. + * + * @param element the element to test + * @param type the type the element needs to be assignable to + * + * @return {@code true} if the element type is assignable to the class type, otherwise {@code false} + */ + private boolean isTypeAssignableFrom(final Element element, final Class type) { + return isTypeAssignableFrom(element.asType(), type); + } + + /** + * Checks the type, if an array the type of the array is checked, against the class. If the element type is + * assignable to the class type. + * + * @param typeMirror the type to test + * @param type the type the element needs to be assignable to + * + * @return {@code true} if the element type is assignable to the class type, otherwise {@code false} + */ + private boolean isTypeAssignableFrom(final TypeMirror typeMirror, final Class type) { + return isTypeAssignableFrom(typeMirror, ElementHelper.toType(elements, type)); + } + + /** + * Checks the type, if an array the type of the array is checked, against the class. If the element type is + * assignable to the class type. + * + * @param typeMirror the type to test + * @param type the type the element needs to be assignable to + * + * @return {@code true} if the element type is assignable to the class type, otherwise {@code false} + */ + private boolean isTypeAssignableFrom(final TypeMirror typeMirror, final TypeMirror type) { + TypeMirror t = typeMirror; + if (t.getKind() == TypeKind.ARRAY) { + t = ((ArrayType) t).getComponentType(); + } + if (types.isAssignable(types.erasure(t), ElementHelper.toType(elements, Collection.class))) { + // We only need the first type + t = types.erasure(ElementHelper.getTypeArguments(t).iterator().next()); } - return messageMethods; + return types.isAssignable(t, type); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/main/resources/META-INF/LICENSE.txt jboss-logging-tools-2.1.0/processor/src/main/resources/META-INF/LICENSE.txt --- jboss-logging-tools-2.0.2/processor/src/main/resources/META-INF/LICENSE.txt 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/resources/META-INF/LICENSE.txt 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff -Nru jboss-logging-tools-2.0.2/processor/src/main/resources/schema/logging-report_1_0.xsd jboss-logging-tools-2.1.0/processor/src/main/resources/schema/logging-report_1_0.xsd --- jboss-logging-tools-2.0.2/processor/src/main/resources/schema/logging-report_1_0.xsd 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/main/resources/schema/logging-report_1_0.xsd 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + The optional title of the report. + + + + + + + + + A group of messages for a logger or message bundle interface. + + + + + + + + + The fully qualified class name of the interface. + + + + + + + + + Represents a message from a logger or message bundle interface. + + + + + + + + The id associated with the message if one is present. + + + + + + + An optional URL to a resolution document for the error. + + + + + + + The log level if this is a logger message. + + + + + + + The return type if this is a message bundle message. + + + + + + + \ No newline at end of file diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/AbstractLoggerTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/AbstractLoggerTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/AbstractLoggerTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/AbstractLoggerTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -25,8 +25,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; +import org.junit.AfterClass; +import org.junit.BeforeClass; /** * @author James R. Perkins @@ -34,19 +34,21 @@ public abstract class AbstractLoggerTest { static final String PROJECT_CODE = "LOGL"; - static final MessageListHandler HANDLER = new MessageListHandler(); + static final QueuedMessageHandler HANDLER = new QueuedMessageHandler(); static final String CATEGORY = AbstractLoggerTest.class.getPackage().getName(); static final String LOGGER_ID_PATTERN = "LOG.*[0-9]:\\s"; + private static final org.jboss.logmanager.Logger LOGGER = org.jboss.logmanager.Logger.getLogger(CATEGORY); + @BeforeClass public static void installHandler() { - org.jboss.logmanager.Logger.getLogger(CATEGORY).addHandler(HANDLER); + LOGGER.addHandler(HANDLER); } @AfterClass public static void uninstallHandler() { + LOGGER.removeHandler(HANDLER); HANDLER.close(); - org.jboss.logmanager.Logger.getLogger(CATEGORY).removeHandler(HANDLER); } protected String parseStringLoggerId(final String message) { diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/DefaultLogger.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/DefaultLogger.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/DefaultLogger.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/DefaultLogger.java 2017-08-09 18:02:31.000000000 +0000 @@ -53,6 +53,14 @@ // Used to test the ambiguous log field in the DelegatingBasicLogger DefaultLogger log = Logger.getMessageLogger(DefaultLogger.class, AbstractLoggerTest.CATEGORY); + static DefaultLogger get(final String category) { + return Logger.getMessageLogger(DefaultLogger.class, category); + } + + default void initialized() { + LOGGER.info("Initialized"); + } + @LogMessage(level = Level.INFO) @Message(id = 100, value = "Hello %s.") void hello(String name); diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionLogger.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionLogger.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionLogger.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionLogger.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,56 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.generated; + +import org.jboss.logging.Logger; +import org.jboss.logging.Logger.Level; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.Message.Format; +import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ValidIdRange; +import org.jboss.logging.annotations.ValidIdRanges; + +/** + * @author James R. Perkins + */ +@MessageLogger(projectCode = AbstractLoggerTest.PROJECT_CODE) +public interface ExpressionLogger { + + ExpressionLogger LOGGER = Logger.getMessageLogger(ExpressionLogger.class, AbstractLoggerTest.CATEGORY); + + @LogMessage(level = Level.INFO) + @Message(value = "${test.property}") + void logProperty(); + + @LogMessage(level = Level.INFO) + @Message(value = "${test.property.nonexistent:default value}") + void logPropertyDefault(); + + @Message(value = "${test.property}") + String property(); + + @Message(value = "${test.property.nonexistent:default value}") + String propertyDefault(); +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionMessagesTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionMessagesTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionMessagesTest.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ExpressionMessagesTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.generated; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author James R. Perkins + */ +public class ExpressionMessagesTest extends AbstractLoggerTest { + + @After + public void clearHandler() { + HANDLER.close(); + } + + @Test + public void testExpressions() throws Exception { + ExpressionLogger.LOGGER.logProperty(); + Assert.assertEquals("test property value", HANDLER.getMessage()); + + ExpressionLogger.LOGGER.logPropertyDefault(); + Assert.assertEquals("default value", HANDLER.getMessage()); + + Assert.assertEquals("test property value", ExpressionLogger.LOGGER.property()); + Assert.assertEquals("default value", ExpressionLogger.LOGGER.propertyDefault()); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/GeneratedSourceAnalysisTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/GeneratedSourceAnalysisTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/GeneratedSourceAnalysisTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/GeneratedSourceAnalysisTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -32,9 +32,13 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.jboss.forge.roaster.Roaster; +import org.jboss.forge.roaster.model.Method; +import org.jboss.forge.roaster.model.Named; import org.jboss.forge.roaster.model.Type; import org.jboss.forge.roaster.model.source.FieldSource; import org.jboss.forge.roaster.model.source.JavaClassSource; @@ -43,9 +47,9 @@ import org.jboss.forge.roaster.model.source.ParameterSource; import org.jboss.logging.DelegatingBasicLogger; import org.jboss.logging.Logger; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; /** * @author James R. Perkins @@ -109,13 +113,13 @@ public void testRootLocale() throws Exception { JavaClassSource implementationSource = parseGenerated(RootLocaleLogger.class); FieldSource locale = implementationSource.getField("LOCALE"); - Assert.assertNotNull(locale, "Expected a LOCALE field for " + implementationSource.getName()); - Assert.assertEquals(locale.getLiteralInitializer(), "Locale.forLanguageTag(\"en-UK\")"); + Assert.assertNotNull("Expected a LOCALE field for " + implementationSource.getName(), locale); + Assert.assertEquals("Locale.forLanguageTag(\"en-UK\")", locale.getLiteralInitializer()); implementationSource = parseGenerated(DefaultLogger.class); locale = implementationSource.getField("LOCALE"); - Assert.assertNotNull(locale, "Expected a LOCALE field for " + implementationSource.getName()); - Assert.assertEquals(locale.getLiteralInitializer(), "Locale.ROOT"); + Assert.assertNotNull("Expected a LOCALE field for " + implementationSource.getName(), locale); + Assert.assertEquals("Locale.ROOT", locale.getLiteralInitializer()); } private void compareLogger(final Class intf) throws IOException { @@ -125,20 +129,21 @@ // Logger implementations should have a single constructor which accepts a org.jboss.logging.Logger final List> implementationMethods = implementationSource.getMethods(); - final MethodSource constructor = findConstructor(implementationMethods); - Assert.assertNotNull(constructor, "No constructor found for " + implementationSource.getName()); - final List> parameters = constructor.getParameters(); - Assert.assertEquals(parameters.size(), 1, "Found more than one parameter for " + implementationSource.getName() + ": " + parameters); + final Optional> constructor = findConstructor(implementationMethods); + Assert.assertTrue("No constructor found for " + implementationSource.getName(), constructor.isPresent()); + final List> parameters = constructor.get().getParameters(); + Assert.assertEquals("Found more than one parameter for " + implementationSource.getName() + ": " + parameters, + 1, parameters.size()); final ParameterSource parameter = parameters.get(0); final Type type = parameter.getType(); - Assert.assertEquals(type.getQualifiedName(), Logger.class.getName()); + Assert.assertEquals(Logger.class.getName(), type.getQualifiedName()); // If the logger is not extending the DelegatingBasicLogger there should be a protected final org.jboss.logging.Logger field if (!DelegatingBasicLogger.class.getName().equals(implementationSource.getSuperType())) { final FieldSource log = implementationSource.getField("log"); - Assert.assertNotNull(log, "Expected a log field in " + implementationSource.getName()); - Assert.assertTrue(log.isProtected() && log.isFinal(), - "Expected the log field to be protected and final in " + implementationSource.getName()); + Assert.assertNotNull("Expected a log field in " + implementationSource.getName(), log); + Assert.assertTrue("Expected the log field to be protected and final in " + implementationSource.getName(), + log.isProtected() && log.isFinal()); } } @@ -149,15 +154,16 @@ // Message bundles should have an INSTANCE field final FieldSource instance = implementationSource.getField("INSTANCE"); - Assert.assertNotNull(instance, "Expected an INSTANCE field in " + implementationSource.getName()); - Assert.assertTrue(instance.isStatic() && instance.isFinal() && instance.isPublic(), - "Expected the instance field to be public, static and final in " + implementationSource.getName()); + Assert.assertNotNull("Expected an INSTANCE field in " + implementationSource.getName(), instance); + Assert.assertTrue("Expected the instance field to be public, static and final in " + implementationSource.getName(), + instance.isStatic() && instance.isFinal() && instance.isPublic()); // Expect a protected constructor with no parameters - final MethodSource constructor = findConstructor(implementationSource.getMethods()); - Assert.assertNotNull(constructor, "No constructor found for " + implementationSource.getName()); - Assert.assertTrue(constructor.getParameters().isEmpty(), "Expected the constructor parameters to be empty for " + implementationSource.getName()); - Assert.assertTrue(constructor.isProtected(), "Expected the constructor to be protected for " + implementationSource.getName()); + final Optional> constructor = findConstructor(implementationSource.getMethods()); + Assert.assertTrue("No constructor found for " + implementationSource.getName(), constructor.isPresent()); + final MethodSource c = constructor.get(); + Assert.assertTrue("Expected the constructor parameters to be empty for " + implementationSource.getName(), c.getParameters().isEmpty()); + Assert.assertTrue("Expected the constructor to be protected for " + implementationSource.getName(), c.isProtected()); } private void compareCommon(final JavaInterfaceSource interfaceSource, final JavaClassSource implementationSource) { @@ -167,17 +173,18 @@ // Validate the implementation has all the interface methods, note this should be the cause final Collection interfaceMethodNames = toNames(interfaceMethods); final Collection implementationMethodNames = toNames(implementationMethods); - Assert.assertTrue(implementationMethodNames.containsAll(interfaceMethodNames), - String.format("Implementation is missing methods from the interface:%n\timplementation: %s%n\tinterface:%s", implementationMethodNames, interfaceMethodNames)); + Assert.assertTrue(String.format("Implementation is missing methods from the interface:%n\timplementation: %s%n\tinterface:%s", implementationMethodNames, interfaceMethodNames), + implementationMethodNames.containsAll(interfaceMethodNames)); // The generates source files should have a serialVersionUID with a value of one - Assert.assertTrue(implementationSource.hasField("serialVersionUID"), "Expected a serialVersionUID field in " + implementationSource.getName()); + Assert.assertTrue("Expected a serialVersionUID field in " + implementationSource.getName(), implementationSource.hasField("serialVersionUID")); final FieldSource serialVersionUID = implementationSource.getField("serialVersionUID"); - Assert.assertEquals(serialVersionUID.getLiteralInitializer(), "1L", "Expected serialVersionUID to be set to 1L in " + implementationSource.getName()); + Assert.assertEquals("Expected serialVersionUID to be set to 1L in " + implementationSource.getName(), "1L", serialVersionUID.getLiteralInitializer()); + // All bundles should have a getLoggingLocale() final MethodSource getLoggingLocale = implementationSource.getMethod("getLoggingLocale"); - Assert.assertNotNull(getLoggingLocale, "Expected a getLoggingLocale() method in " + implementationSource.getName()); - Assert.assertTrue(getLoggingLocale.isProtected(), "Expected the getLoggingLocale() to be protected in " + implementationSource.getName()); + Assert.assertNotNull("Expected a getLoggingLocale() method in " + implementationSource.getName(), getLoggingLocale); + Assert.assertTrue("Expected the getLoggingLocale() to be protected in " + implementationSource.getName(), getLoggingLocale.isProtected()); } private void compareTranslations(final Class intf) throws IOException { @@ -193,72 +200,64 @@ private void compareTranslations(final JavaInterfaceSource interfaceSource, final JavaClassSource superImplementationSource, final JavaClassSource implementationSource) { // The implementations should not contain any methods from the interface - final List interfaceMethods = new ArrayList<>(); - for (MethodSource method : interfaceSource.getMethods()) { - interfaceMethods.add(method.getName()); - } + final List interfaceMethods = interfaceSource.getMethods() + .stream() + .map(Named::getName) + .collect(Collectors.toList()); final Collection found = new ArrayList<>(); for (MethodSource method : implementationSource.getMethods()) { if (interfaceMethods.contains(method.getName())) { found.add(method.getName()); } } - Assert.assertTrue(found.isEmpty(), "Found methods in implementation that were in the interface " + implementationSource.getName() + " : " + found); + Assert.assertTrue("Found methods in implementation that were in the interface " + implementationSource.getName() + " : " + found, found.isEmpty()); // The getLoggerLocale() should be overridden final MethodSource getLoggerLocale = implementationSource.getMethod("getLoggingLocale"); - Assert.assertNotNull(getLoggerLocale, "Missing overridden getLoggingLocale() method " + implementationSource.getName()); + Assert.assertNotNull("Missing overridden getLoggingLocale() method " + implementationSource.getName(), getLoggerLocale); // If the file should have a locale constant, validate the constant is one of the Locale constants - for (Map.Entry entry : LOCALE_CONSTANTS.entrySet()) { - final Locale locale = entry.getKey(); - final String constant = entry.getValue(); + LOCALE_CONSTANTS.forEach((locale, constant) -> { if (implementationSource.getName().endsWith(locale.toString())) { // Get the LOCALE field final FieldSource localeField = implementationSource.getField("LOCALE"); - Assert.assertNotNull(localeField, "Expected a LOCALE field " + implementationSource.getName()); - Assert.assertEquals(localeField.getLiteralInitializer(), constant, - "Expected the LOCALE to be set to " + constant + " in " + implementationSource.getName()); + Assert.assertNotNull("Expected a LOCALE field " + implementationSource.getName(), localeField); + Assert.assertEquals("Expected the LOCALE to be set to " + constant + " in " + implementationSource.getName(), constant, + localeField.getLiteralInitializer()); } - } + }); // Get all the method names from the super class - final List superMethods = new ArrayList<>(); - for (MethodSource method : superImplementationSource.getMethods()) { - if (!method.isConstructor()) { - superMethods.add(method.getName()); - } - } + final List superMethods = superImplementationSource.getMethods() + .stream() + .filter(method -> !method.isConstructor()) + .map(Named::getName) + .collect(Collectors.toList()); // All methods in the translation implementation should be overrides of methods in the super class - for (MethodSource method : implementationSource.getMethods()) { + implementationSource.getMethods().forEach(method -> { if (!method.isConstructor()) { - Assert.assertTrue(method.hasAnnotation(Override.class), String.format("Expected method %s to be overridden in %s.", - method.getName(), implementationSource.getName())); - Assert.assertTrue(superMethods.contains(method.getName()), String.format("Expected method %s to override the super (%s) method in %s.", - method.getName(), superImplementationSource.getName(), implementationSource.getName())); + Assert.assertTrue(String.format("Expected method %s to be overridden in %s.", + method.getName(), implementationSource.getName()), method.hasAnnotation(Override.class)); + Assert.assertTrue(String.format("Expected method %s to override the super (%s) method in %s.", + method.getName(), superImplementationSource.getName(), implementationSource.getName()), superMethods.contains(method.getName())); } - } + }); } - - private MethodSource findConstructor(final List> implementationMethods) { - for (MethodSource method : implementationMethods) { - if (method.isConstructor()) { - return method; - } - } - return null; + private Optional> findConstructor(final List> implementationMethods) { + return implementationMethods.stream() + .filter(Method::isConstructor) + .findFirst(); } private Collection toNames(final List> methods) { - final Collection names = new ArrayList<>(); - for (MethodSource method : methods) { - if (!method.isStatic() && !method.isConstructor()) { - names.add(method.getName()); - } - } - return names; + return methods.stream() + // Skip default methods, static methods and constructors + .filter(m -> !m.isDefault() && !m.isStatic() && !m.isConstructor()) + .map(Named::getName) + .collect(Collectors.toList()); + } private String packageToPath(final Package pkg) { @@ -269,17 +268,12 @@ private JavaClassSource parseGenerated(final Class intf) throws IOException { final Pattern pattern = Pattern.compile(Pattern.quote(intf.getSimpleName()) + "_\\$(logger|bundle)\\.java$"); // Find all the files that match - final FileFilter filter = new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pattern.matcher(pathname.getName()).find(); - } - }; + final FileFilter filter = pathname -> pattern.matcher(pathname.getName()).find(); final File dir = new File(TEST_GENERATED_SRC_PATH, packageToPath(intf.getPackage())); final File[] files = dir.listFiles(filter); // There should only be one file - Assert.assertNotNull(files, "Did not find any implementation files for interface " + intf.getName()); - Assert.assertEquals(1, files.length, "Found more than one implementation for interface " + intf.getName() + " " + Arrays.asList(files)); + Assert.assertNotNull("Did not find any implementation files for interface " + intf.getName(), files); + Assert.assertEquals("Found more than one implementation for interface " + intf.getName() + " " + Arrays.asList(files), 1, files.length); return Roaster.parse(JavaClassSource.class, files[0]); } @@ -287,17 +281,12 @@ private Collection parseGeneratedTranslations(final Class intf) throws IOException { final Pattern pattern = Pattern.compile(Pattern.quote(intf.getSimpleName()) + "_\\$(logger|bundle)_.*\\.java$"); // Find all the files that match - final FileFilter filter = new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pattern.matcher(pathname.getName()).matches(); - } - }; + final FileFilter filter = pathname -> pattern.matcher(pathname.getName()).matches(); final File dir = new File(TEST_GENERATED_SRC_PATH, packageToPath(intf.getPackage())); final File[] files = dir.listFiles(filter); // There should only be one file - Assert.assertNotNull(files, "Did not find any implementation files for interface " + intf.getName()); - Assert.assertTrue(files.length > 0, "Did not find any translation implementations for interface " + intf.getName()); + Assert.assertNotNull("Did not find any implementation files for interface " + intf.getName(), files); + Assert.assertTrue("Did not find any translation implementations for interface " + intf.getName(), files.length > 0); final Collection result = new ArrayList<>(); for (final File file : files) { result.add(Roaster.parse(JavaClassSource.class, file)); diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/LevelIdCheckTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/LevelIdCheckTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/LevelIdCheckTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/LevelIdCheckTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,16 +22,16 @@ package org.jboss.logging.processor.generated; -import org.testng.annotations.AfterMethod; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; /** * @author James R. Perkins */ public class LevelIdCheckTest extends AbstractLoggerTest { - @AfterMethod + @After public void clearHandler() { HANDLER.close(); } @@ -42,10 +42,10 @@ ValidLogger.LOGGER.processingError(new IllegalArgumentException()); ValidLogger.LOGGER.processingError(new IllegalArgumentException(), "generated"); ValidLogger.LOGGER.processingError(this, "invalid reference"); - Assert.assertEquals(parseLoggerId(HANDLER.getMessage(0)), 203); - Assert.assertEquals(parseLoggerId(HANDLER.getMessage(1)), 203); - Assert.assertEquals(parseLoggerId(HANDLER.getMessage(2)), 203); - Assert.assertEquals(parseLoggerId(HANDLER.getMessage(3)), 203); + Assert.assertEquals(203, parseLoggerId(HANDLER.getMessage())); + Assert.assertEquals(203, parseLoggerId(HANDLER.getMessage())); + Assert.assertEquals(203, parseLoggerId(HANDLER.getMessage())); + Assert.assertEquals(203, parseLoggerId(HANDLER.getMessage())); } diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/LoggerVerificationTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/LoggerVerificationTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/LoggerVerificationTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/LoggerVerificationTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -33,9 +33,9 @@ import org.jboss.logging.Logger; import org.jboss.logging.processor.generated.DefaultLogger.CustomFormatter; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; /** * @author James R. Perkins @@ -44,7 +44,7 @@ private static final String NAME = System.getProperty("user.name"); private static final String FILE_NAME_FORMAT = "DefaultLogger.i18n%s.properties"; - @AfterMethod + @After public void clearHandler() { HANDLER.close(); } @@ -64,14 +64,14 @@ logger.invalidSelection("A", "B", "C", "D"); final Properties properties = findFile(String.format(FILE_NAME_FORMAT, "")); - Assert.assertEquals(properties.size(), HANDLER.size()); - compare(0, "hello", properties, NAME); - compare(1, "howAreYou", properties, NAME); - compare(2, "noFormat", properties); - compare(3, "noFormatWithCause", properties); - compare(4, "formatWith", properties, new CustomFormatter(msg)); - compare(5, "invalidSelection.2", properties, "G", Arrays.toString(values)); - compare(6, "invalidSelection.1", properties, Arrays.toString(values)); + Assert.assertEquals(HANDLER.size(), properties.size()); + compare("hello", properties, NAME); + compare("howAreYou", properties, NAME); + compare("noFormat", properties); + compare("noFormatWithCause", properties); + compare("formatWith", properties, new CustomFormatter(msg)); + compare("invalidSelection.2", properties, "G", Arrays.toString(values)); + compare("invalidSelection.1", properties, Arrays.toString(values)); } @Test @@ -80,9 +80,9 @@ logger.hello(NAME); logger.howAreYou(NAME); final Properties properties = findFile(String.format(FILE_NAME_FORMAT, "_de")); - Assert.assertEquals(properties.size(), HANDLER.size()); - compare(0, "hello", properties, NAME); - compare(1, "howAreYou", properties, NAME); + Assert.assertEquals(HANDLER.size(), properties.size()); + compare("hello", properties, NAME); + compare("howAreYou", properties, NAME); } @Test @@ -91,9 +91,9 @@ logger.hello(NAME); logger.howAreYou(NAME); final Properties properties = findFile(String.format(FILE_NAME_FORMAT, "_fr")); - Assert.assertEquals(properties.size(), HANDLER.size()); - compare(0, "hello", properties, NAME); - compare(1, "howAreYou", properties, NAME); + Assert.assertEquals(HANDLER.size(), properties.size()); + compare("hello", properties, NAME); + compare("howAreYou", properties, NAME); } @Test @@ -102,9 +102,9 @@ logger.hello(NAME); logger.howAreYou(NAME); final Properties properties = findFile(String.format(FILE_NAME_FORMAT, "_es")); - Assert.assertEquals(properties.size(), HANDLER.size()); - compare(0, "hello", properties, NAME); - compare(1, "howAreYou", properties, NAME); + Assert.assertEquals(HANDLER.size(), properties.size()); + compare("hello", properties, NAME); + compare("howAreYou", properties, NAME); } @Test @@ -113,9 +113,9 @@ logger.hello(NAME); logger.howAreYou(NAME); final Properties properties = findFile(String.format(FILE_NAME_FORMAT, "_ja")); - Assert.assertEquals(properties.size(), HANDLER.size()); - compare(0, "hello", properties, NAME); - compare(1, "howAreYou", properties, NAME); + Assert.assertEquals(HANDLER.size(), properties.size()); + compare("hello", properties, NAME); + compare("howAreYou", properties, NAME); } @Test @@ -127,28 +127,28 @@ final Date date = new Date(); logger.dukesBirthday(date); logger.dukesBirthdayFailure(date); - compare(0, "dukesBirthday", es, date); - compare(1, "dukesBirthdayFailure", en, date); + compare("dukesBirthday", es, date); + compare("dukesBirthdayFailure", en, date); logger.stringInt("string", 1); logger.stringIntFailure("string", 1); - compare(2, "stringInt", es, "string", 1); - compare(3, "stringIntFailure", en, "string", 1); + compare("stringInt", es, "string", 1); + compare("stringIntFailure", en, "string", 1); logger.repeat("invalid"); logger.repeatFailure("invalid"); - compare(4, "repeat", es, "invalid"); - compare(5, "repeatFailure", en, "invalid"); + compare("repeat", es, "invalid"); + compare("repeatFailure", en, "invalid"); } private static DefaultLogger getLogger(final Locale locale) { return Logger.getMessageLogger(DefaultLogger.class, CATEGORY, locale); } - private void compare(final int handlerIndex, final String key, final Properties properties, final Object... params) { + private void compare(final String key, final Properties properties, final Object... params) throws InterruptedException { final String expectedMessage = getFormattedProperty(key, properties, params); - final String loggedMessage = HANDLER.getMessage(handlerIndex).replaceAll(LOGGER_ID_PATTERN, ""); - Assert.assertEquals(loggedMessage, expectedMessage); + final String loggedMessage = HANDLER.getMessage().replaceAll(LOGGER_ID_PATTERN, ""); + Assert.assertEquals(expectedMessage, loggedMessage); } private String getFormattedProperty(final String key, final Properties properties, final Object... params) { diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/LogOnceTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/LogOnceTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/LogOnceTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/LogOnceTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -29,16 +29,19 @@ import java.util.Map; import org.jboss.logging.Logger; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import org.junit.After; +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; /** * @author James R. Perkins */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class LogOnceTest extends AbstractLoggerTest { - @AfterMethod + @After public void clearHandler() { HANDLER.close(); } @@ -47,25 +50,25 @@ public void logOnce() throws Exception { LogOnceLogger.LOGGER.deprecated("test.property"); LogOnceLogger.LOGGER.deprecated("test.property"); - Assert.assertEquals(HANDLER.size(), 1, "Only one message should have been logged"); + Assert.assertEquals("Only one message should have been logged", 1, HANDLER.size()); LogOnceLogger.LOGGER.deprecated("test.property", "new.test.property"); - Assert.assertEquals(HANDLER.size(), 1, "Only one message should have been logged"); + Assert.assertEquals("Only one message should have been logged", 1, HANDLER.size()); final Method method = LogOnceTest.class.getMethod("logOnce"); LogOnceLogger.LOGGER.deprecated(method); LogOnceLogger.LOGGER.deprecated(method); - Assert.assertEquals(HANDLER.size(), 3, "The message should have been logged twice"); + Assert.assertEquals("The message should have been logged three times", 3, HANDLER.size()); } @Test public void newLogger() throws Exception { final LogOnceLogger logger = Logger.getMessageLogger(LogOnceLogger.class, CATEGORY); logger.deprecated("test.property"); - Assert.assertEquals(HANDLER.size(), 0, "No messages should have been logged"); + Assert.assertEquals("No messages should have been logged", 0, HANDLER.size()); logger.deprecated("test.property", "new.test.property"); - Assert.assertEquals(HANDLER.size(), 0, "No messages should have been logged"); + Assert.assertEquals("No messages should have been logged", 0, HANDLER.size()); } @@ -74,17 +77,17 @@ final List listCache = Arrays.asList("item1", "item2", "item3"); LogOnceLogger.LOGGER.cacheSizeChanged(listCache); LogOnceLogger.LOGGER.cacheSizeChanged(listCache); - Assert.assertEquals(HANDLER.size(), 1, "Only one message should have been logged"); + Assert.assertEquals("Only one message should have been logged", 1, HANDLER.size()); final Map mapCache = new HashMap<>(); for (int i = 0; i < 5; i++) { mapCache.put("item" + i, "value " + i); } LogOnceLogger.LOGGER.cacheSizeChanged(mapCache); - Assert.assertEquals(HANDLER.size(), 1, "Only one message should have been logged"); + Assert.assertEquals("Only one message should have been logged", 1, HANDLER.size()); LogOnceLogger.LOGGER.cacheSizeChanged("item1", "item2", "item3", "item4"); LogOnceLogger.LOGGER.cacheSizeChanged("item1", "item2", "item3", "item4", "item5", "item6"); - Assert.assertEquals(HANDLER.size(), 3, "The message should have been logged twice"); + Assert.assertEquals("The message should have been logged twice", 3, HANDLER.size()); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/MessageListHandler.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/MessageListHandler.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/MessageListHandler.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/MessageListHandler.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* - * JBoss, Home of Professional Open Source. - * Copyright 2016, Red Hat, Inc., and individual contributors - * as indicated by the @author tags. See the copyright.txt file in the - * distribution for a full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package org.jboss.logging.processor.generated; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.jboss.logmanager.ExtHandler; -import org.jboss.logmanager.ExtLogRecord; - -/** - * @author James R. Perkins - */ -class MessageListHandler extends ExtHandler { - private final List messages = new CopyOnWriteArrayList(); - - @Override - protected void doPublish(final ExtLogRecord record) { - super.doPublish(record); - messages.add(record.getFormattedMessage()); - } - - String getMessage(final int index) { - return messages.get(index); - } - - int size() { - return messages.size(); - } - - @Override - public void flush() { - // no-op - } - - @Override - public void close() throws SecurityException { - messages.clear(); - } -} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/MessagesTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/MessagesTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/MessagesTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/MessagesTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,38 +22,234 @@ package org.jboss.logging.processor.generated; +import java.io.IOException; import java.text.MessageFormat; +import java.util.Arrays; +import java.util.function.Supplier; +import org.jboss.logging.processor.generated.ValidMessages.CustomException; +import org.jboss.logging.processor.generated.ValidMessages.LoggingException; import org.jboss.logging.processor.generated.ValidMessages.StringOnlyException; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.Assert; +import org.junit.Test; /** * @author James R. Perkins */ public class MessagesTest { + private static final String FORMATTED_TEST_MSG = String.format(ValidMessages.TEST_MSG); + @Test public void testFormats() { - Assert.assertEquals(ValidMessages.MESSAGES.testWithNewLine(), String.format(ValidMessages.TEST_MSG)); - Assert.assertEquals(ValidMessages.MESSAGES.noFormat(), ValidMessages.TEST_MSG); - Assert.assertEquals(ValidMessages.MESSAGES.noFormatException(new IllegalArgumentException()).getLocalizedMessage(), ValidMessages.TEST_MSG); + Assert.assertEquals(FORMATTED_TEST_MSG, ValidMessages.MESSAGES.testWithNewLine()); + Assert.assertEquals(ValidMessages.TEST_MSG, ValidMessages.MESSAGES.noFormat()); + Assert.assertEquals(ValidMessages.TEST_MSG, ValidMessages.MESSAGES.noFormatException(new IllegalArgumentException()).getLocalizedMessage()); final int value = 10; - Assert.assertEquals(ValidMessages.MESSAGES.fieldMessage(value).value, value); - Assert.assertEquals(ValidMessages.MESSAGES.paramMessage(value).value, value); - Assert.assertEquals(ValidMessages.MESSAGES.propertyMessage(value).value, value); + Assert.assertEquals(value, ValidMessages.MESSAGES.fieldMessage(value).value); + Assert.assertEquals(value, ValidMessages.MESSAGES.paramMessage(value).value); + Assert.assertEquals(value, ValidMessages.MESSAGES.propertyMessage(value).value); final StringOnlyException e = ValidMessages.MESSAGES.stringOnlyException(new RuntimeException()); - Assert.assertEquals(e.getMessage(), String.format(ValidMessages.TEST_MSG)); + Assert.assertEquals(FORMATTED_TEST_MSG, e.getMessage()); Assert.assertNotNull(e.getCause()); - Assert.assertTrue(ValidMessages.MESSAGES.invalidCredentials() instanceof IllegalArgumentException, "Incorrect type constructed"); + Assert.assertTrue("Incorrect type constructed", ValidMessages.MESSAGES.invalidCredentials() instanceof IllegalArgumentException); final String arg1 = "value-1"; final String arg2 = "value-2"; final String messageFormatMessage = MessageFormat.format(ValidMessages.TEST_MESSAGE_FORMAT, arg1, arg2); - Assert.assertEquals(ValidMessages.MESSAGES.testMessageFormat(arg1, arg2), messageFormatMessage); - Assert.assertEquals(ValidMessages.MESSAGES.testMessageFormatException(arg1, arg2).getMessage(), messageFormatMessage); + Assert.assertEquals(messageFormatMessage, ValidMessages.MESSAGES.testMessageFormat(arg1, arg2)); + Assert.assertEquals(messageFormatMessage, ValidMessages.MESSAGES.testMessageFormatException(arg1, arg2).getMessage()); + } + + @Test + public void testSuppressed() { + final IllegalArgumentException e1 = new IllegalArgumentException("First exception"); + final IllegalStateException e2 = new IllegalStateException("Second exception"); + final RuntimeException e3 = new RuntimeException("Third exception"); + + RuntimeException expected = new RuntimeException(ValidMessages.MULTIPLE_ERRORS); + expected.addSuppressed(e1); + expected.addSuppressed(e2); + expected.addSuppressed(e3); + + RuntimeException actual = ValidMessages.MESSAGES.multipleErrors(e1, e2, e3); + compare(expected.getSuppressed(), actual.getSuppressed()); + + actual = ValidMessages.MESSAGES.multipleErrorsCollection(Arrays.asList(e1, e2, e3)); + compare(expected.getSuppressed(), actual.getSuppressed()); + + expected = new RuntimeException(ValidMessages.SUPPRESSED_ERROR); + expected.addSuppressed(e1); + + actual = ValidMessages.MESSAGES.suppressedError(e1); + compare(expected.getSuppressed(), actual.getSuppressed()); + + expected = new RuntimeException(ValidMessages.SUPPRESSED_ERRORS); + expected.addSuppressed(e1); + expected.addSuppressed(e2); + + actual = ValidMessages.MESSAGES.suppressedErrors(e1, e2); + compare(expected.getSuppressed(), actual.getSuppressed()); + + + } + + @Test + public void testPropertyConstants() { + Assert.assertEquals(true, MethodMessageConstants.MESSAGES.booleanProperty().value); + Assert.assertEquals("x".getBytes()[0], MethodMessageConstants.MESSAGES.byteProperty().value); + Assert.assertEquals(MethodMessageConstants.testChar, MethodMessageConstants.MESSAGES.charProperty().value); + Assert.assertEquals(MethodMessageConstants.ValueType.class, MethodMessageConstants.MESSAGES.classProperty().value); + Assert.assertEquals(Double.MAX_VALUE, MethodMessageConstants.MESSAGES.douleProperty().value, 0); + Assert.assertEquals(Float.MAX_VALUE, MethodMessageConstants.MESSAGES.floatProperty().value, 0); + Assert.assertEquals(Integer.MAX_VALUE, MethodMessageConstants.MESSAGES.intProperty().value); + Assert.assertEquals(Long.MAX_VALUE, MethodMessageConstants.MESSAGES.longProperty().value); + Assert.assertEquals(Short.MAX_VALUE, MethodMessageConstants.MESSAGES.shortProperty().value); + Assert.assertEquals(MethodMessageConstants.stringTest, MethodMessageConstants.MESSAGES.stringProperty().value); + MethodMessageConstants.TypeException exception = MethodMessageConstants.MESSAGES.multiProperty(); + Assert.assertEquals(String.class, exception.type); + Assert.assertEquals(MethodMessageConstants.stringTest, exception.value); + exception = MethodMessageConstants.MESSAGES.repeatableProperty(); + Assert.assertEquals(String.class, exception.type); + Assert.assertEquals(MethodMessageConstants.stringTest, exception.value); + } + + @Test + public void testFieldConstants() { + Assert.assertEquals(true, MethodMessageConstants.MESSAGES.booleanField().value); + Assert.assertEquals("x".getBytes()[0], MethodMessageConstants.MESSAGES.byteField().value); + Assert.assertEquals(MethodMessageConstants.testChar, MethodMessageConstants.MESSAGES.charField().value); + Assert.assertEquals(MethodMessageConstants.ValueType.class, MethodMessageConstants.MESSAGES.classField().value); + Assert.assertEquals(Double.MAX_VALUE, MethodMessageConstants.MESSAGES.douleField().value, 0); + Assert.assertEquals(Float.MAX_VALUE, MethodMessageConstants.MESSAGES.floatField().value, 0); + Assert.assertEquals(Integer.MAX_VALUE, MethodMessageConstants.MESSAGES.intField().value); + Assert.assertEquals(Long.MAX_VALUE, MethodMessageConstants.MESSAGES.longField().value); + Assert.assertEquals(Short.MAX_VALUE, MethodMessageConstants.MESSAGES.shortField().value); + Assert.assertEquals(MethodMessageConstants.stringTest, MethodMessageConstants.MESSAGES.stringField().value); + MethodMessageConstants.TypeException exception = MethodMessageConstants.MESSAGES.multiField(); + Assert.assertEquals(String.class, exception.type); + Assert.assertEquals(MethodMessageConstants.stringTest, exception.value); + exception = MethodMessageConstants.MESSAGES.repeatableField(); + Assert.assertEquals(String.class, exception.type); + Assert.assertEquals(MethodMessageConstants.stringTest, exception.value); + } + + @Test + public void testSupplierReturnType() throws Exception { + Supplier runtimeExceptionSupplier = ValidMessages.MESSAGES.testSupplierRuntimeException(); + Assert.assertNotNull(runtimeExceptionSupplier); + RuntimeException runtimeException = runtimeExceptionSupplier.get(); + Assert.assertEquals(FORMATTED_TEST_MSG, runtimeException.getMessage()); + Assert.assertEquals(RuntimeException.class, runtimeException.getClass()); + + Assert.assertEquals(ValidMessages.MESSAGES.testSupplierString().get(), FORMATTED_TEST_MSG); + + runtimeExceptionSupplier = ValidMessages.MESSAGES.invalidCredentialsSupplier(); + Assert.assertNotNull(runtimeExceptionSupplier); + runtimeException = runtimeExceptionSupplier.get(); + Assert.assertEquals(IllegalArgumentException.class, runtimeException.getClass()); + + // Test suppliers with fields/properties + int value = 5; + Supplier customExceptionSupplier = ValidMessages.MESSAGES.fieldMessageSupplier(value); + Assert.assertNotNull(customExceptionSupplier); + CustomException customException = customExceptionSupplier.get(); + Assert.assertEquals(FORMATTED_TEST_MSG, customException.getMessage()); + Assert.assertEquals(CustomException.class, customException.getClass()); + Assert.assertEquals(value, customException.value); + + value = 20; + customExceptionSupplier = ValidMessages.MESSAGES.propertyMessageSupplier(value); + Assert.assertNotNull(customExceptionSupplier); + customException = customExceptionSupplier.get(); + Assert.assertEquals(FORMATTED_TEST_MSG, customException.getMessage()); + Assert.assertEquals(CustomException.class, customException.getClass()); + Assert.assertEquals(value, customException.value); + + } + + @Test + public void testFunctionProducerMessages() throws Exception { + RuntimeException runtimeException = ValidMessages.MESSAGES.operationFailed(IllegalArgumentException::new, "start"); + Assert.assertEquals(IllegalArgumentException.class, runtimeException.getClass()); + Assert.assertEquals(String.format(ValidMessages.TEST_OP_FAILED_MSG, "start"), runtimeException.getMessage()); + + IOException ioException = ValidMessages.MESSAGES.operationFailed(IOException::new, "query"); + Assert.assertEquals(String.format(ValidMessages.TEST_OP_FAILED_MSG, "query"), ioException.getMessage()); + + final Supplier supplier = ValidMessages.MESSAGES.supplierFunction(IllegalStateException::new); + runtimeException = supplier.get(); + Assert.assertEquals(IllegalStateException.class, runtimeException.getClass()); + Assert.assertEquals(FORMATTED_TEST_MSG, runtimeException.getMessage()); + + // Test functions with fields/properties + int value = 5; + CustomException customException = ValidMessages.MESSAGES.fieldMessageFunction(CustomException::new, value); + Assert.assertEquals(FORMATTED_TEST_MSG, customException.getMessage()); + Assert.assertEquals(CustomException.class, customException.getClass()); + Assert.assertEquals(customException.value, value); + + value = 20; + customException = ValidMessages.MESSAGES.propertyMessageFunction(CustomException::new, value); + Assert.assertEquals(FORMATTED_TEST_MSG, customException.getMessage()); + Assert.assertEquals(CustomException.class, customException.getClass()); + Assert.assertEquals(value, customException.value); + } + + @Test + public void testBiFunctionProducerMessages() throws Exception { + final RuntimeException cause = new RuntimeException("This is the cause"); + RuntimeException runtimeException = ValidMessages.MESSAGES.operationFailed(IllegalArgumentException::new, cause, "start"); + Assert.assertEquals(IllegalArgumentException.class, runtimeException.getClass()); + Assert.assertEquals(String.format(ValidMessages.TEST_OP_FAILED_MSG, "start"), runtimeException.getMessage()); + Assert.assertEquals(cause, runtimeException.getCause()); + + runtimeException = ValidMessages.MESSAGES.throwableStringBiFunction(LoggingException::new, cause); + Assert.assertEquals(LoggingException.class, runtimeException.getClass()); + Assert.assertEquals(cause, runtimeException.getCause()); + + final Supplier supplier = ValidMessages.MESSAGES.throwableStringBiFunctionSupplier(IllegalArgumentException::new, cause); + runtimeException = supplier.get(); + Assert.assertEquals(IllegalArgumentException.class, runtimeException.getClass()); + Assert.assertEquals(FORMATTED_TEST_MSG, runtimeException.getMessage()); + Assert.assertEquals(cause, runtimeException.getCause()); + + } + + private void compare(final T[] a1, final T[] a2) { + Assert.assertTrue(String.format("Expected: %s%n Actual: %s", Arrays.toString(a1), Arrays.toString(a2)), equalsIgnoreOrder(a1, a2)); + } + + private boolean equalsIgnoreOrder(final T[] a1, final T[] a2) { + if (a1.length != a2.length) { + return false; + } + final T[] ca2 = Arrays.copyOf(a2, a2.length); + boolean found = false; + for (T t : a1) { + final int i = search(ca2, t); + if (i >= 0) { + found = true; + ca2[i] = null; + } else { + found = false; + } + if (!found) { + break; + } + } + return found; + } + + private int search(final T[] a, final T key) { + for (int i = 0; i < a.length; i++) { + if (key.equals(a[i])) { + return i; + } + } + return -1; } } diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/MethodMessageConstants.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/MethodMessageConstants.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/MethodMessageConstants.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/MethodMessageConstants.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,303 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.generated; + +import org.jboss.logging.Messages; +import org.jboss.logging.annotations.Field; +import org.jboss.logging.annotations.Fields; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.Properties; +import org.jboss.logging.annotations.Property; + +/** + * @author James R. Perkins + */ +@MessageBundle(projectCode = "CONSTANTS") +public interface MethodMessageConstants { + String TEST_MSG = "Test method message constant"; + MethodMessageConstants MESSAGES = Messages.getBundle(MethodMessageConstants.class); + + // Properties + + @Message(TEST_MSG) + @Property(name = "value", intValue = Integer.MAX_VALUE) + IntTypeException intProperty(); + + @Message(TEST_MSG) + @Property(name = "value", longValue = Long.MAX_VALUE) + LongTypeException longProperty(); + + @Message(TEST_MSG) + @Property(name = "value", shortValue = Short.MAX_VALUE) + ShortTypeException shortProperty(); + + @Message(TEST_MSG) + @Property(name = "value", doubleValue = Double.MAX_VALUE) + DoubleTypeException douleProperty(); + + @Message(TEST_MSG) + @Property(name = "value", floatValue = Float.MAX_VALUE) + FloatTypeException floatProperty(); + + @Message(TEST_MSG) + @Property(name = "value", booleanValue = true) + BooleanTypeException booleanProperty(); + + @Message(TEST_MSG) + @Property(name = "value", charValue = testChar) + CharTypeException charProperty(); + + @Message(TEST_MSG) + @Property(name = "value", byteValue = (byte) 'x') + ByteTypeException byteProperty(); + + @Message(TEST_MSG) + @Property(name = "value", classValue = ValueType.class) + ClassTypeException classProperty(); + + @Message(TEST_MSG) + @Property(name = "value", stringValue = stringTest) + StringTypeException stringProperty(); + + @Message(TEST_MSG) + @Property(name = "value", stringValue = stringTest) + @Property(name = "type", classValue = String.class) + TypeException repeatableProperty(); + + @Message(TEST_MSG) + @Properties({ + @Property(name = "value", stringValue = stringTest), + @Property(name = "type", classValue = String.class) + }) + TypeException multiProperty(); + + // Fields + + @Message(TEST_MSG) + @Field(name = "value", intValue = Integer.MAX_VALUE) + IntTypeException intField(); + + @Message(TEST_MSG) + @Field(name = "value", longValue = Long.MAX_VALUE) + LongTypeException longField(); + + @Message(TEST_MSG) + @Field(name = "value", shortValue = Short.MAX_VALUE) + ShortTypeException shortField(); + + @Message(TEST_MSG) + @Field(name = "value", doubleValue = Double.MAX_VALUE) + DoubleTypeException douleField(); + + @Message(TEST_MSG) + @Field(name = "value", floatValue = Float.MAX_VALUE) + FloatTypeException floatField(); + + @Message(TEST_MSG) + @Field(name = "value", booleanValue = true) + BooleanTypeException booleanField(); + + char testChar = 'c'; + + @Message(TEST_MSG) + @Field(name = "value", charValue = testChar) + CharTypeException charField(); + + @Message(TEST_MSG) + @Field(name = "value", byteValue = (byte) 'x') + ByteTypeException byteField(); + + @Message(TEST_MSG) + @Field(name = "value", classValue = ValueType.class) + ClassTypeException classField(); + + String stringTest = "test"; + + @Message(TEST_MSG) + @Field(name = "value", stringValue = stringTest) + StringTypeException stringField(); + + @Message(TEST_MSG) + @Field(name = "value", stringValue = stringTest) + @Field(name = "type", classValue = String.class) + TypeException repeatableField(); + + @Message(TEST_MSG) + @Fields({ + @Field(name = "value", stringValue = stringTest), + @Field(name = "type", classValue = String.class) + }) + TypeException multiField(); + + class TypeException extends RuntimeException { + public Class type; + public Object value; + + public TypeException() { + } + + public TypeException(final String msg) { + super(msg); + } + + public TypeException(final Throwable t) { + super(t); + } + + public TypeException(final String msg, final Throwable t) { + super(msg, t); + } + + public void setValue(final Object value) { + this.value = value; + } + + public void setType(final Class type) { + this.type = type; + } + } + + class IntTypeException extends RuntimeException { + public int value; + + public IntTypeException(final String message) { + super(message); + } + + public void setValue(final Integer value) { + this.value = value; + } + } + + class LongTypeException extends RuntimeException { + public long value; + + public LongTypeException(final String message) { + super(message); + } + + public void setValue(final long value) { + this.value = value; + } + } + + class ShortTypeException extends RuntimeException { + public short value; + + public ShortTypeException(final String message) { + super(message); + } + + public void setValue(final short value) { + this.value = value; + } + } + + class FloatTypeException extends RuntimeException { + public float value; + + public FloatTypeException(final String message) { + super(message); + } + + public void setValue(final float value) { + this.value = value; + } + } + + class DoubleTypeException extends RuntimeException { + public double value; + + public DoubleTypeException(final String message) { + super(message); + } + + public void setValue(final double value) { + this.value = value; + } + } + + class BooleanTypeException extends RuntimeException { + public boolean value; + + public BooleanTypeException(final String message) { + super(message); + } + + public void setValue(final boolean value) { + this.value = value; + } + } + + class ByteTypeException extends RuntimeException { + public byte value; + + public ByteTypeException(final String message) { + super(message); + } + + public void setValue(final byte value) { + this.value = value; + } + } + + class CharTypeException extends RuntimeException { + public char value; + + public CharTypeException(final String message) { + super(message); + } + + public void setValue(final char value) { + this.value = value; + } + } + + class ClassTypeException extends RuntimeException { + public Class value; + + public ClassTypeException(final String message) { + super(message); + } + + public void setValue(final Class value) { + this.value = value; + } + } + + class StringTypeException extends RuntimeException { + public String value; + + public StringTypeException(final String message) { + super(message); + } + + public void setValue(final String value) { + this.value = value; + } + } + + class ValueType { + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/QueuedMessageHandler.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/QueuedMessageHandler.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/QueuedMessageHandler.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/QueuedMessageHandler.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,68 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.generated; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; + +import org.jboss.logmanager.ExtHandler; +import org.jboss.logmanager.ExtLogRecord; + +/** + * @author James R. Perkins + */ +class QueuedMessageHandler extends ExtHandler { + //private final List messages = Collections.synchronizedList(new ArrayList<>()); + private final BlockingQueue messages = new LinkedBlockingQueue<>(); + + @Override + protected void doPublish(final ExtLogRecord record) { + messages.add(record.getFormattedMessage()); + } + + /** + * Polls the message from queue waiting for up to 1 second for the message to appear. + * + * @return the message + * + * @throws InterruptedException if the poll was interrupted + */ + String getMessage() throws InterruptedException { + return messages.poll(1, TimeUnit.SECONDS); + } + + int size() { + return messages.size(); + } + + @Override + public void flush() { + // no-op + } + + @Override + public void close() throws SecurityException { + messages.clear(); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/RootLocaleLogger.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/RootLocaleLogger.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/RootLocaleLogger.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/RootLocaleLogger.java 2017-08-09 18:02:31.000000000 +0000 @@ -43,4 +43,4 @@ @Message(id = 50, value = "Authorisation failed for %s") RuntimeException authFailed(String user); -} \ No newline at end of file +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/SignatureMessages.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/SignatureMessages.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/SignatureMessages.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/SignatureMessages.java 2017-08-09 18:02:31.000000000 +0000 @@ -29,6 +29,7 @@ import org.jboss.logging.annotations.Message; import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.annotations.Param; +import org.jboss.logging.annotations.Signature; import org.jboss.logging.processor.util.Objects; import org.jboss.logging.processor.util.Objects.HashCodeBuilder; @@ -46,6 +47,9 @@ RedirectException redirect(@Cause Throwable cause, @Param int responseCode, @Param String location); + @Signature({String.class, String.class}) + RedirectException redirect(@Cause Throwable cause, @Param String location); + @Message(TEST_MSG) TestException test(); @@ -56,6 +60,9 @@ InvalidTextException invalidText(@Cause Throwable cause, @Param String text); + @Signature(causeIndex = 1, messageIndex = 3, value = {int.class, Throwable.class, String.class, String.class}) + InvalidTextException invalidText(@Param int position, @Cause Throwable cause, @Param String text); + @SuppressWarnings("unused") static class RedirectException extends RuntimeException { final int statusCode; @@ -81,6 +88,12 @@ this.location = location; } + public RedirectException(final String msg, final String location) { + super(msg); + this.statusCode = 301; + this.location = location; + } + @Override public int hashCode() { return HashCodeBuilder.builder() @@ -165,14 +178,17 @@ @SuppressWarnings("unused") static class InvalidTextException extends RuntimeException { final String value; + final int position; public InvalidTextException(final String value) { this.value = value; + position = -1; } public InvalidTextException(final String msg, final String value) { super(msg); this.value = value; + position = -1; } public InvalidTextException(final Throwable cause) { @@ -186,12 +202,24 @@ public InvalidTextException(final String msg, final Throwable cause, final String value) { super(msg, cause); this.value = value; + position = -1; + } + + public InvalidTextException(final int position, final Throwable cause, final String value, final String msg) { + super(msg, cause); + this.value = value; + this.position = position; + } + + public InvalidTextException(final Integer position, final Throwable cause, final String value, final String msg) { + throw new IllegalStateException("Should never be chosen"); } @Override public int hashCode() { return HashCodeBuilder.builder() .add(value) + .add(position) .add(getMessage()) .add(getCause()) .toHashCode(); @@ -207,6 +235,7 @@ } final InvalidTextException other = (InvalidTextException) obj; return areEqual(value, other.value) && + areEqual(position, other.position) && areEqual(getMessage(), other.getMessage()) && areEqual(getCause(), other.getCause()); } @@ -215,6 +244,7 @@ public String toString() { return Objects.ToStringBuilder.of(this) .add("value", value) + .add("position", position) .add("message", getMessage()) .add("cause", getCause()) .toString(); diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ThrowableSignatureTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ThrowableSignatureTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ThrowableSignatureTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ThrowableSignatureTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -25,8 +25,8 @@ import org.jboss.logging.processor.generated.SignatureMessages.InvalidTextException; import org.jboss.logging.processor.generated.SignatureMessages.RedirectException; import org.jboss.logging.processor.generated.SignatureMessages.TestException; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.Assert; +import org.junit.Test; /** * @author James R. Perkins @@ -41,19 +41,24 @@ final int code = 307; final String location = "foo"; RedirectException redirectExpected = new RedirectException(formattedMessage, code, location); - Assert.assertEquals(SignatureMessages.MESSAGES.redirect(code, location), redirectExpected); + Assert.assertEquals(redirectExpected, SignatureMessages.MESSAGES.redirect(code, location)); + redirectExpected = new RedirectException(formattedMessage, location); + redirectExpected.initCause(cause); + Assert.assertEquals(redirectExpected, SignatureMessages.MESSAGES.redirect(cause, location)); redirectExpected = new RedirectException(formattedMessage, cause, code, location); - Assert.assertEquals(SignatureMessages.MESSAGES.redirect(cause, code, location), redirectExpected); + Assert.assertEquals(redirectExpected, SignatureMessages.MESSAGES.redirect(cause, code, location)); TestException testExpected = new TestException(formattedMessage); - Assert.assertEquals(SignatureMessages.MESSAGES.test(), testExpected); + Assert.assertEquals(testExpected, SignatureMessages.MESSAGES.test()); testExpected = new TestException(formattedMessage, cause); - Assert.assertEquals(SignatureMessages.MESSAGES.test(cause), testExpected); + Assert.assertEquals(testExpected, SignatureMessages.MESSAGES.test(cause)); final String invalidText = "invalid"; InvalidTextException invalidTextExpected = new InvalidTextException(formattedMessage, invalidText); - Assert.assertEquals(SignatureMessages.MESSAGES.invalidText(invalidText), invalidTextExpected); + Assert.assertEquals(invalidTextExpected, SignatureMessages.MESSAGES.invalidText(invalidText)); invalidTextExpected = new InvalidTextException(formattedMessage, cause, invalidText); - Assert.assertEquals(SignatureMessages.MESSAGES.invalidText(cause, invalidText), invalidTextExpected); + Assert.assertEquals(invalidTextExpected, SignatureMessages.MESSAGES.invalidText(cause, invalidText)); + invalidTextExpected = new InvalidTextException(3, cause, invalidText, formattedMessage); + Assert.assertEquals(invalidTextExpected, SignatureMessages.MESSAGES.invalidText(3, cause, invalidText)); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/TransformTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/TransformTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/TransformTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/TransformTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -27,14 +27,13 @@ import java.util.HashMap; import java.util.Map; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.Assert; +import org.junit.Test; /** * @author James R. Perkins */ public class TransformTest extends AbstractLoggerTest { - int pos = 0; @Test public void testLog() throws Exception { @@ -42,125 +41,125 @@ // Log strings final String s = "This is a test string"; TransformLogger.LOGGER.logClassHashCode(s); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, s.getClass().hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, s.getClass().hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logClassIdentityHashCode(s); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s.getClass()))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s.getClass())), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectClass(s); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.GET_CLASS_MSG, s.getClass())); + Assert.assertEquals(String.format(TransformLogger.GET_CLASS_MSG, s.getClass()), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectHashCode(s); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, s.hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, s.hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectIdentityHashCode(s); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s)), HANDLER.getMessage()); TransformLogger.LOGGER.logSize(s); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.SIZE_MSG, s.length())); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, s.length()), HANDLER.getMessage()); // Log collections final Collection c = Arrays.asList("test"); TransformLogger.LOGGER.logClassHashCode(c); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, c.getClass().hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, c.getClass().hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logClassIdentityHashCode(c); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c.getClass()))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c.getClass())), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectHashCode(c); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, c.hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, c.hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectIdentityHashCode(c); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c)), HANDLER.getMessage()); TransformLogger.LOGGER.logSize(c); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.SIZE_MSG, c.size())); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, c.size()), HANDLER.getMessage()); // Log an array final Object[] array = {"test1", "test2", "test3"}; TransformLogger.LOGGER.logClassHashCode(array); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, array.getClass().hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, array.getClass().hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logClassIdentityHashCode(array); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array.getClass()))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array.getClass())), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectClass(array); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.GET_CLASS_MSG, array.getClass())); + Assert.assertEquals(String.format(TransformLogger.GET_CLASS_MSG, array.getClass()), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectHashCode(array); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(array))); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(array)), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectIdentityHashCode(array); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array)), HANDLER.getMessage()); TransformLogger.LOGGER.logSize(array); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.SIZE_MSG, array.length)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, array.length), HANDLER.getMessage()); // Log vararg array final String[] sArray = {"test1", "test2", "test3"}; TransformLogger.LOGGER.logClassHashCode(sArray); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, sArray.getClass().hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, sArray.getClass().hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logClassIdentityHashCode(sArray); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray.getClass()))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray.getClass())), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectClass(sArray); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.GET_CLASS_MSG, sArray.getClass())); + Assert.assertEquals(String.format(TransformLogger.GET_CLASS_MSG, sArray.getClass()), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectHashCode(sArray); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(sArray))); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(sArray)), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectIdentityHashCode(sArray); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray)), HANDLER.getMessage()); TransformLogger.LOGGER.logSize(sArray); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.SIZE_MSG, sArray.length)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, sArray.length), HANDLER.getMessage()); // Log a map - final Map map = new HashMap(); + final Map map = new HashMap<>(); for (int i = 0; i < 10; i++) { map.put("key" + i, "value" + i); } TransformLogger.LOGGER.logClassHashCode(map); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, map.getClass().hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, map.getClass().hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logClassIdentityHashCode(map); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map.getClass()))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map.getClass())), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectHashCode(map); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.HASH_CODE_MSG, map.hashCode())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, map.hashCode()), HANDLER.getMessage()); TransformLogger.LOGGER.logObjectIdentityHashCode(map); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map))); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map)), HANDLER.getMessage()); TransformLogger.LOGGER.logSize(map); - Assert.assertEquals(HANDLER.getMessage(pos++), String.format(TransformLogger.SIZE_MSG, map.size())); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, map.size()), HANDLER.getMessage()); } @Test public void testMessage() throws Exception { // Log strings final String s = "This is a test string"; - Assert.assertEquals(TransformMessages.MESSAGES.msgClassHashCode(s), String.format(TransformLogger.HASH_CODE_MSG, s.getClass().hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgClassIdentityHashCode(s), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s.getClass()))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectClass(s), String.format(TransformLogger.GET_CLASS_MSG, s.getClass())); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectHashCode(s), String.format(TransformLogger.HASH_CODE_MSG, s.hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectIdentityHashCode(s), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s))); - Assert.assertEquals(TransformMessages.MESSAGES.msgSize(s), String.format(TransformLogger.SIZE_MSG, s.length())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, s.getClass().hashCode()), TransformMessages.MESSAGES.msgClassHashCode(s)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s.getClass())), TransformMessages.MESSAGES.msgClassIdentityHashCode(s)); + Assert.assertEquals(String.format(TransformLogger.GET_CLASS_MSG, s.getClass()), TransformMessages.MESSAGES.msgObjectClass(s)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, s.hashCode()), TransformMessages.MESSAGES.msgObjectHashCode(s)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(s)), TransformMessages.MESSAGES.msgObjectIdentityHashCode(s)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, s.length()), TransformMessages.MESSAGES.msgSize(s)); // Log collections final Collection c = Arrays.asList("test"); - Assert.assertEquals(TransformMessages.MESSAGES.msgClassHashCode(c), String.format(TransformLogger.HASH_CODE_MSG, c.getClass().hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgClassIdentityHashCode(c), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c.getClass()))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectHashCode(c), String.format(TransformLogger.HASH_CODE_MSG, c.hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectIdentityHashCode(c), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c))); - Assert.assertEquals(TransformMessages.MESSAGES.msgSize(c), String.format(TransformLogger.SIZE_MSG, c.size())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, c.getClass().hashCode()), TransformMessages.MESSAGES.msgClassHashCode(c)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c.getClass())), TransformMessages.MESSAGES.msgClassIdentityHashCode(c)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, c.hashCode()), TransformMessages.MESSAGES.msgObjectHashCode(c)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(c)), TransformMessages.MESSAGES.msgObjectIdentityHashCode(c)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, c.size()), TransformMessages.MESSAGES.msgSize(c)); // Log an array final Object[] array = {"test1", "test2", "test3"}; - Assert.assertEquals(TransformMessages.MESSAGES.msgClassHashCode(array), String.format(TransformLogger.HASH_CODE_MSG, array.getClass().hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgClassIdentityHashCode(array), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array.getClass()))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectClass(array), String.format(TransformLogger.GET_CLASS_MSG, array.getClass())); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectHashCode(array), String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(array))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectIdentityHashCode(array), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array))); - Assert.assertEquals(TransformMessages.MESSAGES.msgSize(array), String.format(TransformLogger.SIZE_MSG, array.length)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, array.getClass().hashCode()), TransformMessages.MESSAGES.msgClassHashCode(array)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array.getClass())), TransformMessages.MESSAGES.msgClassIdentityHashCode(array)); + Assert.assertEquals(String.format(TransformLogger.GET_CLASS_MSG, array.getClass()), TransformMessages.MESSAGES.msgObjectClass(array)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(array)), TransformMessages.MESSAGES.msgObjectHashCode(array)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(array)), TransformMessages.MESSAGES.msgObjectIdentityHashCode(array)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, array.length), TransformMessages.MESSAGES.msgSize(array)); // Log vararg array final String[] sArray = {"test1", "test2", "test3"}; - Assert.assertEquals(TransformMessages.MESSAGES.msgClassHashCode(sArray), String.format(TransformLogger.HASH_CODE_MSG, sArray.getClass().hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgClassIdentityHashCode(sArray), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray.getClass()))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectClass(sArray), String.format(TransformLogger.GET_CLASS_MSG, sArray.getClass())); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectHashCode(sArray), String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(sArray))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectIdentityHashCode(sArray), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray))); - Assert.assertEquals(TransformMessages.MESSAGES.msgSize(sArray), String.format(TransformLogger.SIZE_MSG, sArray.length)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, sArray.getClass().hashCode()), TransformMessages.MESSAGES.msgClassHashCode(sArray)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray.getClass())), TransformMessages.MESSAGES.msgClassIdentityHashCode(sArray)); + Assert.assertEquals(String.format(TransformLogger.GET_CLASS_MSG, sArray.getClass()), TransformMessages.MESSAGES.msgObjectClass(sArray)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, Arrays.hashCode(sArray)), TransformMessages.MESSAGES.msgObjectHashCode(sArray)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(sArray)), TransformMessages.MESSAGES.msgObjectIdentityHashCode(sArray)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, sArray.length), TransformMessages.MESSAGES.msgSize(sArray)); // Log a map - final Map map = new HashMap(); + final Map map = new HashMap<>(); for (int i = 0; i < 10; i++) { map.put("key" + i, "value" + i); } - Assert.assertEquals(TransformMessages.MESSAGES.msgClassHashCode(map), String.format(TransformLogger.HASH_CODE_MSG, map.getClass().hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgClassIdentityHashCode(map), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map.getClass()))); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectHashCode(map), String.format(TransformLogger.HASH_CODE_MSG, map.hashCode())); - Assert.assertEquals(TransformMessages.MESSAGES.msgObjectIdentityHashCode(map), String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map))); - Assert.assertEquals(TransformMessages.MESSAGES.msgSize(map), String.format(TransformLogger.SIZE_MSG, map.size())); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, map.getClass().hashCode()), TransformMessages.MESSAGES.msgClassHashCode(map)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map.getClass())), TransformMessages.MESSAGES.msgClassIdentityHashCode(map)); + Assert.assertEquals(String.format(TransformLogger.HASH_CODE_MSG, map.hashCode()), TransformMessages.MESSAGES.msgObjectHashCode(map)); + Assert.assertEquals(String.format(TransformLogger.IDENTITY_HASH_CODE_MSG, System.identityHashCode(map)), TransformMessages.MESSAGES.msgObjectIdentityHashCode(map)); + Assert.assertEquals(String.format(TransformLogger.SIZE_MSG, map.size()), TransformMessages.MESSAGES.msgSize(map)); } @Test @@ -171,8 +170,8 @@ final String msg2 = "Test message 2"; String expected = String.format(TransformLogger.POS_MSG_1, msg2.length(), msg1.hashCode(), System.identityHashCode(msg1)); TransformLogger.LOGGER.posTest1(msg1, msg2); - Assert.assertEquals(HANDLER.getMessage(pos++), expected); - Assert.assertEquals(TransformMessages.MESSAGES.posTest1(msg1, msg2), expected); + Assert.assertEquals(expected, HANDLER.getMessage()); + Assert.assertEquals(expected, TransformMessages.MESSAGES.posTest1(msg1, msg2)); final Object obj = "Test"; final String msg = "This is a test message"; @@ -180,7 +179,7 @@ final String s2 = "s2"; expected = String.format(TransformLogger.POS_MSG_2, msg.length(), s1, s2, obj.getClass()); TransformLogger.LOGGER.posTest2(obj, msg, s1, s2); - Assert.assertEquals(HANDLER.getMessage(pos++), expected); - Assert.assertEquals(TransformMessages.MESSAGES.posTest2(obj, msg, s1, s2), expected); + Assert.assertEquals(expected, HANDLER.getMessage()); + Assert.assertEquals(expected, TransformMessages.MESSAGES.posTest2(obj, msg, s1, s2)); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ValidMessages.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ValidMessages.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/generated/ValidMessages.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/generated/ValidMessages.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,6 +22,11 @@ package org.jboss.logging.processor.generated; +import java.util.Collection; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; + import org.jboss.logging.Messages; import org.jboss.logging.annotations.Cause; import org.jboss.logging.annotations.ConstructType; @@ -30,7 +35,9 @@ import org.jboss.logging.annotations.Message.Format; import org.jboss.logging.annotations.MessageBundle; import org.jboss.logging.annotations.Param; +import org.jboss.logging.annotations.Producer; import org.jboss.logging.annotations.Property; +import org.jboss.logging.annotations.Suppressed; /** * @author James R. Perkins @@ -69,13 +76,72 @@ @Message("Invalid user id or password") RuntimeException invalidCredentials(); + String SUPPRESSED_ERROR = "Single error occurred"; + + @Message(SUPPRESSED_ERROR) + RuntimeException suppressedError(@Suppressed Throwable t); + + String SUPPRESSED_ERRORS = "Two errors occurred"; + + @Message(SUPPRESSED_ERRORS) + RuntimeException suppressedErrors(@Suppressed Throwable error1, @Suppressed Throwable error2); + + String MULTIPLE_ERRORS = "Multiple errors occurred"; + + @Message(MULTIPLE_ERRORS) + RuntimeException multipleErrors(@Suppressed Throwable... errors); + + String MULTIPLE_ERRORS_COLLECTION = "Multiple errors occurred"; + + @Message(MULTIPLE_ERRORS_COLLECTION) + RuntimeException multipleErrorsCollection(@Suppressed Collection errors); + String TEST_MESSAGE_FORMAT = "A two argument message format test. Argument 1 is {0} argument 2 is {1}."; + @Message(format = Format.MESSAGE_FORMAT, value = TEST_MESSAGE_FORMAT) String testMessageFormat(final String arg1, final String arg2); @Message(format = Format.MESSAGE_FORMAT, value = TEST_MESSAGE_FORMAT) RuntimeException testMessageFormatException(final String arg1, final String arg2); + @Message(value = TEST_MSG) + Supplier testSupplierRuntimeException(); + + @Message(TEST_MSG) + Supplier fieldMessageSupplier(@Field(name = "value") int value); + + @Message(TEST_MSG) + Supplier propertyMessageSupplier(@Property int value); + + @ConstructType(IllegalArgumentException.class) + @Message("Invalid user id or password") + Supplier invalidCredentialsSupplier(); + + @Message(value = TEST_MSG) + Supplier testSupplierString(); + + String TEST_OP_FAILED_MSG = "The operation failed due to %s"; + + @Message(TEST_OP_FAILED_MSG) + T operationFailed(@Producer Function function, String op); + + T operationFailed(@Producer BiFunction function, @Cause Throwable cause, String op); + + @Message(TEST_MSG) + Supplier supplierFunction(@Producer Function function); + + @Message(TEST_MSG) + T fieldMessageFunction(@Producer Function function, @Field(name = "value") int value); + + @Message(TEST_MSG) + T propertyMessageFunction(@Producer Function function, @Property int value); + + @Message(TEST_MSG) + LoggingException throwableStringBiFunction(@Producer BiFunction function, @Cause Exception cause); + + @Message(TEST_MSG) + Supplier throwableStringBiFunctionSupplier(@Producer BiFunction function, @Cause Exception cause); + class CustomException extends RuntimeException { public int value; diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/report/ReportGenerationTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/report/ReportGenerationTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/report/ReportGenerationTest.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/report/ReportGenerationTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,127 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2016, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.report; + +import java.io.IOException; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.validation.SchemaFactory; + +import org.jboss.logging.processor.apt.report.ReportType; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.XMLReader; + +/** + * @author James R. Perkins + */ +public class ReportGenerationTest { + private static String TEST_REPORT_PATH = null; + + @BeforeClass + public static void setUp() { + TEST_REPORT_PATH = System.getProperty("test.report.path"); + } + + @Test + public void testAsciidoc() throws Exception { + final Collection paths = findFiles(ReportType.ASCIIDOC); + // Just ensure they were generated + Assert.assertFalse("No asciidoc files found", paths.isEmpty()); + } + + @Test + public void testXml() throws Exception { + final Collection paths = findFiles(ReportType.XML); + Assert.assertFalse("No XML files found", paths.isEmpty()); + final SAXParserFactory factory = SAXParserFactory.newInstance(); + factory.setNamespaceAware(true); + + final SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + factory.setSchema(schemaFactory.newSchema(getClass().getResource("/schema/logging-report_1_0.xsd"))); + + // Crudely test each XML file + for (Path path : paths) { + final SAXParser parser = factory.newSAXParser(); + + final XMLReader reader = parser.getXMLReader(); + reader.setErrorHandler(new ErrorHandler() { + @Override + public void warning(final SAXParseException exception) throws SAXException { + // ignore + } + + @Override + public void error(final SAXParseException exception) throws SAXException { + fail(exception); + } + + @Override + public void fatalError(final SAXParseException exception) throws SAXException { + fail(exception); + } + + private void fail(final SAXParseException exception) { + Assert.fail(String.format("%s - Line: %d Column: %d%nPath: %s", exception.getMessage(), exception.getLineNumber(), exception.getColumnNumber(), path)); + } + }); + try (final Reader fileReader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { + reader.parse(new InputSource(fileReader)); + } + } + } + + private static Collection findFiles(final ReportType reportType) throws IOException { + + final Path dir = Paths.get(TEST_REPORT_PATH); + final List paths = new ArrayList<>(); + + Files.walkFileTree(dir, new SimpleFileVisitor() { + + @Override + public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { + if (file.toString().endsWith(reportType.getExtension())) { + paths.add(file); + } + return FileVisitResult.CONTINUE; + } + }); + return paths; + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/report/TestReportLogger.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/report/TestReportLogger.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/report/TestReportLogger.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/report/TestReportLogger.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.report; + +import org.jboss.logging.Logger.Level; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; +import org.jboss.logging.annotations.ResolutionDoc; + +/** + * Used for validating the XML for a {@code resolutionUrl} attribute. + * + * @author James R. Perkins + */ +@MessageLogger(projectCode = "RPTL", length = 5) +@ResolutionDoc +public interface TestReportLogger { + + @LogMessage(level = Level.INFO) + @Message(id = 1, value = "Test message") + @ResolutionDoc(suffix = ".html") + void containsUrl(); + + @LogMessage(level = Level.INFO) + @Message("Test message") + void noUrl(); + + @LogMessage(level = Level.INFO) + @Message(id = 2, value = "Test message") + void defaultResolutionUrl(); +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/report/TestReportMessages.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/report/TestReportMessages.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/report/TestReportMessages.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/report/TestReportMessages.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.report; + +import org.jboss.logging.annotations.BaseUrl; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageBundle; +import org.jboss.logging.annotations.ResolutionDoc; + +/** + * Used for validating the XML for a {@code resolutionUrl} attribute. + * @author James R. Perkins + */ +@BaseUrl("http://jboss.org/") +@MessageBundle(projectCode = "RPTM") +public interface TestReportMessages { + + @Message(id = 1, value = "Test message") + @ResolutionDoc + RuntimeException defaultUrl(); + + @Message("Test message") + RuntimeException noUrl(); + + @Message(id = 2, value = "Test message") + @ResolutionDoc + RuntimeException containsUrl(); +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/util/ExpressionsTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/util/ExpressionsTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/util/ExpressionsTest.java 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/util/ExpressionsTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,62 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.logging.processor.util; + +import java.io.IOException; +import java.util.Properties; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author James R. Perkins + */ +public class ExpressionsTest { + + private static final Properties PROPERTIES = new Properties(); + + @BeforeClass + public static void configureProperties() throws IOException { + PROPERTIES.load(ExpressionsTest.class.getResourceAsStream("/expression.properties")); + } + + @Test + public void testEnvironmentVariables() throws Exception { + Assert.assertEquals("envValue", Expressions.resolve(PROPERTIES, "${env.JBOSS_LOGGING_TEST_VAR}")); + Assert.assertEquals("defaultValue", Expressions.resolve(PROPERTIES, "${env.JBOSS_LOGGING_TEST_INVALID:defaultValue}")); + } + + @Test + public void testSystemProperties() { + Assert.assertEquals(System.getProperty("user.home"), Expressions.resolve(PROPERTIES, "${sys.user.home}")); + Assert.assertEquals("sysValue", Expressions.resolve(PROPERTIES, "${sys.test.property}")); + Assert.assertEquals("defaultValue", Expressions.resolve(PROPERTIES, "${sys.invalid.property:defaultValue}")); + } + + @Test + public void testProperties() { + Assert.assertEquals("test property value", Expressions.resolve(PROPERTIES, "${test.property}")); + Assert.assertEquals("defaultValue", Expressions.resolve(PROPERTIES, "${invalid.property:defaultValue}")); + } +} diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/util/VersionComparatorTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/util/VersionComparatorTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/util/VersionComparatorTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/util/VersionComparatorTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,8 +22,8 @@ package org.jboss.logging.processor.util; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.Assert; +import org.junit.Test; /** * Date: 09.11.2011 diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/validation/MessageFormatValidatorTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/validation/MessageFormatValidatorTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/validation/MessageFormatValidatorTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/validation/MessageFormatValidatorTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,9 +22,10 @@ package org.jboss.logging.processor.validation; -import static org.testng.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import org.testng.annotations.Test; +import org.junit.Test; /** * Date: 14.06.2011 @@ -36,10 +37,10 @@ @Test public void validFormats() { MessageFormatValidator validator = MessageFormatValidator.of("Message {} is valid."); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); validator = MessageFormatValidator.of("Parameter {1} is not compatible with {2}."); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); } @Test @@ -51,12 +52,12 @@ @Test public void validateParameterCount() { MessageFormatValidator validator = MessageFormatValidator.of("{}", "Test"); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); validator = MessageFormatValidator.of("{1} {0}", "Test", "Test2"); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); validator = MessageFormatValidator.of("{0} {0}", "Test"); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); } } diff -Nru jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/validation/StringFormatValidatorTest.java jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/validation/StringFormatValidatorTest.java --- jboss-logging-tools-2.0.2/processor/src/test/java/org/jboss/logging/processor/validation/StringFormatValidatorTest.java 2016-11-19 04:13:37.000000000 +0000 +++ jboss-logging-tools-2.1.0/processor/src/test/java/org/jboss/logging/processor/validation/StringFormatValidatorTest.java 2017-08-09 18:02:31.000000000 +0000 @@ -22,12 +22,12 @@ package org.jboss.logging.processor.validation; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.Date; -import org.testng.annotations.Test; +import org.junit.Test; /** * Date: 14.06.2011 @@ -48,7 +48,7 @@ } } StringFormatValidator validator = StringFormatValidator.of(sb.toString()); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); final String[] validFormats = { "%1$s %1$s %1$s", @@ -60,7 +60,7 @@ }; for (String s : validFormats) { validator = StringFormatValidator.of(s); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); } } @@ -73,10 +73,10 @@ @Test public void validateParameterCount() { StringFormatValidator validator = StringFormatValidator.of("%1$s %1$s %1$s", "Test"); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); validator = StringFormatValidator.of("Duke's Birthday: %1$tm %1$te,%1$tY", new Date()); - assertTrue(validator.isValid(), validator.detailMessage()); + assertTrue(validator.detailMessage(), validator.isValid()); validator = StringFormatValidator.of("Duke's Birthday: %1$tm % org.jboss.logging jboss-logging-tools-parent - 2.0.2.Final + 2.1.0.Final ../pom.xml @@ -64,8 +64,8 @@ test - org.testng - testng + junit + junit test @@ -97,11 +97,14 @@ maven-compiler-plugin + **/ExpressionMessagesTest.java + **/ExpressionsTest.java **/LegacyLogger.java **/LegacyLoggerTest.java **/LegacyMessages.java **/LegacyMessagesTest.java **/GeneratedSourceAnalysisTest.java + **/ReportGenerationTest.java @@ -138,4 +141,4 @@ - \ No newline at end of file + diff -Nru jboss-logging-tools-2.0.2/README.adoc jboss-logging-tools-2.1.0/README.adoc --- jboss-logging-tools-2.0.2/README.adoc 1970-01-01 00:00:00.000000000 +0000 +++ jboss-logging-tools-2.1.0/README.adoc 2017-08-09 18:02:31.000000000 +0000 @@ -0,0 +1,16 @@ += JBoss Logging Tools + +The JBoss logging tools are used to create internationalized log statements and exceptions. + +For user documentation see https://jboss-logging.github.io/jboss-logging-tools/. For annotation JavaDoc's see +https://jboss-logging.github.io/jboss-logging-tools/apidocs/. + +== Building + +Standard Maven build: + + mvn clean install + +To generate the site use the `-Pgenerate-site` profile or `-Dgenerate-site` system property when building. + + mvn clean install -Dgenerate-site