Griffon+Remote GORM+X: Inspirations for the Best RIA Horse!

Today I explain a possibility of a pure Java-based client/server application (the client side should be a Rich Internet Application) with a database backend.

I know that other people might already had this idea and others implemented this in a different way and Griffon is on the way, but let my explain it now in (more) detail. It is only an aggregation of existing tools.

How should it look like?

We simply replace the HTML-view of an ordinary Grails application with Griffon! So instead of a browser we will have the mature JVM and we could programm all in Java/Groovy! No JavaScript, no HTML, no CSS, no …!

(Ups. No CSS? Okay we could use css on the desktop, too)

Shouldn’t this be an easy task to replace the V in an MVC application? The problem lays in the detail. E.g. do we need the full GORM functionality on the client side (‘remote GORM’)?

The cayenne framework (a nice hibernate alternative) supports the so called remote object persistence which would be great for this kind of application. They use the hessian library to communicate over HTTP from the client ‘over’ the server to the database. So, the db-programming-style on the client is nearly identical to that on the server!

So, do we need Person.findByXY and all the other, useful methods on the client? I fear tweaking hibernate is necessary but maybe with some grooviness we could avoid this!?

Another simpler approach would be to use the already available services of Grails for the client side. With Xml (Un-)Marshalling or SOAP like it was done before? But hmmh, I prefer the cayenne way … its groovier!

So, what do we need for our 3 tier pure Groovy solution?

We’ll need Grails!

To be a bit more specific: we would actually only need the GORM plugin (and Spring) from the Grails project for the server to communicate to the DB and manage the migrations.

We’ll need Griffon!

We need the full Griffon stack for the client. And if we only use GORM from Grails we will use Griffon also on the server side, I guess.

So either GORM+Griffon+Griffon (db+server+client), which would be more consistent

or GORM+Grails+Griffon which could be easier to implement at the moment.

We’ll need Spring Rich Client!

We need some nice to have packages from the Spring Rich Client project for the client side: validation, window-docking, master-details stuff, …

We’ll need the Hessian Library!

Additionally to the GORM plugin we will need the Hessian library to easily (!) communicate between the client and server. (Short explanation: Hessian library is RMI without drawbacks.) Later on we could implement a remote GORM with the help of this library (see above)! Without this functionality we won’t have fun: either we can only implement a two tier applications (client+db) or the programming is as slow as it would be with an ordinary non-groovy desktop application (via SOAP etc).

We’ll need JavaFX!

Why do we need JavaFX if we already have Groovy as the UI DSL? Marketing! That would mean a broader audience and maybe some tiny  support of Sun 😉

Another feature of JavaFX would be that designers could create good looking SwingUIs for us without knowing Java/Groovy.

XML Marshalling

TimeFinder v4 Released – Automatic Educational Scheduling

Today the TimeFinder Team (its me ;-))
announces the availability of TimeFinder v4!

TimeFinder allows universities and schools to reduce and even avoid conflicts in the timetable! TimeFinder will improve the work of the human timetabler at the institute. A lot of work which would be done by hand to create the educational schedule could be done with TimeFinder.

TimeFinder is completely free and independent of the operating system (via Java 6). The power of TimeFinder is its algorithm. It eliminates the hard-conflicts of nearly all datasets of the International Timetabling Competition 08 in under 20 seconds on a normal laptop. And it can be applied on real data like the one from University of Bayreuth.

Pictures tells a lot more than 1000 words, so here is a video as introduction

and here are some screenshots:

The first screenshot is how editing of events works

  1. create a new event
  2. then set the name
  3. and specify the start and duration
  4. after this you can add some visitors under Event Table->Persons

edit-events

And here you see how TimeFinder optimized an instance of the International Timetabling Competition 08:

after-optimization

See some more screenshots and look again here for the video documentation.

Start TimeFinder right now via WebStart! Or download the jar which is faster!

New Features

The TimeFinder Team worked hard to add the following features in this version for you:

  1. Events with any duration are now possible – without performance losings! (before only duration=1 was possible)
  2. A more robust and lightweight Swing component the TimeFinderPlanner to display the schedule/timetable of all locations and persons was implemented and replaces the JavaFX component hassle. This component is small (<30KB) and but has some dependencies (1MB). It has the same purpose as MigCalendar, but is of course not as powerful as this.
  3. Import of text files (tab separated, comma separated data). XML was already supported in previous versions
  4. Auto-import for the last imported file
  5. Cloning entities is now possible
  6. Anonymize data, so that institutes could give away its data for performance-tests and other research projects.
  7. Import of the data for University of Bayreuth (Germany) and the possibility to optimize this data set with >1500 events; >100 locations; >600 resources (persons/course of studies) is now possible and shows how other institutes could use its existing data with TimeFinder.
  8. Removed a lot of deprecated classes and removed unused dependencies (now ~11MB)
  9. Now the English TimeFinder is fully translated into German too. Translation is now simplified with a small tool.
  10. A new maven module called algo was created (~3MB), to reduce coupling of the algorithm to the GUI. Now it is theoretically possible to deploy the algorithm without the spring dependency e.g. to an optimization server.

