Hi!
I've searched google far and wide, but I don't seem to be able to find a
solution to this problem:
The instance of java.lang.Class returned by ComponentSource.getPage()
seems to be broken - it does not have any of the Annotations the
original Page class does have...
To reproduce this I created a TestAnnotation:
---------
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface TestAnnotation {
}
---------
... and added it to my page class. I then created a
ComponentRequestFilter that uses a ComponentSource to acquire an
instance of said class and tries to determine whether it is annotated
with TestAnnotation:
---------
private void annotationTest(String pageName) {
Component page = componentSource.getPage(pageName);
Class<?> pageClass = page.getClass();
if (isAnnotationPresent(pageClass)) {
System.out.println("heureka!");
} else {
System.out.println("wtf tapestry? You're doing it wrong!");
}
if (isAnnotationPresent(Index.class)) {
System.out.println("this is how it should be!");
} else {
System.out.println("Java is broken - we're all gonna die!");
}
System.out.println(String.format("oh, and by the way: %b",
(page instanceof Index)));
System.out.println(String.format("and neither is: %b",
Index.class.equals(pageClass)));
}
private boolean isAnnotationPresent(Class<?> pageClass) {
System.out.println(String.format("class: %s", pageClass));
boolean annotationPresent =
pageClass.isAnnotationPresent(TestAnnotation.class);
System.out.println(String.format("annotation present: %b",
annotationPresent));
return annotationPresent;
}
---------
The output is:
---------
class: class test.pages.Index
annotation present: false
wtf tapestry? You're doing it wrong!
class: class test.pages.Index
annotation present: true
this is how it should be!
oh, and by the way: false
and neither is: false
---------
The page that is returned by ComponentSource.getPage() seems to not have
the annotation.
Is this desired behavior? I found many tutorials out there (some in the
tapestry wiki) that seem to use the exact same method to get the
annotations of a page class.
I've put together a small project containing my test code, you can find
it here:
http://satansoft.de/tapestry/annotationtest.zip (~20k)
Just run
# > mvn package jetty:run
and access
http://localhost:8080/annotationtest/
to reproduce this behavior.
Does anybody else experience this? Is it my fault?
Thanks in advance for your time
Tapestry Version: 5.2.0
Reproduced on Jetty and Glassfish
--
Michael Bayer
Software Developer
Gameforge Productions GmbH
Albert-Nestler-Straße 8
D-76131 Karlsruhe
Tel. +49 721 354 808-0
Fax +49 721 354 808-152
michael.ba...@gameforge.de
http://www.gameforge.de
Amtsgericht Mannheim, HRB 701682
USt-ID: DE 254 298 652
Geschäftsführer: Alexander Rösner, Christoph Jennen
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org