Skip to content

Commit

Permalink
Qute - remove deprecated annotations from the io.quarkus.qute.api pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Apr 13, 2021
1 parent 1bb72b4 commit 6cfb6cd
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 167 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/qute.adoc
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
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
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,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<FieldInfo, String> GETTER_FUN = new Function<FieldInfo, String>() {
Expand Down Expand Up @@ -205,8 +202,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 +242,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 +1050,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.

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

0 comments on commit 6cfb6cd

Please sign in to comment.