Writing Extension Modules (Plugins) for
JAS 3
Mark Donszelmann Tony Johnson
Victor SerboMax Turri
CHEP2004, 27 september-1 october 2004,Interlaken, Switzerland.
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 2
Content JAS 3 and the FreeHEP Application
Framework Plugins
Management Menus, Command Processing and Pages Communication, Services Tree
Comparison to Other Frameworks Simple Event Display plugin Conclusions
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 3
JAS 3 JAS 3
Based on the FreeHEP Application Framework, Empty Framework into which
extension modules (plugins) can be loaded.
JAS3 IS just a set of built-in plugin modules
Provides General functionality: Top-level GUI: windows,
menus, status bar, etc… Help System Storage/retrieval of user
preferences Customizable
by adding, removing or replacing plugin modules.
Plugins Data Analysis and other
functionality is provided by a set of plugins.
Plugins are (in general) only loosely coupled. Provide a set of services and
events available to JAS and extensible by new plugin
modules.
Communication restricted to service interfaces and
notification events.
Can be added, removed, upgraded independently Present seamless interface to
user, for instance by merging functionality into existing menus
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 4
Example Plugin:BaBar’s Ambient Data Explorer
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 5
Example Plugin:FermiLab’s Accelerator Control
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 6
Management of Plugin Modules Plugin Types:
Built-in modules (cannot be removed)
System modules (come standard with JAS)
User modules (individual or group based)
PluginManager in JAS to handle installation and removal
Semi-Automatic download of updated plugins based on version numbers
Plugins can be published on the Web as jar files with an embedded XML description file
Dependencies and versions can be specified
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 7
Built-in and System modules Built-in modules
Console Data Source File Opener Plotter Plugin Manager Preferences Save/Restore Status Bar Tree Web Browser
System modules AIDA Compiler Excel Jython PAW for AIDA Pnuts Record Loop Root for AIDA Simple Editor SpreadSheet Tuple Explorer
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 8
Instantiation and Initialization
Plugins inherit from the Plugin class. Plugins are constructed after which the init()
and postInit() methods are called. Plugins may implement a set of standard or
plugin defined services.
Plugins make themselves known to the system in the init() method.
Plugins should look for other plugins in the postInit() method or afterwards.
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 9
Menu and ToolBar Plugins can add their own menus
to the Menubar in any position to any submenus in any position
Plugins can add their own toolbars to the general toolbar toolbars automatically hide themselves if
functionality is temporarily unavailable
Menus and Toolbars can be added statically, using an XML description file dynamically by the plugin at runtime
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 10
Command Processing
Actions from menus and toolbars hook up to a command processor Handles enabling and disabling of menu/toolbar
buttons Handles state of checkbox or radio buttons Handles the dispatching of actions to multiple
listeners
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 11
Pages Pages can be used by plugins to display any
content (Histograms, Events, …) PageManager handles the display of pages.
as tabbed pages as internal windows
ManagedPage service allows you to handle page notifications page displayed page selected page iconized …
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 12
Find others and be found
Lookup system Lookup services by class or interface Lookup services by name
Publish Register by class and name
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 13
Services
Standard services FileHandler / URLHandler DataSource ManagedPage PreferencesManager …
Plugin-defined for others to look up and use
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 14
Tree - a point of contact Plugins can add/remove nodes
on the tree A node is defined by a type
(java Class) and can contain multiple objects
Any plugin can attach objects to a given node
Plugins can add behavior to any type of node A node’s behavior is defined
by its type (by inheritance) Node adapters are registered
with the tree for a given type and with a given priority
A node adapter controls: Single and Double click Popup menu Icon Text Drag & Drop …
Plugins modify the tree by sending it Notifications
The trees feedback to the plugins is sent via Events
Plugins can modify behaviour of nodes created by other plugins
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 15
Via the Root plugin we open a root file
The content of the root file is presented in the tree by the AIDA plugin: histograms and tuples are shown
The TupleExplorer plugin modifies the appearance and behavior of a tuple by adding extra functionality: the internal structure is displayed. Ex.: the tooltip text is modified.
Tree - Root Example
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 16
Comparison to other Frameworks Other similar framework available for Java IDEs
Netbeans JAS uses some utilities from netbeans and will likely adopt other
modules (editor, window manager) in future Eclipse
Newer plugin architecture, architected for fast startup (e.g. plugins not loaded until used)
Eclipse is SWT based (not Swing like Netbeans, JAS) Open source Java Plugin Framework
http://jpf.sourceforge.net/ Encapsulates feature of eclipse plugins without SWT Maybe useful for future release of JAS
JAS is a much lighter framework than full IDE JAS base plugins provide plotting, data analysis capabilities.
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 17
Simple Event Display(real life example) Suppose you want to read a file with an event per line format like this:
eventLabel run#.event# weight Ecm[GeV] zVertex[cm] objectType1 (mass)[GeV] pT[GeV] eta phi[degrees] …
mad_ttbar-e+vemu-vm-b-b 151435.538095 0.05 1960. -10.21 e+ 55.5416 -1.17836 89.2775 mu- 26.8907 -0.236785 -82.8115 j 9.03099 104.635 0.22464 -120.258 j 4.31111 25.401 -0.992276 21.7658 uncl 0 12.9285 056.8782;
and display the events in WIRED 4, with all itsfunctionality:
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 18
Simple Event Display Plugin Give the file an extension Create a FileHandler for it Parse the file and provides its lines as Records in a RecordSource Each Record needs to be converted (on the fly) into a HepRep Provide to WIRED 4.
Green = Part of JAS/FreeHEP Pink = Provided by plugin implementer
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 19
Conclusion
JAS 3 is a configuration of plugin modules used in the lightweight FreeHEP Application Framework.
It can be easily extended by writing fairly independent plugin modules
Plugin modules can communicate with JAS and other modules via services and events.
30 September 2004 Mark Donszelmann, CHEP 2004, Interlaken, Switzerland 20
References
JAS 3 – http://jas.freehep.org/jas3 Documentation on JAS 3 and how to write
extension modules. Forums – http://forum.freehep.org
Discussions on JAS 3, FreeHEP and WIRED 4.