Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.cfconf.org/fusebox2004/ Mach-II Primer Ben Edwards An Introduction to Mach-II: An event-based, implicit invocation web-application framework.

Similar presentations


Presentation on theme: "Www.cfconf.org/fusebox2004/ Mach-II Primer Ben Edwards An Introduction to Mach-II: An event-based, implicit invocation web-application framework."— Presentation transcript:

1 www.cfconf.org/fusebox2004/ Mach-II Primer Ben Edwards An Introduction to Mach-II: An event-based, implicit invocation web-application framework

2 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II Introduction  Mach-II is a framework for writing object- oriented web-applications  Key Mach-II concepts:  Object orientation  Model-View-Controller (MVC)  Implicit Invocation

3 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II Introduction  In a web-application, Mach-II facilitates communication between the web interface and business objects: Web Interface (.cfm files, Flash movies) Mach-II Business Model (CFCs, WebServices)

4 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: MVC  Mach-II implements the Model-View- Controller (MVC) design pattern  The goal of MVC is to keep business logic and presentation logic independent of each other  MVC components are grouped in the following categories:  Model: business logic, data access  View: user’s perspective (HTML and CFM files)  Controller: mediation between model and view

5 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: MVC  Mach-II acts as an application’s controller, directing interaction between model and view components: Web Interface (.cfm files, Flash movies) Mach-II Business Model (CFCs, WebServices) VCM

6 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: An OO Framework  Mach-II is an object-oriented (OO) framework  Mach-II for ColdFusion is built entirely in CFCs  Mach-II development includes using framework components (CFCs) that will be extended and specialized

7 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Object-Oriented  With Mach-II developers write components that extend core framework objects (CFCs)  Mach-II components:  Encapsulated, self-contained  Cohesive, have singularity in purpose  Follow CFC coding best-practices

8 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Implicit Invocation  Mach-II uses an implicit invocation architecture  Implicit invocation is a software architecture for writing highly flexible, maintainable applications  In an implicit invocation system, business objects communicate with other objects via events  Listeners are business objects that respond to events

9 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Implicit Invocation  Events are used to communicate between layers: Web Interface (.cfm files, Flash movies) Mach-II Business Model (CFCs, WebServices) Event

10 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Implicit Invocation  Implicit invocation components:  Events – encapsulate information needed to perform an action  Listeners – business components that are notified when events occur; can also announce events  Event-handlers – define how to handle an event when announced

11 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Responsibilities  Mach-II framework main responsibilities:  Encapsulate requests into events  Handle all events processed for a request  Notify listeners of events  Mach-II developer main responsibilities:  Define events the framework can respond to  Define event-handlers to handle events when they occur  Define listeners to perform business logic

12 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Events  Events encapsulate the information needed to perform an action in a Mach-II application  Events can be announced by external requests to the framework (e.g. URL or form submission) or by components of the Mach-II framework  An event is an encapsulation of a requested action and any data associated with that request  URL data  form data  etc.

13 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Events  Events contain:  name – the name of the event  args – the information in the event used by listeners  Event definitions should be documented during design  Example events (name: args):  registerUser: firstName, lastName, emailAddress  addToCart: shoppingCart, product, quantity  newUserRegistered: newUser

14 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Event-handlers  Event-handlers are created by the framework to respond to events  Developers define event-handlers in an XML configuration file  Example event-handler XML:

15 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Listeners  Listeners components are notified when certain events occur to perform business logic  Listeners are implemented as objects (CFCs)  New functionality can be introduced simply by adding and registering new listeners (or new methods in existing listeners)  Because listeners know nothing about each other (loose coupling), changes to existing business logic entails less risk of introducing bugs into the application

16 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Event Lifecycle OK Mach- II Login formis submitted to Login Event userName: joe password: machii creates a mach-ii.xml reads AuthenticationListener invokes is passed to LoginSuccess Event LoginFailure Event announces specifies Username: Password:

17 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Request Handling  When Mach-II receives a web-request it will translate it into an event object  Consider the following request: ../index.cfm?event=registerUser&firstName=Bo b&lastName=Smith  The result is an event named registerUser with two arguments: firstName (Bob) and lastName (Smith)

18 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Event Handling  Mach-II can handle multiple events per request  Events are handled on at a time, in a queue (first in, first out) sequence  When an event is announced, it is placed at the bottom of the queue

19 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Code  A typical Mach-II project will consist of:  An XML configuration file (mach-ii.xml)  ColdFusion components for performing business logic  ColdFusion pages for user interaction

20 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Other Components  We’ve already covered events, event- handlers, and listeners. Other Mach-II components include:  Plugins – used in the Mach-II framework for customizing application wide functionality  Event-filters – reusable framework objects that can manipulate events and how they are processed

21 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Primer Review  Mach-II is an object-oriented framework, so much of the coding will be in CFCs that extend Mach-II components  We’ll be writing Mach-II code as:  CFCs (for business logic)  CFM templates (for presentation logic)  XML files (for configuration/controller logic)

22 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Process  A high-level overview of a Mach-II development process: 1.Develop prototype pages and page flow 2.Identify events that will drive the application 3.Identify objects needed to perform business logic (object model) 4.Identify listeners and other Mach-II components

23 www.cfconf.org/fusebox2004/ Mach-II Primer Mach-II: Resources  The Mach-II website, www.mach-ii.com, contains:  Documentation  Mach-II Configuration Guide  Mach-II Request, Event, and Error Handling  Articles  Mach-II How To Series  Introduction to Implicit Invocation  Consulting and Training  Forums and Mailing Lists


Download ppt "Www.cfconf.org/fusebox2004/ Mach-II Primer Ben Edwards An Introduction to Mach-II: An event-based, implicit invocation web-application framework."

Similar presentations


Ads by Google