![]() |
|||||
|
Chapter 4. Getting started with a Typed JMI clientThe Java Metadata Interface (JMI) provides a natural and easy-to-use mapping from a MOF-compliant data abstraction defined in UML to the Java programming language. Starting from the UML model the Java interfaces to the model can be automatically generated according to the JMI specification. Therefore if you are familiar with the MOF to Java Mapping defined in the JMI specification, you will find this chapter very much straightforward to understand. In this chapter you will see how to write your first openMDX client based on the UML model that has been introduced in Figure 2-1. Before you start with this chapter please make sure that you have generated the JMI accessors based on the lab model beforehand. A description of the lab model and how to generate the JMI accessors for it can be found in Introduction to the lab model. At the end of this chapter you will have the opportunity to practice what you have learnt in this chapter in a lab exercise. How to retrieve a package?In JMI packages play an important part. Each package object provides access to the class proxy objects wihtin its package scope. These class proxy objects are used to create instances (more on class proxy objects in the next section). A special package, the root package, represents the outermost package extent. All other packages are directly or indirectly nested within this root package. The root package acts as starting point for all top level packages like e.g. org which itself acts as starting point for its nested packages, e.g. openmdx. By means of the refPackage operation a package can retrieve its nested packages. The following code snippet shows how the example package org:openmdx:example:lab1 is retrieved. This example package will be used in the subsequent sections of this chapter.
Example 4-1. Setup initial root package and retrieve desired package // setup initial root package based on a given manager instance RefPackage_1_0 rootPkg = new RefRootPackage_1( this.manager ); // get desired package by means of refPackage call on root package lab1Package lab1Pkg = (lab1Package)rootPkg.refPackage( "org:openmdx:example:lab1" );
|
||||