From 6cfb6cd15b395aa50d087d59eeb3007c2ee01aff Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Tue, 13 Apr 2021 12:30:58 +0200 Subject: [PATCH] Qute - remove deprecated annotations from the io.quarkus.qute.api pkg --- docs/src/main/asciidoc/qute.adoc | 8 +- .../io/quarkus/qute/deployment/Names.java | 4 - .../qute/deployment/QuteProcessor.java | 12 +-- .../io/quarkus/qute/api/CheckedTemplate.java | 91 ------------------- .../io/quarkus/qute/api/ResourcePath.java | 53 ----------- .../qute/runtime/TemplateProducer.java | 5 - 6 files changed, 6 insertions(+), 167 deletions(-) delete mode 100644 extensions/qute/runtime/src/main/java/io/quarkus/qute/api/CheckedTemplate.java delete mode 100644 extensions/qute/runtime/src/main/java/io/quarkus/qute/api/ResourcePath.java diff --git a/docs/src/main/asciidoc/qute.adoc b/docs/src/main/asciidoc/qute.adoc index a53ab455466ae1..d788fe09006ff8 100644 --- a/docs/src/main/asciidoc/qute.adoc +++ b/docs/src/main/asciidoc/qute.adoc @@ -66,7 +66,7 @@ public class HelloResource { } } ---- -<1> If there is no `@ResourcePath` qualifier provided, the field name is used to locate the template. In this particular case, we're injecting a template with path `templates/hello.txt`. +<1> If there is no `@Location` qualifier provided, the field name is used to locate the template. In this particular case, we're injecting a template with path `templates/hello.txt`. <2> `Template.data()` returns a new template instance that can be customized before the actual rendering is triggered. In this case, we put the name value under the key `name`. The data map is accessible during rendering. <3> Note that we don't trigger the rendering - this is done automatically by a special `ContainerResponseFilter` implementation. @@ -442,7 +442,7 @@ package org.acme.quarkus.sample; import javax.inject.Inject; import io.quarkus.qute.Template; -import io.quarkus.qute.api.ResourcePath; +import io.quarkus.qute.Location; import io.quarkus.scheduler.Scheduled; public class ReportGenerator { @@ -450,7 +450,7 @@ public class ReportGenerator { @Inject SampleService service; - @ResourcePath("reports/v1/report_01") <1> + @Location("reports/v1/report_01") <1> Template report; @Scheduled(cron="0 30 * * * ?") <2> @@ -463,7 +463,7 @@ public class ReportGenerator { } } ---- -<1> In this case, we use the `@ResourcePath` qualifier to specify the template path: `templates/reports/v1/report_01.html`. +<1> In this case, we use the `@Location` qualifier to specify the template path: `templates/reports/v1/report_01.html`. <2> Use the `@Scheduled` annotation to instruct Quarkus to execute this method on the half hour. For more information see the link:scheduler[Scheduler] guide. <3> The `TemplateInstance.render()` method triggers rendering. Note that this method blocks the current thread. diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Names.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Names.java index a7873e3160181f..32a3f4923155ff 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Names.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/Names.java @@ -12,8 +12,6 @@ import io.quarkus.qute.Location; import io.quarkus.qute.Template; import io.quarkus.qute.TemplateInstance; -import io.quarkus.qute.api.CheckedTemplate; -import io.quarkus.qute.api.ResourcePath; import io.quarkus.qute.i18n.Localized; import io.quarkus.qute.i18n.Message; import io.quarkus.qute.i18n.MessageBundle; @@ -26,7 +24,6 @@ final class Names { static final DotName MESSAGE = DotName.createSimple(Message.class.getName()); static final DotName MESSAGE_PARAM = DotName.createSimple(MessageParam.class.getName()); static final DotName LOCALIZED = DotName.createSimple(Localized.class.getName()); - static final DotName RESOURCE_PATH = DotName.createSimple(ResourcePath.class.getName()); static final DotName TEMPLATE = DotName.createSimple(Template.class.getName()); static final DotName ITERABLE = DotName.createSimple(Iterable.class.getName()); static final DotName ITERATOR = DotName.createSimple(Iterator.class.getName()); @@ -34,7 +31,6 @@ final class Names { static final DotName MAP = DotName.createSimple(Map.class.getName()); static final DotName MAP_ENTRY = DotName.createSimple(Entry.class.getName()); static final DotName COLLECTION = DotName.createSimple(Collection.class.getName()); - static final DotName CHECKED_TEMPLATE_OLD = DotName.createSimple(CheckedTemplate.class.getName()); static final DotName TEMPLATE_INSTANCE = DotName.createSimple(TemplateInstance.class.getName()); static final DotName COMPLETION_STAGE = DotName.createSimple(CompletionStage.class.getName()); static final DotName UNI = DotName.createSimple(Uni.class.getName()); diff --git a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java index efea10956644d5..de4d68846e135b 100644 --- a/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java +++ b/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java @@ -106,7 +106,6 @@ import io.quarkus.qute.UserTagSectionHelper; import io.quarkus.qute.Variant; import io.quarkus.qute.WhenSectionHelper; -import io.quarkus.qute.api.ResourcePath; import io.quarkus.qute.deployment.TemplatesAnalysisBuildItem.TemplateAnalysis; import io.quarkus.qute.deployment.TypeCheckExcludeBuildItem.TypeCheck; import io.quarkus.qute.deployment.TypeInfos.Info; @@ -136,8 +135,6 @@ public class QuteProcessor { - public static final DotName RESOURCE_PATH = Names.RESOURCE_PATH; - private static final Logger LOGGER = Logger.getLogger(QuteProcessor.class); private static final Function GETTER_FUN = new Function() { @@ -205,8 +202,8 @@ void processTemplateErrors(TemplatesAnalysisBuildItem analysis, List collectCheckedTemplates(BeanArchiveIndexBuildItem Map checkedTemplateMethods = new HashMap<>(); Set checkedTemplateAnnotations = new HashSet<>(); - checkedTemplateAnnotations.addAll(index.getIndex().getAnnotations(Names.CHECKED_TEMPLATE_OLD)); checkedTemplateAnnotations.addAll(index.getIndex().getAnnotations(Names.CHECKED_TEMPLATE)); // Build a set of file paths for validation @@ -1054,10 +1050,6 @@ void validateTemplateInjectionPoints(QuteConfig config, Listnative static methods will be used to declare - * templates and the list of parameters they require. - *

