Hi,

I re-post here some ideas about annotations with Pivot; I have already written 
about those ideas in http://java.dzone.com/news/building-simple-rss-client - a 
RSS example.

Greg Brown mentionned in his RSS example the startup() method including the 
following instructions:

WTKXSerializer wtkxSerializer = ..
window = ...
feedListView = (ListView)  wtkxSerializer.getObjectByName(...);
final CardPane cardPane = (CardPane) wtkxSerializer.getObjectByName(...);
final Label statusLabel = (Label) wtkxSerializer.getObjectByName(...);

Here, 'window' and 'feedListView' are class fields. And 'cardPane' and 
'statusLabel' are method-scoped variables. These fields and variables are 
assignated explicitly while fetching the corresponding XML element's value.

While reading these instructions, I have first thought about an implicit 
binding, that is, about something like (with appropriate setter definitions) :

private WTKXSerializer wtkxSerializer;

@WtkxResource("rss_feed_demo.wtkx")
private Window window = null;
   
@Bind("feedListView")
private ListView feedListView;

@Bind("cardPane")
private CardPane cardPane;
   
@Bind("statusLabel")
private Label statusLabel;

Here, all these Java elements are Java fields.

I thought, if the 'Application' class lifecycle/method chain call enables it, 
annotations could be used to bind XML elements/Java fields, before the call of 
the startup() method. Then, according to annotations, all the assignments above 
could be done automatically, following annotation directives.

It's a first sketch. I am not fully happy with it.

I just feel annoyed needing to expose setter methods for all possible fields to 
be assigned, while I just need them only here for initialization! So, I don't 
feel fully happy with the way constructors/DI works today. 

So, nowadays, I am looking deeper into DI internal details in order to see how 
to mix annotation+DI without exposing too much about the object internals (I 
just feel property-DI break unfortunately OO encapsulation).

Another interesting topic is: does Pivot need a specific binding annotation 
set, or is it possible re-use the annotation set of some library (like JiBX or 
Castor)?

Any comment/idea about Pivot with annotations ?

Thanks.

Regards,
Dominique
http://www.jroller.com/dmdevito

PS : for those interested, I have mentionned Pivot into 2 of my posts.

Swing browsers - other interesting DSL Swing projects to follow
http://www.jroller.com/dmdevito/entry/swing_browsers_other_interesting_dsl

HotJava may come back, due to existing, or coming, components, like JWebPane
http://www.jroller.com/dmdevito/entry/hotjava_may_come_back_due





Reply via email to