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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="application" class="org.springframework.richclient.application.Application">
</bean>
</beans>
Now the question is from where to initialize the above. In "Startup.groovy", I have this:
def rootController = app.controllers.root
rootController.startApplication()
...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.
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\*/ }