Factory example using our Reactor Gateway Factory
ColdFusion
One of a number of techniques we employ to cut down processing on our Reactor applications is to treat each gateway object that is created as a singleton and only one instance of each gateway exists per application intance. An easy way to acheive this is by using a factory to produce the Reactor Gateway objects when needed, and for that matter only one instance of the factory itself is ever created. Basically when you request a "Foo" gateway from our factory, our factory object first checks to see if the Foo gateway exists yet in the application scope. If it doesn't, it is then created. It then returns the application scoped Foo Gateway.
Here is our approach.
First, we will create our ReactorGatewayFactory object. It consists of only two methods:
Then in our methods that get intialized on application load, after we instantiate the Reactor Factory into the application scope as application.ReactorFactory, we put that Gateway Factory in the Application scope like this:
Now in our code when we need access to the Foo gateway we simplay call:
It should be noted that this techinque is by no means limited to use by the Reactor gateway factory, and was simply used to illustrate an example. We take the same type of approach with a Facade factory, standard Data Gateway Factory, and others.
- init() which accepts the Reactor Factory as an argument
- createGateway() which accepts the name of the Object which you wish to create a Gateway for





Loading....