The Reactor Generated Files

Now that we've generated a gateway object, let's take a look at our file system and see what happened.

 

Open your data directory.  What once was empty now has two folders: Gateway and Metadata.  These two folders correspond to the types of objects Reactor had to generate to create your UserGateway object.

 

Underneath both of these folders are a collection of CFCs.  Underneath the /data/Gateway folder there are two files, UserGateway.cfc and UserGatewayDBMS.cfc, where DBMS is the abbreviation of the database system you're using.  Because I'm working with MSSQL mine is named UserGatewaymssql.cfc.  If you're using MySQL 5 or later it would be named UserGatewaymysql.cfc.

 

If you look at UserGatewaymssql.cfc you will see:

 

<cfcomponent hint="I am the mssql custom Gateway object for the User object.  I am generated, but not overwritten if I exist.  You are safe to edit me."
    extends="UserGateway" >
    <!--- Place custom code here, it will not be overwritten --->
</cfcomponent>

 

This file is created so that you can add Database-Specific code to your application.  For example, if you are creating an application that will be distributed to run on either MySQL or MSSQL, you would end up having two versions of the database-specific file.  If you have a requirement for database-specific code it would go into the database-specific file.

 

The database-specific file extends a database agnostic component, UserGateway.

 

If you open UserGateway.cfc you will see the following code:

 

<cfcomponent hint="I am the database agnostic custom Gateway object for the User object.  I am generated, but not overwritten if I exist.  You are safe to edit me."
    extends="reactor.project.Scratch.Gateway.UserGateway" >
    <!--- Place custom code here, it will not be overwritten --->
</cfcomponent>

 

This file is created so that you can add Database-Agnostic code to your application.  Code in this CFC should always work, no matter what DBMS you're using.

 

This file extends another component, "reactor.project.Scratch.Gateway.UserGateway".  This CFC is created by reactor and contains a range of functions for the specific type of object.  This file should never be edited.  In fact, it's generated outside of your data directory (and maybe even your application) because the files in the reactor.project folder are volatile and could be overwritten at any time.  You're safe to look at the file, but don't edit it.  

 

Note that the "Scratch" in reactor.project.Scratch is your application name.  If you change your application name your DBMS-agnostic files will have the old application name hard coded into them.  They won't be able to find the CFCs for your new application name.

 

Note: Reactor generated code is not as nicely formatted as you might prefer.  Steps were taken to make it as readable as possible while still making the core XSL files reasonably easy to read. All in all, this code is not intended for human consumption.

 

Files in the reactor.Project folder extend core Reactor objects, such as AbstractGateway, based on their type which provide a set of core type-specific functions.  And, lastly, all of these objects ultimately extend a core AbstractObject object which provides the basest Reactor generated object functionality.

 

You don't need to remember this.  There will not be a test.  I just think it's useful to understand what's going on under the covers.

To learn what methods Reactor generated objects have, I suggest either dumping the objects using the cfdump tag or browsing directly to the component to see the ColdFusion generated documentation.

 

All other generated objects follow the same pattern as the UserGateway.