Skip to content

Commit

Permalink
Merge pull request #16468 from mkouba/qute-remove-deprecated-api-ann
Browse files Browse the repository at this point in the history
Qute - remove deprecated annotations from the io.quarkus.qute.api pkg
  • Loading branch information
mkouba authored Apr 13, 2021
2 parents af74476 + 65491bc commit 8b67037
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 188 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/qute.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -442,15 +442,15 @@ 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 {
@Inject
SampleService service;
@ResourcePath("reports/v1/report_01") <1>
@Location("reports/v1/report_01") <1>
Template report;
@Scheduled(cron="0 30 * * * ?") <2>
Expand All @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void validateMailTemplates(

for (InjectionPointInfo injectionPoint : validationPhase.getContext().get(BuildExtension.Key.INJECTION_POINTS)) {
if (injectionPoint.getRequiredType().name().equals(MAIL_TEMPLATE)) {
AnnotationInstance resourcePath = injectionPoint.getRequiredQualifier(QuteProcessor.RESOURCE_PATH);
AnnotationInstance resourcePath = injectionPoint.getRequiredQualifier(QuteProcessor.LOCATION);
String name;
if (resourcePath != null) {
name = resourcePath.value().asString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.mailer.MailTemplate.MailTemplateInstance;
import io.quarkus.qute.api.CheckedTemplate;
import io.quarkus.qute.api.ResourcePath;
import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.Location;
import io.quarkus.test.QuarkusUnitTest;
import io.smallrye.mutiny.Uni;
import io.vertx.ext.mail.MailClient;
Expand Down Expand Up @@ -123,7 +123,7 @@ static class Templates {
@Inject
MailTemplate test1;

@ResourcePath("mails/test2")
@Location("mails/test2")
MailTemplate testMail;

Uni<Void> send1() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@

import io.quarkus.arc.Arc;
import io.quarkus.mailer.MailTemplate;
import io.quarkus.qute.Location;
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.ResourcePath;
import io.quarkus.qute.runtime.LocationLiteral;

@Singleton
public class MailTemplateProducer {
Expand Down Expand Up @@ -50,19 +51,19 @@ MailTemplate getDefault(InjectionPoint injectionPoint) {
return new MailTemplate() {
@Override
public MailTemplateInstance instance() {
return new MailTemplateInstanceImpl(mailer, template.select(new ResourcePath.Literal(name)).get().instance());
return new MailTemplateInstanceImpl(mailer, template.select(new LocationLiteral(name)).get().instance());
}

};
}

@ResourcePath("ignored")
@Location("ignored")
@Produces
MailTemplate get(InjectionPoint injectionPoint) {
ResourcePath path = null;
Location path = null;
for (Annotation qualifier : injectionPoint.getQualifiers()) {
if (qualifier.annotationType().equals(ResourcePath.class)) {
path = (ResourcePath) qualifier;
if (qualifier.annotationType().equals(Location.class)) {
path = (Location) qualifier;
break;
}
}
Expand All @@ -73,7 +74,7 @@ MailTemplate get(InjectionPoint injectionPoint) {
return new MailTemplate() {
@Override
public MailTemplateInstance instance() {
return new MailTemplateInstanceImpl(mailer, template.select(new ResourcePath.Literal(name)).get().instance());
return new MailTemplateInstanceImpl(mailer, template.select(new LocationLiteral(name)).get().instance());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,15 +24,13 @@ 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());
static final DotName STREAM = DotName.createSimple(Stream.class.getName());
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -136,7 +135,7 @@

public class QuteProcessor {

public static final DotName RESOURCE_PATH = Names.RESOURCE_PATH;
public static final DotName LOCATION = Names.LOCATION;

private static final Logger LOGGER = Logger.getLogger(QuteProcessor.class);

Expand Down Expand Up @@ -205,8 +204,8 @@ void processTemplateErrors(TemplatesAnalysisBuildItem analysis, List<IncorrectEx
AdditionalBeanBuildItem additionalBeans() {
return AdditionalBeanBuildItem.builder()
.setUnremovable()
.addBeanClasses(EngineProducer.class, TemplateProducer.class, ContentTypes.class, ResourcePath.class,
Template.class, TemplateInstance.class, CollectionTemplateExtensions.class,
.addBeanClasses(EngineProducer.class, TemplateProducer.class, ContentTypes.class, Template.class,
TemplateInstance.class, CollectionTemplateExtensions.class,
MapTemplateExtensions.class, NumberTemplateExtensions.class, ConfigTemplateExtensions.class,
TimeTemplateExtensions.class)
.build();
Expand Down Expand Up @@ -245,7 +244,6 @@ List<CheckedTemplateBuildItem> collectCheckedTemplates(BeanArchiveIndexBuildItem
Map<String, MethodInfo> checkedTemplateMethods = new HashMap<>();

Set<AnnotationInstance> 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
Expand Down Expand Up @@ -1054,10 +1052,6 @@ void validateTemplateInjectionPoints(QuteConfig config, List<TemplatePathBuildIt
for (InjectionPointInfo injectionPoint : validationPhase.getContext().getInjectionPoints()) {
if (injectionPoint.getRequiredType().name().equals(Names.TEMPLATE)) {
AnnotationInstance location = injectionPoint.getRequiredQualifier(Names.LOCATION);
if (location == null) {
// Try the deprecated @ResourcePath
location = injectionPoint.getRequiredQualifier(Names.RESOURCE_PATH);
}
String name;
if (location != null) {
name = location.value().asString();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import org.jboss.resteasy.annotations.jaxrs.QueryParam;

import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.CheckedTemplate;
import io.quarkus.resteasy.qute.RestTemplate;

@Path("hello")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.CheckedTemplate;

@Path("item")
public class ItemResource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import javax.ws.rs.Path;

import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.CheckedTemplate;

@Path("missing-template")
public class MissingTemplateResource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.quarkus.qute.resteasy.deployment;

import io.quarkus.qute.CheckedTemplate;
import io.quarkus.qute.TemplateInstance;
import io.quarkus.qute.api.CheckedTemplate;

@CheckedTemplate
public class Templates {
Expand Down
Loading

0 comments on commit 8b67037

Please sign in to comment.