Greg actually implemented and checked in this functionality yesterday
in ApplicationContext, so he can comment specifically on this, but I
know that he used setAccessible(), which throws a SecurityException in
an unsigned applet.  AFAIK, the current plan is to move the API to a
static method in WTKXSerializer (bind()) and have application
instances call it explicitly if they know that they're either
deploying to the DesktopApplicationContext or are signing their JAR
files.

-T

On Sat, May 2, 2009 at 11:25 AM, Noel Grandin <[email protected]> wrote:
> There are 2 alternatives to exposing setters.
> (1) use setAccessible() - not very nice, but it's pretty much what
> serialisation does.
> (2) use bytecode enhancement - not very easy in Pivot's context.
> I'm not sure what technique the EJB @Resource annotations use, but
> they don't need to expose setters.
> But then an EJB container has more control over the application class
> lifecycle than Pivot does.
>
> But also, Pivot code could be make a lot neater by simply wrapping
> WTKXSerializer in a helper class like this:
>
>  PivotLoader loader = ..
>  window = loader.window(...)
>  feedListView = loader.listView(...);
>  final CardPane cardPane = loader.cardPane(...);
>  final Label statusLabel = loader.label(...);
>
> Sure, loader will need quite a few helper methods, but it would make
> the majority of UI code neater without any extra magic being required.
>
> Regards, Noel Grandin
>
>
> On Sat, May 2, 2009 at 15:06, Dominique de Vito <[email protected]> wrote:
>>
>> 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