Public: Concord Software Projects : Integrating Java applications into OTrunk
This page last changed on May 21, 2007 by sfentress.
In order to create an OTrunk component from an external Java application, you need three things:
While it is not strictly necessary to have access to the application's source code, correctly initializing and running the application without reading its main method becomes a tedious task of trial-and-error.
OTrunk components consist of two parts: a model and a view. Unlike a model-view-controller system, however, it is the view that must handle the initialization and running of the external application.
The simplest scenario for integrating an external Java component is to initialize the application (loading initialization data from an external URL if necessary) and display the application's Swing component. This supports embedding the component along with authored data but does not support OTrunk persistence of either the authored data or changes to the learner state data.
This level of integration is relatively simple: initializing an external application is as easy as copying the main method of the application and pasting into a "load" method in the OTrunk view. This load method is then typically called from the getComponent() method, which is itself called when the view is displayed in the OTrunk document. In many cases, however, some further tweaking of the initialization code is necessary to get the component to display correctly within the document.
After the application has been loaded, all that remains is to return a Swing component representing the application. Most Java applications display a JFrame when they are run. If this is the case, it is usually simplest to return the content pane contained within the application's JFrame, and to then hide or dispose of the frame to prevent multiple windows from opening within the OTML document.
We have currently integrated the following external applications:
|Document generated by Confluence on Jan 27, 2014 16:52|