pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique de Vito <ddv36...@yahoo.fr>
Subject Re: using annotations for binding between XML/Java elements
Date Sun, 03 May 2009 07:46:58 GMT

--- En date de : Sam 2.5.09, Noel Grandin a écrit :
 
> There are 2 alternatives to exposing
> setters.

There is maybe a third way: 
(3) leveraging 'JSR 199: Java Compiler API' (from Java 6) in order to do the on-the-fly code
generation (at the source level, instead of byte-code level).

The question is: which Java version Pivot is targeted ?

If I were you, I would target Java 6 for various reasons.
Pivot is currently for early adopters that would be keen also to adopt Java 6 on the client-side.
Targeting Java 6 may bring early adopters. Targeting Java 5 could bring more audience, but
only *few* percent of the Java 5 developers who are not early adopters: then, IMHO, targeting
Java 5 is not worth the effort.

At first glance, I have not found, on the Apache web site, any clue about which Java version
you are targeting. IMHO it would be worthwhile to write this information into some summary
page.

Dominique




> (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 <ddv36a78@yahoo.fr>
> 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
> >
> >
> >
> >
> >
> >
> 


      

Mime
View raw message