Support

No software is complete or bug-free, and so is TimeFinder which is beta software at the moment. You are free to support TimeFinder with your constructive critique, blog posts or even money if you like to make it better. Feel free to contact me or raise an issue if you find a bug.

Check the documentation or watch an introductive video to get an overview. Keep in mind that updating documentation is still work in progress.

You can win

If you know some Java and like coding GUIs, databases or algorithms you can contact me and win experiences via joining the project!

Especially the calendar component TimeFinderPlanner could be alluring for people with Java2d experiences or interests in this area.

Thanks!

This application wouldn’t be the same without the following nice open source projects:

… and last but not least thanks to NetBeans – the only IDE you need
and Yourkit profiler, which offers open source projects a free license!

TimeFinder – Powerful Optimization Algorithm, RIA and more

TimeFinder is an Open Source Timetable Optimizer for universities and schools, which uses the Spring Rich Client project to create an easy to use application with a nice user interface, a database and … more bla bla …

ok, it is a bit dingy headline and a more dingy introduction, but I would like to invite you to test the latest development version v4 of TimeFinder now! And without such a headline you woudn’t have read this. And I feel that I would like to release TimeFinder in the next weeks, so I need some beta testers. Go here to see some screenshots.

Get the dev version of TimeFinder here, double click the jar (optionally read the documentation for v1) and tell me:

  1. If you understand the purpose of TimeFinder from the website
  2. If you understand the user interface and how you can insert data
  3. If you find a bug
  4. If you need other features

Any feedback is welcome! Please contact me at peathal AT yahoo |dot| de, post an email to the mailing list or simply leave a comment here.

Java Application Frameworks (not only client side …)

In an old post I listed all Java libraries,where only two application frameworks were listed.

Today it is time to list some client side Java application frameworks, because I discovered some new ones while reading the W-JAX announcement. Some of the listed frameworks will make developing application with DB easier. And some of them are real 3 tier architectured frameworks. Some of them even allow you to develop RIA’s and web frameworks at the same time.

Here is now the list of open source Java application frameworks especially for the desktop. Feel free to add some more (via comment):

  1. NetBeans RC Platform, my IDE is build on this 😉
  2. Eclipse RC Platform, has an interesting ‘subproject’ called Riena
  3. Spring RC, at the moment my favourite used in TimeFinder
  4. AppFramework which won’t be in JDK 7, but has a lot of derivatives
    1. Swing application framework fork
    2. Guice Utilities & Tools Set
    3. Better Swing AppFramework
    4. with OSGi
  5. JVx, looks very nice! Makes fast development of Swing applications possible (with db support)
  6. OpenXDev a framework which could be used as a base for your next Swing project
  7. Genuine is a client framework for Java Swing applications for which it provides basic infrastructure
  8. Genesis with Swing and SWT binding; Easy, transparent remoting; etc
  9. GWT (although only intented for javascript widgets it could theoretically being used as a rich client running in the jvm)
  10. OpenSwing Framework is an open-source suite of advanced graphics components based on Swing toolkit
  11. Leonardi Framework
  12. Jspresso is a framework for building rich internet applications
  13. Viewa framework
  14. XUI is a Java and XML RIA platform
  15. Swing + XUL = SwiXAT looks interesting but dead, the same for the next:
  16. Swing + XML = SwiXml a small GUI generating engine.
  17. buoy built on top of Swing. Xml serialization of UI possible
  18. But why xml if you have groovy: Griffon 😉
    Now, a nice approach would be to send/receive groovy code and build the clients’ GUI on fly… this would be like replacing the browser+html+javascript system with rock solid JVM+Groovy 😉
    Another Comment from AndresAn addtional tidbit about Griffon, it can be seen as a polyglot programming desktop/RIA framework as it supports 5 JVM languages at the moment: Java, Groovy, Scala, Clojure and JavaFX. It also lets you embed JavaFX components on Swing containers.
  19. JMatter is a software framework for constructing workgroup business applications based on the Naked Objects Architectural Pattern.
  20. Metawidget is a ‘User Interface widget’ that populates itself, at runtime, with UI components to match the properties of your business objects.
  21. Pivot a platform for building rich internet applications in Java

Especially JVx with a webstart demo looks very promising! It even feels better and faster than an ordinary flash application!

Commercial:

  1. Aviantes-Business-Application-Framework
  2. Jide Desktop Application Framework
  3. Jazz

I listed only frameworks which help developers to easier build client side desktop application and only if they run in the JVM. So frameworks where the client is browser-based (aka web frameworks) are not listed here.

For a good list of J2EE frameworks go to java-source.net or to wikipedia. (Or here, or there, or even here)

