Architecture

Environment class

The Environment class is a central point of access to platform specific APIs; in this case ASP API. It exposes the following properties:

Environment methods:

  • init()
  • reset()

Each of the fifth property is an instance of corresponding Adapter object that extends HashMap. We are using Adapter pattern here to adapt ASP interface APIs to our own interface. Each adapter class defines a minimalist set of convenience methods delegating call to the underlying ASP intrinsic object.

This is a very flexible design approach that makes it possible to decouple and isolate ASP specific calls from the rent of the framework code. That means we can easily port the framework to any other web platforms, e.g. ASP.NET, PHP etc!

Extra advantage is that by replacing each adapter with a mock one we can easily test the hole framework code off line; no need for IIS server!

All properties of the Environment object are populated on initialisation stage. The reset() method refreshes the request and session properties.


Environment.prototype.init = function () {

  this.request =  new RequestAdapter();
  this.response =  new ResponseAdapter();
  this.session =  new SessionAdapter();
  this.server =  new ServerAdapter();
  this.application =  new ApplicationAdapter();

  return this;
};

Environment.prototype.reset = function () {

  this.request =  new RequestAdapter();
  this.session =  new SessionAdapter();
};

Please consult the implementation of each adapter. The interface of each is very similar to what you would expect from corresponding ASP object.

Each Command object will have a reference to Environment object so that you can access all underlying ASP adapters if you need raw ASP functionality.

Search

FAQ

Bookmarks

AddThis Social Bookmark Button

Support This Project