Skip to content

Commit b679186

Browse files
committed
Rename quarkus-qute-resteasy to quarkus-resteasy-qute
- plus other fixes
1 parent 52c6757 commit b679186

File tree

37 files changed

+147
-227
lines changed

37 files changed

+147
-227
lines changed

bom/deployment/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@
521521
</dependency>
522522
<dependency>
523523
<groupId>io.quarkus</groupId>
524-
<artifactId>quarkus-qute-resteasy-deployment</artifactId>
524+
<artifactId>quarkus-resteasy-qute-deployment</artifactId>
525525
<version>${project.version}</version>
526526
</dependency>
527527

bom/runtime/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@
744744
</dependency>
745745
<dependency>
746746
<groupId>io.quarkus</groupId>
747-
<artifactId>quarkus-qute-resteasy</artifactId>
747+
<artifactId>quarkus-resteasy-qute</artifactId>
748748
<version>${project.version}</version>
749749
</dependency>
750750

core/deployment/src/main/java/io/quarkus/runner/RuntimeClassLoader.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.io.Writer;
1313
import java.net.MalformedURLException;
1414
import java.net.URI;
15-
import java.net.URISyntaxException;
1615
import java.net.URL;
1716
import java.net.URLConnection;
1817
import java.net.URLStreamHandler;
@@ -527,20 +526,22 @@ private ProtectionDomain createDefaultProtectionDomain(Path applicationClasspath
527526
URL url = null;
528527
if (applicationClasspath != null) {
529528
try {
530-
String path = applicationClasspath.toString();
531-
if (File.separatorChar != '/') {
532-
// Note that windows separator is always quoted in the URI constructor
533-
path = path.replace('/', File.separatorChar);
534-
}
535-
URI uri = new URI("file", null, path, null);
529+
// String path = applicationClasspath.toString();
530+
//if (File.separatorChar != '/') {
531+
// // Note that windows separator is always quoted in the URI constructor
532+
// path = path.replace(File.separatorChar, '/');
533+
//}
534+
//URI uri = new URI("file", null, path, null);
535+
URI uri = applicationClasspath.toUri();
536536
url = uri.toURL();
537-
} catch (URISyntaxException | MalformedURLException e) {
537+
//} catch (URISyntaxException | MalformedURLException e) {
538+
} catch (MalformedURLException e) {
538539
log.error("URL codeSource location for path " + applicationClasspath + " could not be created.", e);
539540
}
540541
}
541542
CodeSource codesource = new CodeSource(url, (Certificate[]) null);
542543
ProtectionDomain protectionDomain = new ProtectionDomain(codesource, null, this, null);
543544
return protectionDomain;
544545
}
545-
546+
546547
}

docs/src/main/asciidoc/qute.adoc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In your `pom.xml` file, add:
3030
----
3131
<dependency>
3232
<groupId>io.quarkus</groupId>
33-
<artifactId>quarkus-qute-resteasy</artifactId>
33+
<artifactId>quarkus-resteasy-qute</artifactId>
3434
</dependency>
3535
----
3636

@@ -72,12 +72,13 @@ public class HelloResource {
7272
}
7373
}
7474
----
75-
<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`.
75+
<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`.
7676
<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.
7777
<3> Note that we don't trigger the rendering - this is done automatically by a special `ContainerResponseFilter` implementation.
7878

79-
If running your application, you can request the endpoint:
79+
If your application is running, you can request the endpoint:
8080

