Hi folks,

I want to get your thoughts around using Castor in a web environment. For
those of you not yet familiar with AJAX it is the age old technique of
remotely scripting calls back to the server from a web page with out the
need to refresh the page. Read more here http://www.xoscript.org/

Today I am using XOscript an open source AJAX implementation to talk to my
Castor classes on the server. I am using a main class that does the work for
my application and applies the data to my Castor class instance and then
takes care of any database interaction and returns something appropriate
back to the web application where the process continues.

In the next stage of development I have been thinking about how I can have
more robust interaction with my Castor classes and I would like to get your
thoughts on what makes the most sense to you.
Today I can generate classes from my xsd using the
org.exolab.castor.builder.SourceGenerator.  I can interact with my castor
class by returning it from a method call back to my web application. At this
point in the browser I have a proxy instance of my Castor class which
contains no data and all of it's methods are mapped to remote calls behind
the scenes.
If I call a method on one of my Castor classes I get another proxy object
and the process goes on. Here is where I am at a cross road, if the proxy
object I get back from my method call to the server is another concrete
class life is good. If the return type of my method call is java.util.Vector
which Castor uses for collections I can use
org.xoscript.javascript.util.JSCollection and return all of the contents of
the vector to my web application. Maps and Collectons are support by special
JavaScript objects that do the same work as the java.util classes. If I then
iterate over the buckets in that collection and call a method on the object
in that bucket it will be a proxy class who's methods are mapped back to the
server as remote calls. My point here is that I am growing my dependency on
bandwidth consumption and some consideration to how much I might use based
on the hierarchy of my Castor tags.

What I can do is use org.xoscript.builder.JScriptGenerator to generate the
JavaScript equivalent of my Castor classes. At page load I can import this
hierarchy of JavaScript objects into the browser where they are ready to
marshall into instances xml sent from the server representing my Castor
classes complete with the data. The generator uses the JavaScript version of
a vector to manage collection just like in my Castor classes so now when I
iterate over a collection I am touching the data. One concern in this
approach is that if other clients interacts with my Castor classes, I now
have a dirty read and unmarshalling the data back into xml and sending it
back to the server for processing could mean that my instance data is out of
sync with my disconnected web application.

If you want to see an example of a class that was generated with the
org.xoscript.builder.JScriptGenerator you can download the source code from
http://www.xoscript.org/opencms/opencms/download/ and look at the js files
that are in org.xoscript.jsobject.*, with the exception of the class-object
and exception-object the other js classes were generated using the
generator.

Any comments are appreciated. Discussion on this topic may not be
appropriate for this forum so I will invite you to make your comments in the
xoscript discussion forum at google groups.
http://groups-beta.google.com/group/xoscript

Thanks for letting me ramble

Bryan LaPlante



-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to