JeeWiz Home  
The Model-Driven System Builder

JeeWiz Architect's Guide
 
Contents  >   4.  Meta-Models And Template Directories
 


4.2 Creating And Building A New Meta-Model

This page describes how to set up and create a new meta-model.

  1. Decide on the directory name to hold information. We recommend using a Java naming convention for the directory name. In other words, 'xmlSchema' (or 'XmlSchema'), but not 'Xml Schema' with a space in it. We use 'myMetaModel' in the examples that follow.
    A completed copy of the example described in this section is in the directory jeewiz/resources/myMetaModel_completed.
  2. Create the meta-model directory in the JeeWiz product tree under 'jeewiz/resources', which is the directory for standard meta-models (and renderings). In other words, create 'jeewiz/resources/myMetaModel'. A meta-model directory normally has the following three subdirectories:
    • specification, holding the specification of the meta-model and build products for the meta-model;
    • src, which is where the Java files for the meta-classes are created;
    • control, which is where the generated jar is placed. (Later we will see that the 'control' directory also holds the default rendering for the meta-model.
    Eventually, you will probably want to take a meta-model you create outside the JeeWiz product tree, but for now it is simplest to keep the meta-model in the same structure as all the other meta-models.
  3. Create the directory 'jeewiz/resources/myMetaModel/specification' to hold the specification of the meta-model.
  4. Create the file 'jeewiz/resources/myMetaModel/specification/assembly.xml' to define the meta-model. Here is the text that will define the meta-model (using with the following text:
    <meta-model name="myMetaModel"
           package="com.yourName.myMetaModel"
           descriptiveName="My First"
           >
      <description>
    <![CDATA[
    This is a test meta-model.
    ]]>
      </description>
    </meta-model>
  5. We need a couple of build files to meta-model and copy the following files into it:
    jeewiz/resources/myMetaModel_completed/build.xml
    jeewiz/resources/myMetaModel_completed/build.jwp
    
    The build.xml file is the Ant build job to generate the meta-model (into Java classes and a jar). The build.jwp is the Jeewiz properties file; see the description of the build properties file for details.
  6. Define your first meta-class by creating the file 'jeewiz/resources/myMetaModel/specification/my-first-meta-class.xml' containing the following text:

    <meta-class            name="my-first-meta-class"
                             >
      <description>
    <![CDATA[
    This defines a meta-class.  It's just a test
    ]]>
      </description>
      
      <property              name="name"
                             type="String"
                             required="true"
                             alias="my-other-name"
                             />
      
      <list                  name="my-children"
                             description="List of things below me"
                             type="my-first-meta-class"
                             index="name"
                             />
    
    <![CDATA[
    // Character data within a meta-class get's copied into the .java file.
    // So this can be implementation of additional methods for the meta-class.
    
    public String getHelloWorld()
    {
      return "Hello World!";
    }
    ]]>
    
    
  7. From the project directory (jeewiz/resources/myMetaModel), run Ant (just type 'ant'). You will need to have installed Ant on your system to do this. This should build the meta-model.
  8. The created files are
    • jeewiz/resources/myMetaModel/src/MyFirstMetaClass.java
    • jeewiz/resources/myMetaModel/classes/com/yourName/myMetaModel/MyFirstMetaClass.class
    • jeewiz/resources/myMetaModel/control/components.jar
The last file - components.jar - is the one that is actually used: this has a representation of the meta-model as executable Java code.

How you actually use this Jar and render using it is described later.

 


Copyright (c) 2001-2008 New Technology/enterprise Ltd.