Reactor XML Configuration Overview

The Reactor framework is configured via an XML file.  The XML configuration file is used to (optionally) set various configuration options such as the DSN and application name.  It is also used to configure relationships between database objects.

 

The XML configuration file is separated into two parts, general configuration and object relationship configuration.

 

This is a simple sample reactor XML configuration file which shows most of reactor's configuration options:

 

<reactor>
 <config>
   <project value="Scratch" />
   <dsn value="Scratch" />
   <type value="mssql" />
   <mapping value="/ScratchData" />
   <mode value="development" />
   <!-- These config values are not required -->
   <!-- <username value="" />
   <password value="" /> -->
 </config>

 <objects>

   <object name="Customer">
      <hasOne name="Address">
         <relate from="addressId" to="addressId" />
      </hasOne>

      <hasMany name="Invoice">
         <relate from="customerId" to="customerId" />
      </hasMany>
    </object>

    <object name="Address">
       <hasMany name="Customer">
          <relate from="addressId" to="addressId" />
       </hasMany>
    </object>

    <object name="Invoice">
       <hasMany name="Product">
          <link name="InvoiceProduct" />
       </hasMany>
    </object>

    <object name="Product">
       <hasMany name="Invoice">
          <link name="InvoiceProduct" />
       </hasMany>
    </object>

    <object name="InvoiceProduct">
       <hasOne name="Product">
          <relate from="productId" to="productId" />
       </hasOne>
      
       <hasOne name="Invoice">
          <relate from="invoiceId" to="invoiceId" />
       </hasOne>
    </object>

 </objects>
</reactor>

 
As you can see by looking at the example, the document is contained inside a root "reactor" tag block.  The "reactor" tag block contains only two other tag blocks, "config" and "objects".

 

The "config" block is used for general configuration.  The "objects" block is used to define relationships between objects in your database.