Technical Papers

Dynamic Plug-in Loading with Ada

Maintenance of high-availability systems (e.g., servers) requires the ability to modify, enhance, or correct parts of the application without having to stop and re-link the entire system. This capability is relatively straight-forward with interpreted languages or virtual-machine based languages such as Java, in which new code is loaded upon demand. In languages typically implemented with static executable images this capability can be offered though dynamically loaded/linked libraries (“DLLs”). However, in practice it is impractical to make full use of this capability because the protocol for invoking subprograms in a DLL is very low-level and unsafe. In the case of Ada, global coherency requirements and elaboration ordering constraints add an additional degree of complexity over less strict/safe languages. Object-oriented programming makes this approach practical by using dynamic dispatching to invoke dynamically loaded functions with a more robust, high-level protocol. In an OO paradigm, a “plug-in” contains new classes that enrich the class set of the original application. Calls to subprograms in the shared library (plug-in) are done implicitly through dynamic dispatching which is much simpler, transparent to the programmer, type-safe, and more robust. This application note shows how a statically-typed, statically-built, object-oriented language such as Ada can make full use of the notion of dynamic plug-ins á la Java without relying on a comparatively inefficient virtual machine. We build an extensible application and illustrate adding new functionality at run-time, without first stopping execution, using plug-ins. We use GNAT Pro to build the plug-ins and main program on a Windows system. Tailoring to run on Linux or similar operating systems would be straight-forward. Some new features of Ada 2005 are also used in the implementation. Section two describes the structure of the demonstration application and how plug-ins are discovered and loaded. Section three then shows the commands used to build and run the main program and the plug-ins. Section four provides closing remarks.

Attached Files

posted in GNAT Pro, Ada Compiler, Utilities, Runtime Profiles, Ada 2005 / 95 / 83, Certification, Mixed Language, Safety-Critical Development