Geertjan's Blog

  • September 29, 2008

Spring RCP Application Initialized From Griffon

Geertjan Wielenga
Product Manager
To get them to co-exist, somehow Spring RCP's application class should replace the Griffon application class, or the other way round. Maybe I need to create an ApplicationBuilder for Spring RCP? There's also threading issues to figure out. Anyway, right now I'm able to show both applications: the Griffon application and the Spring RCP application (at least, their main windows):

Here's the application context, containing one single bean only, for the application class:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<bean id="application" class="org.springframework.richclient.application.Application">

Now the question is from where to initialize the above. In "Startup.groovy", I have this:

def rootController = app.controllers.root

...which points to this in the above referenced controller:

def appContextPath = "richclient-application-context.xml"
def startApplication = { evt = null ->
edt {
withWorker( start: true ) {
onInit {
work {
try {
new ApplicationLauncher(appContextPath)
} catch (RuntimeException e) {
println 'Failure'
onDone {

Without SwingWorker, I couldn't get it to work. Then when the application is run, first the Griffon view is shown, then you see Spring RCP output (all about initialization of Spring RCP internals), and then the application class is initialized and displayed. Whether the above is a step forward or not I don't know. But at least it shows the Spring RCP application, which is nice to see in this context.

Join the discussion

Comments ( 1 )
  • Andres Almiray Monday, September 29, 2008

    Geertjan, a couple of notes. Startup.groovy already runs inside the EDT, so calling edt{} inside startApplication() is not needed. withworker() is a thin abstraction layer over SwingWorker (jdk6/swingx depending on your running jvm), which only requires you to write code for the work{} and onDone{} blocks. onInit{} works like a constructor/initializer, in your case you don't need it :-)

    If your controller does not need to reference the Spring RCP Application bean, the you could safely put all the code in Initialize.groovy, which will run inside EDT also, so make sure to wrap your code with SwingBuilder.doOutside{} (doLater/doOutside are conveniently defined as static methods), or even Thread.start{ /\*your code\*/ }

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.