- * The name of a method and the base path are used to locate the template contents. - * By default, the base path is derived from the annotation target: - *

    - *
  • If this is placed on a static nested class of an enclosing class with a simple name X, a - * native static method of the name foo will refer to a template at the path X/foo - * (template file extensions are - * not part of the method name) relative to the templates root.
  • - *
  • If this is placed on a top-level class, a native static method of the name foo will refer to a - * template at the path foo (template file extensions are - * not part of the method name) at the toplevel of the templates root.
  • - *
- * The base path can be also specified via {@link #basePath()}. - *

- * Each parameter of the native static will be used to validate the template at build time, to - * make sure that those parameters are used properly in a type-safe manner. The return type of each - * native static method should be {@link TemplateInstance}. - *

- * Example: - *

- * - *

- * @Path("item")
- * public class ItemResource {
- * 
- *     @CheckedTemplate
- *     static class Templates {
- *         // defines a template at ItemResource/item, taking an Item parameter named item
- *         static native TemplateInstance item(Item item);
- *     }
- * 
- *     @GET
- *     @Path("{id}")
- *     @Produces(MediaType.TEXT_HTML)
- *     public TemplateInstance get(@PathParam("id") Integer id) {
- *         // instantiate that template and pass it the required template parameter
- *         return Templates.item(service.findItem(id));
- *     }
- * }
- * 
- * - * @deprecated Use {@link io.quarkus.qute.CheckedTemplate} instead. This annotation will be removed at some point post Quarkus - * 1.13. - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@Deprecated -public @interface CheckedTemplate { - - /** - * Constant value for {@link #basePath()} indicating that the default strategy should be used. - */ - String DEFAULTED = "<>"; - - /** - * Example: - * - *
-     * @Path("item")
-     * public class ItemResource {
-     * 
-     *     @CheckedTemplate(basePath = "items_v1")
-     *     static class Templates {
-     *         // defines a template at items_v1/item
-     *         static native TemplateInstance item(Item item);
-     * 
-     *         // defines a template at items_v1/allItems
-     *         static native TemplateInstance allItems(List<Item> items);
-     *     }
-     * }
-     * 
- * - * @return the base path relative to the templates root - */ - String basePath() default DEFAULTED; - -} diff --git a/extensions/qute/runtime/src/main/java/io/quarkus/qute/api/ResourcePath.java b/extensions/qute/runtime/src/main/java/io/quarkus/qute/api/ResourcePath.java deleted file mode 100644 index 939597999a1c09..00000000000000 --- a/extensions/qute/runtime/src/main/java/io/quarkus/qute/api/ResourcePath.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.quarkus.qute.api; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.enterprise.util.AnnotationLiteral; -import javax.enterprise.util.Nonbinding; -import javax.inject.Qualifier; - -/** - * Qualifies an injected template. The {@link #value()} is used to locate the template; it represents the path relative from - * the base path. - * - * @deprecated Use {@link io.quarkus.qute.Location} instead. This annotation will be removed at some point post Quarkus 1.13. - */ -@Qualifier -@Retention(RUNTIME) -@Target({ FIELD, PARAMETER, METHOD }) -@Deprecated -public @interface ResourcePath { - - /** - * @return the path relative from the base path, must not be an empty string - */ - @Nonbinding - String value(); - - /** - * Supports inline instantiation of this qualifier. - */ - public static final class Literal extends AnnotationLiteral implements ResourcePath { - - private static final long serialVersionUID = 1L; - - private final String value; - - public Literal(String value) { - this.value = value; - } - - @Override - public String value() { - return value; - } - - } - -} \ No newline at end of file diff --git a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java index 9f5753446e075a..13ff6303af8ca1 100644 --- a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java +++ b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java @@ -27,7 +27,6 @@ import io.quarkus.qute.TemplateInstance; import io.quarkus.qute.TemplateInstanceBase; import io.quarkus.qute.Variant; -import io.quarkus.qute.api.ResourcePath; import io.quarkus.qute.runtime.QuteRecorder.QuteContext; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; @@ -73,16 +72,12 @@ Template getDefaultTemplate(InjectionPoint injectionPoint) { @Produces @Location("ignored") - @ResourcePath("ignored") Template getTemplate(InjectionPoint injectionPoint) { String path = null; for (Annotation qualifier : injectionPoint.getQualifiers()) { if (qualifier.annotationType().equals(Location.class)) { path = ((Location) qualifier).value(); break; - } else if (qualifier.annotationType().equals(ResourcePath.class)) { - path = ((ResourcePath) qualifier).value(); - break; } } if (path == null || path.isEmpty()) {