81+
[source, shell]
8182
```
8283
$ curl -w "\n" http://localhost:8080/hello?name=Martin
8384
Hello Martin!
@@ -176,7 +177,7 @@ public class ItemResource {
176177
== Rendering Periodic Reports
177178

178179
Templating engine could be also very useful when rendering periodic reports.
179-
You'll need to add `quarkus-scheduler` and `quarkus-qute` extensions first.
180+
You'll need to add the `quarkus-scheduler` and `quarkus-qute` extensions first.
180181
In your `pom.xml` file, add:
181182

182183
[source,xml]
@@ -230,7 +231,7 @@ The template is simple:
230231
</html>
231232
----
232233
<1> The loop section makes it possible to iterate over iterables, maps and streams.
233-
<2> This value expression is using https://en.wikipedia.org/wiki/Elvis_operator[elvis operator] - if the name is null the default value is used.
234+
<2> This value expression is using the https://en.wikipedia.org/wiki/Elvis_operator[elvis operator] - if the name is null the default value is used.
234235

235236
[source,java]
236237
.ReportGenerator.java

extensions/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<module>resteasy-jsonb</module>
4646
<module>resteasy-jackson</module>
4747
<module>resteasy-jaxb</module>
48+
<module>resteasy-qute</module>
4849
<module>rest-client</module>
4950
<module>smallrye-openapi-common</module>
5051
<module>smallrye-openapi</module>
@@ -135,7 +136,6 @@
135136

136137
<!-- Templating -->
137138
<module>qute</module>
138-
<module>qute-resteasy</module>
139139
</modules>
140140

141141
<!-- Unfortunately the config below introduces a build dependency on the maven plugin

extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/GeneratedValueResolverBuildItem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import io.quarkus.builder.item.MultiBuildItem;
44

5+
/**
6+
* Holds a name of a generated {@link io.quarkus.qute.ValueResolver} class.
7+
*/
58
public final class GeneratedValueResolverBuildItem extends MultiBuildItem {
69

710
private final String className;

extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
import org.jboss.jandex.MethodInfo;
3737
import org.jboss.jandex.ParameterizedType;
3838
import org.jboss.jandex.Type;
39-
import org.slf4j.Logger;
40-
import org.slf4j.LoggerFactory;
39+
import org.jboss.logging.Logger;
4140

4241
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
4342
import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem;
@@ -87,7 +86,7 @@
8786

8887
public class QuteProcessor {
8988

90-
private static final Logger LOGGER = LoggerFactory.getLogger(QuteProcessor.class);
89+
private static final Logger LOGGER = Logger.getLogger(QuteProcessor.class);
9190

9291
public static final DotName RESOURCE_PATH = DotName.createSimple(ResourcePath.class.getName());
9392
public static final DotName TEMPLATE = DotName.createSimple(Template.class.getName());
@@ -147,7 +146,9 @@ TemplatesAnalysisBuildItem analyzeTemplates(List<TemplatePathBuildItem> template
147146
long start = System.currentTimeMillis();
148147
List<TemplateAnalysis> analysis = new ArrayList<>();
149148

149+
// A dummy engine instance is used to parse and validate all templates during the build. The real engine instance is created at startup.
150150
Engine dummyEngine = Engine.builder().addDefaultSectionHelpers().computeSectionHelper(name -> {
151+
// Create a dummy section helper factory for an uknown section that could be potentially registered at runtime
151152
return new SectionHelperFactory<SectionHelper>() {
152153
@Override
153154
public SectionHelper initialize(SectionInitContext context) {
@@ -169,7 +170,7 @@ public CompletionStage<ResultNode> resolve(SectionResolutionContext context) {
169170
LOGGER.warn("Unable to analyze the template from path: " + path.getFullPath(), e);
170171
}
171172
}
172-
LOGGER.debug("Finished analysis of {} templates in {} ms",
173+
LOGGER.debugf("Finished analysis of %s templates in %s ms",
173174
analysis.size(), System.currentTimeMillis() - start);
174175
return new TemplatesAnalysisBuildItem(analysis);
175176
}
@@ -216,7 +217,7 @@ void validateExpressions(TemplatesAnalysisBuildItem templatesAnalysis, BeanArchi
216217
member = findTemplateExtensionMethod(name, match.clazz, templateExtensionMethods);
217218
}
218219
if (member == null && excludes.stream().anyMatch(e -> e.getPredicate().test(name, match.clazz))) {
219-
LOGGER.debug("No property found for {} in [{}] but it is intentionally ignored", name,
220+
LOGGER.debugf("No property found for %s in [%s] but it is intentionally ignored", name,
220221
expression.toOriginalString(), match.clazz);
221222
break;
222223
}
@@ -324,7 +325,7 @@ void validateInjectedBeans(ApplicationArchivesBuildItem applicationArchivesBuild
324325
}
325326
if (member == null
326327
&& excludes.stream().anyMatch(e -> e.getPredicate().test(name, match.clazz))) {
327-
LOGGER.debug("No property found for {} in [{}] but it is intentionally ignored", name,
328+
LOGGER.debugf("No property found for %s in [%s] but it is intentionally ignored", name,
328329
expression.toOriginalString(), match.clazz);
329330
break;
330331
}
@@ -409,7 +410,7 @@ public void write(String name, byte[] data) {
409410
}
410411
String className = name.substring(0, idx).replace("/", ".");
411412
boolean appClass = appClassPredicate.test(className);
412-
LOGGER.debug("Writing {} [appClass={}]", name, appClass);
413+
LOGGER.debugf("Writing %s [appClass=%s]", name, appClass);
413414
generatedClass.produce(new GeneratedClassBuildItem(appClass, name, data));
414415
}
415416
};
@@ -443,18 +444,18 @@ public void write(String name, byte[] data) {
443444
generator.generate(data);
444445
}
445446

446-
Set<String> generateTypes = new HashSet<>();
447-
generateTypes.addAll(generator.getGeneratedTypes());
447+
Set<String> generatedTypes = new HashSet<>();
448+
generatedTypes.addAll(generator.getGeneratedTypes());
448449

449450
ExtensionMethodGenerator extensionMethodGenerator = new ExtensionMethodGenerator(classOutput);
450451
for (TemplateExtensionMethodBuildItem templateExtension : templateExtensionMethods) {
451452
extensionMethodGenerator.generate(templateExtension.getMethod());
452453
}
453-
generateTypes.addAll(extensionMethodGenerator.getGeneratedTypes());
454+
generatedTypes.addAll(extensionMethodGenerator.getGeneratedTypes());
454455

455-
LOGGER.debug("Generated types: {}", generateTypes);
456+
LOGGER.debugf("Generated types: %s", generatedTypes);
456457

457-
for (String generateType : generateTypes) {
458+
for (String generateType : generatedTypes) {
458459
generatedResolvers.produce(new GeneratedValueResolverBuildItem(generateType));
459460
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, generateType));
460461
}
@@ -477,15 +478,18 @@ void collectTemplates(QuteConfig config, ApplicationArchivesBuildItem applicatio
477478
String tagBasePath = basePath + "tags/";
478479
Path tagsPath = applicationArchive.getChildPath(tagBasePath);
479480
if (tagsPath != null) {
480-
Iterator<Path> tagFiles = Files.list(tagsPath)
481-
.filter(Files::isRegularFile)
482-
.iterator();
483-
while (tagFiles.hasNext()) {
484-
Path path = tagFiles.next();
485-
String tagPath = path.getFileName().toString();
486-
LOGGER.debug("Found tag: {}", path);
487-
produceTemplateBuildItems(templatePaths, watchedPaths, nativeImageResources, tagBasePath, tagPath, path, true);
481+
try (Stream<Path> tagFiles = Files.list(tagsPath)) {
482+
Iterator<Path> iter = tagFiles.filter(Files::isRegularFile)
483+
.iterator();
484+
while (iter.hasNext()) {
485+
Path path = iter.next();
486+
String tagPath = path.getFileName().toString();
487+
LOGGER.debugf("Found tag: %s", path);
488+
produceTemplateBuildItems(templatePaths, watchedPaths, nativeImageResources, tagBasePath, tagPath, path,
489+
true);
490+
}
488491
}
492+
489493
}
490494
}
491495

@@ -563,7 +567,7 @@ void processInjectionPoints(QuteConfig config, ApplicationArchivesBuildItem appl
563567
Map<String, List<String>> variants = new HashMap<>();
564568
scanVariants(basePath, templatesPath, templatesPath, variantBases, variants);
565569
templateVariants.produce(new TemplateVariantsBuildItem(variants));
566-
LOGGER.debug("Variant templates found: {}", variants);
570+
LOGGER.debugf("Variant templates found: %s", variants);
567571
}
568572
}
569573

@@ -749,7 +753,7 @@ private void processsTemplateData(IndexView index, AnnotationInstance templateDa
749753
new AnnotationValue[] { ignoreValue, propertiesValue });
750754
});
751755
} else {
752-
LOGGER.warn("@TemplateData#target() not available: {}", annotationTarget.asClass().name());
756+
LOGGER.warnf("@TemplateData#target() not available: %s", annotationTarget.asClass().name());
753757
}
754758
}
755759
}
@@ -804,37 +808,40 @@ private void scan(Path root, Path directory, String basePath, BuildProducer<HotD
804808
BuildProducer<TemplatePathBuildItem> templatePaths,
805809
BuildProducer<NativeImageResourceBuildItem> nativeImageResources)
806810
throws IOException {
807-
Iterator<Path> files = Files.list(directory).iterator();
808-
while (files.hasNext()) {
809-
Path path = files.next();
810-
if (Files.isRegularFile(path)) {
811-
LOGGER.debug("Found template: {}", path);
812-
String templatePath = root.relativize(path).toString();
813-
produceTemplateBuildItems(templatePaths, watchedPaths, nativeImageResources, basePath, templatePath, path,
814-
false);
815-
} else if (Files.isDirectory(path) && !path.getFileName().toString().equals("tags")) {
816-
LOGGER.debug("Scan directory: {}", path);
817-
scan(root, path, basePath, watchedPaths, templatePaths, nativeImageResources);
811+
try (Stream<Path> files = Files.list(directory)) {
812+
Iterator<Path> iter = files.iterator();
813+
while (iter.hasNext()) {
814+
Path path = iter.next();
815+
if (Files.isRegularFile(path)) {
816+
LOGGER.debugf("Found template: %s", path);
817+
String templatePath = root.relativize(path).toString();
818+
produceTemplateBuildItems(templatePaths, watchedPaths, nativeImageResources, basePath, templatePath, path,
819+
false);
820+
} else if (Files.isDirectory(path) && !path.getFileName().toString().equals("tags")) {
821+
LOGGER.debugf("Scan directory: %s", path);
822+
scan(root, path, basePath, watchedPaths, templatePaths, nativeImageResources);
823+
}
818824
}
819825
}
820826
}
821827

822828
void scanVariants(String basePath, Path root, Path directory, Set<String> variantBases, Map<String, List<String>> variants)
823829
throws IOException {
824-
Iterator<Path> files = Files.list(directory)
825-
.iterator();
826-
while (files.hasNext()) {
827-
Path path = files.next();
828-
if (Files.isRegularFile(path)) {
829-
for (String base : variantBases) {
830-
if (path.toAbsolutePath().toString().contains(base)) {
831-
// Variants are relative paths to base, e.g. "detail/item2"
832-
variants.computeIfAbsent(base, i -> new ArrayList<>())
833-
.add(root.relativize(path).toString());
830+
try (Stream<Path> files = Files.list(directory)) {
831+
Iterator<Path> iter = files.iterator();
832+
while (iter.hasNext()) {
833+
Path path = iter.next();
834+
if (Files.isRegularFile(path)) {
835+
for (String base : variantBases) {
836+
if (path.toAbsolutePath().toString().contains(base)) {
837+
// Variants are relative paths to base, e.g. "detail/item2"
838+
variants.computeIfAbsent(base, i -> new ArrayList<>())
839+
.add(root.relativize(path).toString());
840+
}
834841
}
842+
} else if (Files.isDirectory(path)) {
843+
scanVariants(basePath, root, path, variantBases, variants);
835844
}
836-
} else if (Files.isDirectory(path)) {
837-
scanVariants(basePath, root, path, variantBases, variants);
838845
}
839846
}
840847
}

extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplateExtensionMethodBuildItem.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
import io.quarkus.builder.item.MultiBuildItem;
77
import io.quarkus.qute.TemplateExtension;
88

9+
/**
10+
* Represents a template extension method.
11+
*
12+
* @see TemplateExtension
13+
*/
914
public final class TemplateExtensionMethodBuildItem extends MultiBuildItem {
1015

1116
private final MethodInfo method;

extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplatePathBuildItem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import io.quarkus.builder.item.MultiBuildItem;
66

7+
/**
8+
* Represents a template path.
9+
*/
710
public final class TemplatePathBuildItem extends MultiBuildItem {
811

912
private final String path;

extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/TemplateVariantsBuildItem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
import io.quarkus.builder.item.SimpleBuildItem;
77

8+
/**
9+
* Holds all template variants found.
10+
*/
811
public final class TemplateVariantsBuildItem extends SimpleBuildItem {
912

1013
private final Map<String, List<String>> variants;

0 commit comments

Comments
 (0)