Wednesday, August 31, 2011

Shared Client/Server classes, compiled from different sources

Hiya,

I've created a JavaScript array wrapping class for my client code,
which works great (accessed like an arraylist, but compiles directly
to a JS array with minimal overhead), which has proven to give a big
gain in performance over the default emulated ArrayList.

I've started on shared code (used on both the client and server), and
have realised that the server will not be able to use this class. I've
been mucking around with the super-source module xml tag, in an
attempt to have a "default" (Java environment) MyArray class, and then
"re-root" that definition to a JavaScript-friendly MyArray class at
compile time - however can't seem to work out how to do this.

My code's structure is as follows:

src
-> my_framework
-> my_framework.gwt.xml (no entry point, inherits core GWT stuff,
source path of 'client')
-> my_framework.client
-> my_app
-> my_app.gwt.xml (has an entry point, inherits my_framework,
source path of '_client' and '_shared')
-> my_app._client
-> my_app._shared

MyArray.java is in my_framework.client, and contains the
JavaScriptObject implementation (there's no constructor, new instances
are achieved via a static method, which compiles to inlined 'var arr =
[]' code, fantastically).

My goal is to have the 'MyArray' server/client override occur in the
my_framework module. I've tried several things, but can't seem to get
any of them to work. Is there anybody who knows how the project can be
set up so that:
- The client code is compiled using MyArray.java, which is a
JavaScriptObject.
- The server code compiles using MyArray.java, which is a Java
object, which contains all the same public methods as the first
MyArray.

Thanks, I've been trying for hours and just can't seem to get it to
work (either get 'wrong package' errors, or the JavaScriptObject never
takes precedence and the compiled code ends up with emulated
functionality of the server-intended implementation).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment