Online Glom is now all Java

Over the last couple of weeks I have reimplemented just enough of the C++ libglom code as Java in Online Glom‘s gwt-glom, removing the need for java-libglom (which wrapped libglom for Java via SWIG). It’s now working and deployed on the Online Glom test server.

This makes both development and deployment much easier. It also made the source code all camelCase so it’s not offensive to the eyes of Java coders.

To replace libglom’s use of GdaSqlBuilder, I used jOOQ. That worked well, thanks to its maintainer, Lukas Eder, who was very helpful and who quickly added some API that I needed.

Now that the code is all Java I really hope that more people will look over the code and point out anything that can be improved. I still don’t know Java like I know C++ so please don’t be shy about telling me that I have made mistakes.

GWT, Javascript, and serialization

Removing the use of java-libglom let me simplify the code, because I can now send object, such as LayoutItem, to the client without needing to copy it into a separate LayoutItemDTO object that existed just because the original wasn’t serializable, so it could be sent from the server (Java) to the client (JavaScript, compiled from Java).

However, this raised some new issues. I wanted some of the objects to contain some extra cached data, so that the client code did not have to calculate it itself, often by retrieving some other related object. Right now these are extra member variables in the classes, but that prevents me from splitting the code off into a new java-glom library.

Furthermore, any class that is sent between the client and server must fully conform to the requirements of the GWT Java-to-JavaScript compiler, even if that method will not actually be run on the server. For instance, I tried to add clone() methods, for use on the server, but that broke the JavaScript compilation because it doesn’t have an equivalent for Object.clone().

Those restrictions on the Java code that is allowable on the client side (because it will be compiled to JavaScript) were particularly awkward when the compiler (or Maven, or something) refused to give me clues about what was wrong. For instance, it took me 2 frustrating days to fix this small error by breaking the code apart until only the problem code remained. At other times, there was no real error on stdout, but there were clues (in a variety of hard-to-read formats) in the HTML generated by mvn site. Or sometimes, I could see errors when building inside Eclipse, but not outside.

The GWT system works great, but something is inconsistent about how it shows errors, and it can’t be right that some compilation errors only show up when running, rather than when building.

Next steps

As much as I would like to move on to implementing editing, I need to spend some time now on getting some regression tests set up in the maven build. These must create and run temporary PostgreSQL database instances like I do in the Glom autotools build. For instance, I need to check that the new SQL-building code, using jOOQ, is really safe from SQL injection like the libglom code seems to be.

My recent changes also caused the OnlineGlomService async API to be particularly inefficient, sometimes sending far more data back to the server than should be necessary. I will try to avoid that and try to make this API smaller, to avoid so many round trips.

5 thoughts on “Online Glom is now all Java

  1. It’s great to see a pure Java version of libglom working with Online Glom! It’s definitely going to make deploying and hacking easier.

    Just one comment: If you want to create a full Java version of libglom without the restrictions of GWT, I believe you can use the RequestFactory framework to transfer the data without having to manually copy it into DTOs. Of course this will add complexity to the code. Here’s the documentation in case you’re interested:

    Now that Online Glom has only Java dependencies, it would be interesting to see if it could be run on Heroku ( or OpenShift ( to remove the need to manage servers.

  2. My question is regarding this java library is how you do login. I have a student that is currently implementing the android version for glom and we wanted to have some ideas regarding how do you authenticate the user.

    1. > My question is regarding this java library

      What Java library do you mean?

      > is how you do login

      Both regular Glom and Online Glom (gwt-glom) just defer to PostgreSQL. You give Online Glom (or Glom) your password, and Online Glom tries to connect to the database server (via JDBC). If it cannot connect the the database server (as specified in the .glom file) then it doesn’t bother trying to do anything else with that .glom file.

      This means, of course, that the database structure is currently not secret, though the data is.

      > I have a student that is currently implementing the android version for glom

      That’s a rather large task. I hope you have modest initial goals, such as implementing a read-only UI, like Online Glom

      Also, you probably want to use my libglom code from gwt-glom to load the .glom file and use its structure:

      But you can’t use that source code unless your source code is open source. Which would be wise anyway, so it would be great to see a link to something in gitorious or github, for instance.

  3. it’s open sourced, and it will be only a read only client, no developer mode will be supported. At the right time it will be available on git, but fist this student has to finish the project, after that everything has to be organized for git.


Leave a Reply

Your email address will not be published. Required fields are marked *