Update: For additional comments look at dzone

Plugable Spring RC? (OSGi with Spring Rich Client)

My last post was about pure Swing, which could be easily OSGified. OSGi technologie can be e.g. used to hotdeploy or undeploy jar files to your application server (at the moment only Spring’s server is suggested) or simply to update your Swing application at runtime or write plugins for them. I don’t know for sure, but it seems to me that Eclipse is the most prominent user of OSGi (equinox is one implementation of the specification…) as desktop application, although NetBeans can now use OSGi bundles.

(BTW: do you know a funny myth where the small “i” from OSGi could come from? No? Read the comments here!)

In the last post I show you several swing applications, which were successfully OSGified, today I would like to list Swing- or Eclipse-based applications which use Spring Dynamic Modules:

Then today, in contrast to my last post, I would like to show you an identical solution for the Spring Rich Client project.

Why should I use another framework on the top of OSGi? This is simple: Spring DM provides several nice features, like no dependency on the OSGi implementation (felix, equinox, knopflerfish) and even no one on OSGi at all. Everything (and think) is a bean, like always! But why Spring DM? Why not Declarative Services from OSGi itself or Apache iPOJO? This is simple: I don’t know the others and Spring Rich Client cries for the Spring solution 😉

But to make this short story very short: after struggling the last two days to get Spring Dynamic Modules integrated with Spring Rich Client I gave it up and tried the pure OSGi solution – and – it works. It might be an ugly solution for all those of you who like dependency injection, but this can be optimized later. Today this might be the first plugin for Spring Rich Client – ever:

osgified-springrc

The button “say hello” with its JOptionPane message was installed through the dynamically loaded plugin. The source code is nearly identical to the one in my previous post. Just add the Spring RC startup before you grab the menu from the application to create a MenuTracker, which calls the MenuService(=plugin):

@Override
public void start(BundleContext context) throws Exception {
 startup.start();
 menuTracker = new MenuTracker(context, Application.instance().getActiveWindow().getControl().getJMenuBar().getMenu(1));
 menuTracker.open();
}

The source is available from my TimeFinder project via:

svn checkout -r 595 https://timefinder.svn.sourceforge.net/svnroot/timefinder/trunk timefinder

Be sure to start the application from de.timefinder.core.osgi.Activator (main method!).

I hope this post inspired someone to be the first one with Spring DM + Spring RC marriage … or sb. suggests working examples how Spring DM could be started from command line or from NetBeans.

Swing Talks (video and slides available)

Maybe you already know that at parleys they put some nice presentations.

Especially the talk Spring is Swinging from Jo Wyns was impressive to me, where he talks about the Spring Rich Client project.

The presentation seems to be an old one (where is the date??), but it is even today a hot theme: rich desktop applications with database access (or internet connection). He concludes his talk with a tip, when to stop or when is is a bit too far. I think with too far he means projects like the metaframeworks I talked about earlier. And maybe this is true: in commercial applications nearly always you will need to customize views etc. then the simple “annotated domain object”-approach will only work for the first rapid prototype.

Have fun with this talk and with the related talks (here or here).

A Pagination-enabled List in Swing with Hessian

In an ealier post I documented how to set up a maven project to use port 80 for client-server-communication in a Java Swing project.

Today I want to show how you could implement a list which shows ‘all’ objects of one entity. It is common that there exists thousand or more objects for one entity in a database, so pagination is required. I know that JList and JTable could handle very large result sets easily, but the bandwith would be the limitating factor and loading all the objects into memory is often not required (and not good …).

I will use the simplest Swing solution with some pagination buttons, although it would be a lot nicer to have the pagination with a custom vertical JScrollBar-implementation which loads the objects while scrolling (‘on demand’). But this will be either a task for my readers or for myself at a later time. First we can take a look at the resulting (primitive) GUI:

paginationlist

The interface for the data access object was quickly created:

public interface RemoteDao<T> {
   List<T> getAll(int index, int items, String query);
   int count(String query);
}

… the implementation, too (but for this see the source in the provided project). You can simply replace the existing fake-implementation with a RemoteHibernateDao or sth. like this, if you like.

The communication follows this picture:

dao-hessian

To try this maven project: start PaginationServlet under the paginationlist package and then the PaginationClient. The Swing gui should pop up and you could hit enter after a search string like ‘person’ or ’18’ in the textfield at the top. Now try to paginate through the results with the provided buttons at the bottom.

The final goal for me (at a later time) will be to replace the left ‘Available’-JList in a ShuttleList (from Spring rich client project) with my PaginationList. For you information: with a normal ShuttleList one could drop one or more items from ‘available’ list to ‘choosen’ with the buttons in the middle (they have nothing to do with pagination!). Here a normal shuttle list is shown:

shuttlelist-orig

So, now have fun with my small Swing example and feel free to provide feedback or ask questions if you need help while maven or sth. else!