This is the house what Jack built

Today I realized what we (or may be just I) live in very strange world. Let me describe why.

I work now on problem of making GORM domain classes accessible in GWT client-side code. It is an interesting task by itself and I plan  to dedicate  several separated posts to it but in general it is very simple. I want to define my server data objects in Groovy and be able to request them in from client-side code without coding too much.

The  solution is almost trivial. GWT provides great idea of generators which can create Java code to be integrated in to compilation of client-side JavaScript, so all what I need is to implement generator, which read groovy classes and generate all additional Java code I need. It is not too compilcated especially with Groovy in your hands.

What I realized debugging my code is how many different compilers, generators and even instrumenters involved in run of my one single test.

  1. Javac. I use it to compile Java part of my generator and the test to be run by JUnit.
  2. Groovyc. Most interesting part of my generator is written on Groovy
  3. GWT compiler from Java to JavaScript. It calls my generator and compile my test and generated Java code. If you curious, it contains built-in parser from Eclipse compiler
  4. BTW, compilation of unit tests in GWT involves generation of client-side part of the test. It’s a long story, which I will probably need to blog separately later. For now we just notice one more generation step.
  5. My generator use Groovy compiler to parse Groovy sources of domain classes. Main task for the generator is  to create client-side twins for domain classes and make them serializable.
  6. Of course, serialization may not happen for free. Fortunately GWT provide default generator, which takes care for generation such code for java source, generated by me.
  7. Again, just for record we should notice that my generator not only written on Groovy but also depends on Groovy runtime, which does some code instrumentation in magical GroovyClassLoader.
  8. There is one more thing, which I am afraid to speak about. GORM uses Hibernate and Spring. How many code generation and instrumentation used inside? God knows.
  9. I know only that even GORM iteself uses some to access Hibernate and Spring.

That’t it. But something is wrong in this world, isn’t it?

Advertisements

2 Responses to This is the house what Jack built

  1. […] This is the house what Jack built Today I realized what we (or may be just I) live in very strange world. Let me describe why. I work now on problem of […] […]

  2. herval says:

    yeah there is. And it’s called ‘too much complexity’…
    why do you need the groovy objects on the client side anyway…?

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: