pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Möbius <dmoeb...@scoop-gmbh.de>
Subject Re: Component names inside the containers
Date Wed, 09 Jun 2010 19:15:31 GMT
Greg Brown wrote:
> I actually started prototyping this last night. I ran into what appears to be a bug in
Class#getAnnotation(), but I'm not sure. The Javadoc for this method isn't specific, but the
Javadoc for getDeclaredAnnotations() implies that getAnnotation() and getAnnotations() will
traverse the class hierarchy looking for annotations, but getDeclaredAnnotations() will not.
However, I have not found that to be the case in practice. I can walk up the class hierarchy
myself, but I'm wondering if I'm simply misunderstanding something. Any ideas?

Yes, annotate IDProperty with @Inherited.
You don't need a static findAnnotation() method.

Dirk.


> On Jun 9, 2010, at 4:08 AM, Dirk Möbius wrote:
> 
>> Greg Brown <gkbrown@mac.com> wrote:
>>> After thinking this through a bit, I am starting to think that your idea to use
an annotation here might make sense. I believe you suggested something along the lines of:
>>>
>>> @IDProperty(name="foo")
>> Yes, or simply @Id, or @WtkxId to make clear that the wtkx:id gets injected.
>> @BxId also comes to mind, because you announced that WtkxSerializer will be renamed
to BeanSerializer.
>>
>> Note that if you use "value" as annotation parameter, you can omit it in the usage:
>>
>> @IDProperty("foo")
>>
>> You could also set the value "id" as default:
>>
>> public interface @Id {
>>  String value() = "id";
>> }
>>
>> Thus, you only need to annotate a class with
>>
>> @Id
>> public class Component {
>>  ...
>> }
>>
>> and it is assumed to have a getId()/setId() pair.
>>
>> Btw. my previous post about this is here (dated 05/07):
>> http://mail-archives.apache.org/mod_mbox/pivot-user/201005.mbox/%3C20100507092329.13532v1k8xha1bsw@www.premium-webmail.de%3E
>>
>>> If this attribute is specified, WTKXSerializer would propagate the ID value to
the given property. This would avoid the name duplication and would be a fairly trivial change.
I'm still not convinced that it is absolutely necessary, but it is nice to have and obviously
has some use cases. Also, I believe Spring offers a similar feature via the BeanNameAware
interface, so it would be nice to have a comparable feature.
>> Yes, it's like BeanNameAware, but annotations are less invasive because they don't
prescribe a certain method name.
>>
>> Dirk.


Mime
View raw message