[flexcairngorm] r101 committed - Now includes Flashbuilder 4 (with SDK 3.4) project settings....

3 views
Skip to first unread message

codesite...@google.com

unread,
Feb 18, 2010, 5:39:34 PM2/18/10
to cairngorm...@googlegroups.com
Revision: 101
Author: Tho...@UniversalMind.com
Date: Thu Feb 18 14:33:27 2010
Log: Now includes Flashbuilder 4 (with SDK 3.4) project settings.
Also includes ANT build scripts.
http://code.google.com/p/flexcairngorm/source/detail?r=101

Added:
/trunk/code/.actionScriptProperties
/trunk/code/.flex2docProperties
/trunk/code/.flexLibProperties
/trunk/code/.project
/trunk/code/.settings
/trunk/code/.settings/com.adobe.flexbuilder.project.prefs
/trunk/code/.settings/org.eclipse.core.resources.prefs
/trunk/code/flex2ant-master.xml
/trunk/code/src
/trunk/code/src/cairngorm-manifest.xml
/trunk/code/src/com
/trunk/code/src/com/adobe
/trunk/code/src/com/adobe/ac
/trunk/code/src/com/adobe/ac/Observe.as
/trunk/code/src/com/adobe/ac/ObserveValue.as
/trunk/code/src/com/adobe/ac/Observer.as
/trunk/code/src/com/adobe/ac/SmartObserve.as
/trunk/code/src/com/adobe/cairngorm
/trunk/code/src/com/adobe/cairngorm/CairngormError.as
/trunk/code/src/com/adobe/cairngorm/CairngormMessageCodes.as
/trunk/code/src/com/adobe/cairngorm/business
/trunk/code/src/com/adobe/cairngorm/business/AbstractServices.as
/trunk/code/src/com/adobe/cairngorm/business/HTTPServices.as
/trunk/code/src/com/adobe/cairngorm/business/IServiceLocator.as
/trunk/code/src/com/adobe/cairngorm/business/IServices.as
/trunk/code/src/com/adobe/cairngorm/business/RemoteObjects.as
/trunk/code/src/com/adobe/cairngorm/business/Responder.as
/trunk/code/src/com/adobe/cairngorm/business/ServiceLocator.as
/trunk/code/src/com/adobe/cairngorm/business/WebServices.as
/trunk/code/src/com/adobe/cairngorm/commands
/trunk/code/src/com/adobe/cairngorm/commands/Command.as
/trunk/code/src/com/adobe/cairngorm/commands/ICommand.as
/trunk/code/src/com/adobe/cairngorm/commands/SequenceCommand.as
/trunk/code/src/com/adobe/cairngorm/control
/trunk/code/src/com/adobe/cairngorm/control/CairngormEvent.as
/trunk/code/src/com/adobe/cairngorm/control/CairngormEventDispatcher.as
/trunk/code/src/com/adobe/cairngorm/control/FrontController.as
/trunk/code/src/com/adobe/cairngorm/model
/trunk/code/src/com/adobe/cairngorm/model/IModelLocator.as
/trunk/code/src/com/adobe/cairngorm/model/ModelLocator.as
/trunk/code/src/com/adobe/cairngorm/view
/trunk/code/src/com/adobe/cairngorm/view/ViewHelper.as
/trunk/code/src/com/adobe/cairngorm/view/ViewLocator.as
/trunk/code/src/com/adobe/cairngorm/vo
/trunk/code/src/com/adobe/cairngorm/vo/IValueObject.as
/trunk/code/src/com/adobe/cairngorm/vo/ValueObject.as
/trunk/code/src/com/universalmind
/trunk/code/src/com/universalmind/cairngorm
/trunk/code/src/com/universalmind/cairngorm/business
/trunk/code/src/com/universalmind/cairngorm/business/Delegate.as
/trunk/code/src/com/universalmind/cairngorm/business/ServiceLocator.as
/trunk/code/src/com/universalmind/cairngorm/commands
/trunk/code/src/com/universalmind/cairngorm/commands/Command.as
/trunk/code/src/com/universalmind/cairngorm/control
/trunk/code/src/com/universalmind/cairngorm/control/BaseController.as
/trunk/code/src/com/universalmind/cairngorm/control/FrontController.as
/trunk/code/src/com/universalmind/cairngorm/control/ModuleController.as
/trunk/code/src/com/universalmind/cairngorm/events
/trunk/code/src/com/universalmind/cairngorm/events/AnnounceFaultEvent.as
/trunk/code/src/com/universalmind/cairngorm/events/Callbacks.as
/trunk/code/src/com/universalmind/cairngorm/events/IUMEvent.as
/trunk/code/src/com/universalmind/cairngorm/events/UMEvent.as
/trunk/code/src/com/universalmind/cairngorm/events/generator

/trunk/code/src/com/universalmind/cairngorm/events/generator/EventGenerator.as
/trunk/code/src/com/universalmind/cairngorm/events/generator/EventUtils.as

/trunk/code/src/com/universalmind/cairngorm/events/generator/IEventGenerator.as
/trunk/code/src/com/universalmind/cairngorm/vo
/trunk/code/src/com/universalmind/cairngorm/vo/ConnectionVO.as
/trunk/code/src/com/universalmind/cairngorm/vo/IValueObject.as
/trunk/code/src/locale
/trunk/code/src/locale/en_US
/trunk/code/src/locale/en_US/CairngormMessages.properties

=======================================
--- /dev/null
+++ /trunk/code/.actionScriptProperties Thu Feb 18 14:33:27 2010
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<actionScriptProperties mainApplicationPath="UM_Cairngorm.as"
projectUUID="e257364b-4d7d-4675-af8a-f9e80558f0c1" version="6">
+ <compiler additionalCompilerArguments="-source-path+=locale/{locale}
-locale en_US -include-resource-bundles CairngormMessages
-allow-source-path-overlap=true" autoRSLOrdering="true"
copyDependentFiles="false" generateAccessible="false"
htmlExpressInstall="true" htmlGenerate="false"
htmlHistoryManagement="false" htmlPlayerVersionCheck="true"
includeNetmonSwc="false" outputFolderPath="build" sourceFolderPath="src"
strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false"
useDebugRSLSwfs="true" verifyDigests="true" warn="true">
+ <compilerSourcePath/>
+ <libraryPath defaultLinkType="1">
+ <libraryPathEntry kind="4" path="">
+ <excludedEntries>
+ <libraryPathEntry kind="3" linkType="1"
path="${PROJECT_FRAMEWORKS}/libs/qtp.swc" useDefaultLinkType="false"/>
+ <libraryPathEntry kind="3" linkType="1"
path="${PROJECT_FRAMEWORKS}/libs/datavisualization.swc"
useDefaultLinkType="false"/>
+ <libraryPathEntry kind="3" linkType="1"
path="${PROJECT_FRAMEWORKS}/libs/automation.swc"
useDefaultLinkType="false"/>
+ <libraryPathEntry kind="3" linkType="1"
path="${PROJECT_FRAMEWORKS}/libs/automation_dmv.swc"
useDefaultLinkType="false"/>
+ <libraryPathEntry kind="3" linkType="1"
path="${PROJECT_FRAMEWORKS}/libs/automation_flashflexkit.swc"
useDefaultLinkType="false"/>
+ <libraryPathEntry kind="3" linkType="1"
path="${PROJECT_FRAMEWORKS}/libs/automation_agent.swc"
useDefaultLinkType="false"/>
+ </excludedEntries>
+ </libraryPathEntry>
+ </libraryPath>
+ <sourceAttachmentPath/>
+ </compiler>
+ <applications>
+ <application path="UM_Cairngorm.as"/>
+ </applications>
+ <modules/>
+ <buildCSSFiles/>
+</actionScriptProperties>
=======================================
--- /dev/null
+++ /trunk/code/.flex2docProperties Thu Feb 18 14:33:27 2010
@@ -0,0 +1,55 @@
+<com.farata.flex2doc.models.Flex2DocSettingsModel>
+ <localASDocParams>
+ <projectName>UM_Cairngorm 2.2.1</projectName>
+ <windowTitle>Universal Mind Cairngorm 2.2.1</windowTitle>
+ <title>UM_Cairngorm 2.2.1</title>
+ <appendConfig>false</appendConfig>
+ <sourcePath>E:\projects\UniversalMind\Cairngorm\src</sourcePath>
+ <libraries>
+
<string>DOCUMENTS/.metadata/.plugins/com.adobe.flexbuilder.codemodel/extraClassPath</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/playerglobal.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/automation.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/automation_charts.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/charts.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/flex.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/framework.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/rpc.swc</string>
+ <string>F:/Program Files/Adobe/Flex Builder 3
Plug-in/sdks/2.0.1/frameworks/libs/utilities.swc</string>
+ </libraries>
+ <appendLibsFlag>true</appendLibsFlag>
+ <outputFolder>E:\projects\UniversalMind\Cairngorm\asdocs</outputFolder>
+ <classes>
+ <string>com.universalmind.cairngorm.control.BaseController</string>
+ <string>com.universalmind.cairngorm.control.FrontController</string>
+ <string>com.universalmind.cairngorm.control.ModuleController</string>
+ <string>com.universalmind.cairngorm.events.Callbacks</string>
+
<string>com.universalmind.cairngorm.events.generator.EventGenerator</string>
+
<string>com.universalmind.cairngorm.events.AnnounceFaultEvent</string>
+ <string>com.universalmind.cairngorm.events.UMEvent</string>
+ <string>com.universalmind.cairngorm.commands.Command</string>
+ <string>com.universalmind.cairngorm.business.Delegate</string>
+ <string>com.universalmind.cairngorm.business.ServiceLocator</string>
+ <string>com.adobe.cairngorm.control.CairngormEvent</string>
+ <string>com.adobe.cairngorm.control.FrontController</string>
+ <string>com.adobe.cairngorm.control.CairngormEventDispatcher</string>
+ <string>com.adobe.cairngorm.commands.SequenceCommand</string>
+ <string>com.adobe.cairngorm.CairngormMessageCodes</string>
+ <string>com.adobe.cairngorm.view.ViewHelper</string>
+ <string>com.adobe.cairngorm.view.ViewLocator</string>
+ <string>com.adobe.cairngorm.business.AbstractServices</string>
+ <string>com.adobe.cairngorm.business.RemoteObjects</string>
+ <string>com.adobe.cairngorm.business.HTTPServices</string>
+ <string>com.adobe.cairngorm.business.WebServices</string>
+ <string>com.adobe.cairngorm.business.ServiceLocator</string>
+ <string>com.adobe.cairngorm.CairngormError</string>
+ </classes>
+ <keepXmlFlag>false</keepXmlFlag>
+ <strictFlag>false</strictFlag>
+ <additionalArguments>
+ <string></string>
+ </additionalArguments>
+ <templatesPath>F:\Program Files\Adobe\Flex Builder 3
Plug-in\sdks\2.0.1\asdoc\templates</templatesPath>
+ <generateHelp>true</generateHelp>
+ <helpBaseName>F:\java\EclipseShared\asdoc\update</helpBaseName>
+ </localASDocParams>
+</com.farata.flex2doc.models.Flex2DocSettingsModel>
=======================================
--- /dev/null
+++ /trunk/code/.flexLibProperties Thu Feb 18 14:33:27 2010
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<flexLibProperties includeAllClasses="false" version="1">
+ <includeClasses>
+ <classEntry path="com.adobe.ac.Observe"/>
+ <classEntry path="com.adobe.ac.ObserveValue"/>
+ <classEntry path="com.adobe.ac.Observer"/>
+ <classEntry path="com.adobe.ac.SmartObserve"/>
+ <classEntry path="com.adobe.cairngorm.CairngormError"/>
+ <classEntry path="com.adobe.cairngorm.CairngormMessageCodes"/>
+ <classEntry path="com.adobe.cairngorm.business.AbstractServices"/>
+ <classEntry path="com.adobe.cairngorm.business.HTTPServices"/>
+ <classEntry path="com.adobe.cairngorm.business.IServiceLocator"/>
+ <classEntry path="com.adobe.cairngorm.business.IServices"/>
+ <classEntry path="com.adobe.cairngorm.business.RemoteObjects"/>
+ <classEntry path="com.adobe.cairngorm.business.Responder"/>
+ <classEntry path="com.adobe.cairngorm.business.ServiceLocator"/>
+ <classEntry path="com.adobe.cairngorm.business.WebServices"/>
+ <classEntry path="com.adobe.cairngorm.commands.Command"/>
+ <classEntry path="com.adobe.cairngorm.commands.ICommand"/>
+ <classEntry path="com.adobe.cairngorm.commands.SequenceCommand"/>
+ <classEntry path="com.adobe.cairngorm.control.CairngormEvent"/>
+ <classEntry
path="com.adobe.cairngorm.control.CairngormEventDispatcher"/>
+ <classEntry path="com.adobe.cairngorm.control.FrontController"/>
+ <classEntry path="com.adobe.cairngorm.model.IModelLocator"/>
+ <classEntry path="com.adobe.cairngorm.model.ModelLocator"/>
+ <classEntry path="com.adobe.cairngorm.vo.IValueObject"/>
+ <classEntry path="com.adobe.cairngorm.vo.ValueObject"/>
+ <classEntry path="com.universalmind.cairngorm.business.Delegate"/>
+ <classEntry
path="com.universalmind.cairngorm.business.ServiceLocator"/>
+ <classEntry path="com.universalmind.cairngorm.commands.Command"/>
+ <classEntry path="com.universalmind.cairngorm.control.BaseController"/>
+ <classEntry
path="com.universalmind.cairngorm.control.FrontController"/>
+ <classEntry
path="com.universalmind.cairngorm.control.ModuleController"/>
+ <classEntry
path="com.universalmind.cairngorm.events.AnnounceFaultEvent"/>
+ <classEntry path="com.universalmind.cairngorm.events.Callbacks"/>
+ <classEntry path="com.universalmind.cairngorm.events.IUMEvent"/>
+ <classEntry path="com.universalmind.cairngorm.events.UMEvent"/>
+ <classEntry
path="com.universalmind.cairngorm.events.generator.EventGenerator"/>
+ <classEntry
path="com.universalmind.cairngorm.events.generator.EventUtils"/>
+ <classEntry
path="com.universalmind.cairngorm.events.generator.IEventGenerator"/>
+ <classEntry path="com.universalmind.cairngorm.vo.ConnectionVO"/>
+ <classEntry path="com.universalmind.cairngorm.vo.IValueObject"/>
+ </includeClasses>
+ <includeResources>
+ <resourceEntry destPath="locale/en_US/CairngormMessages.properties"
sourcePath="locale/en_US/CairngormMessages.properties"/>
+ <resourceEntry destPath="cairngorm-manifest.xml"
sourcePath="cairngorm-manifest.xml"/>
+ </includeResources>
+ <namespaceManifests>
+ <namespaceManifestEntry manifest="cairngorm-manifest.xml"
namespace="http://www.adobe.com/2006/cairngorm"/>
+ </namespaceManifests>
+</flexLibProperties>
=======================================
--- /dev/null
+++ /trunk/code/.project Thu Feb 18 14:33:27 2010
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>CairngormExtensions</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.adobe.flexbuilder.project.flexbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.adobe.flexbuilder.project.flexlibnature</nature>
+ <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
+ </natures>
+</projectDescription>
=======================================
--- /dev/null
+++ /trunk/code/.settings/com.adobe.flexbuilder.project.prefs Thu Feb 18
14:33:27 2010
@@ -0,0 +1,3 @@
+#Tue Nov 03 16:12:30 CST 2009
+eclipse.preferences.version=1
+upgradeSDK/fb253292=
=======================================
--- /dev/null
+++ /trunk/code/.settings/org.eclipse.core.resources.prefs Thu Feb 18
14:33:27 2010
@@ -0,0 +1,3 @@
+#Mon Nov 12 16:50:04 CST 2007
+eclipse.preferences.version=1
+encoding/<project>=utf-8
=======================================
--- /dev/null
+++ /trunk/code/flex2ant-master.xml Thu Feb 18 14:33:27 2010
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="no"?><FlexMetadata><actionScriptProperties
mainApplicationPath="UM_Cairngorm.as" version="3">
+ <compiler additionalCompilerArguments="-source-path+=locale/{locale}
-locale en_US -include-resource-bundles CairngormMessages
-allow-source-path-overlap=true" copyDependentFiles="false"
enableModuleDebug="true" generateAccessible="false"
htmlExpressInstall="true" htmlGenerate="false"
htmlHistoryManagement="false" htmlPlayerVersion="9.0.28"
htmlPlayerVersionCheck="true" outputFolderPath="bin" sourceFolderPath="src"
strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
+ <compilerSourcePath/>
+ <libraryPath defaultLinkType="1">
+ <libraryPathEntry kind="4" path=""/>
+ </libraryPath>
+ <sourceAttachmentPath/>
+ </compiler>
+ <applications>
+ <application path="UM_Cairngorm.as"/>
+ </applications>
+ <modules/>
+ <buildCSSFiles/>
+</actionScriptProperties>
+<flexLibProperties version="1">
+ <includeClasses>
+ <classEntry path="com.adobe.cairngorm.CairngormError"/>
+ <classEntry path="com.adobe.cairngorm.CairngormMessageCodes"/>
+ <classEntry path="com.adobe.cairngorm.business.AbstractServices"/>
+ <classEntry path="com.adobe.cairngorm.business.HTTPServices"/>
+ <classEntry path="com.adobe.cairngorm.business.IServiceLocator"/>
+ <classEntry path="com.adobe.cairngorm.business.IServices"/>
+ <classEntry path="com.adobe.cairngorm.business.RemoteObjects"/>
+ <classEntry path="com.adobe.cairngorm.business.Responder"/>
+ <classEntry path="com.adobe.cairngorm.business.ServiceLocator"/>
+ <classEntry path="com.adobe.cairngorm.business.WebServices"/>
+ <classEntry path="com.adobe.cairngorm.commands.Command"/>
+ <classEntry path="com.adobe.cairngorm.commands.ICommand"/>
+ <classEntry path="com.adobe.cairngorm.commands.SequenceCommand"/>
+ <classEntry path="com.adobe.cairngorm.control.CairngormEvent"/>
+ <classEntry
path="com.adobe.cairngorm.control.CairngormEventDispatcher"/>
+ <classEntry path="com.adobe.cairngorm.control.FrontController"/>
+ <classEntry path="com.adobe.cairngorm.model.IModelLocator"/>
+ <classEntry path="com.adobe.cairngorm.model.ModelLocator"/>
+ <classEntry path="com.adobe.cairngorm.vo.IValueObject"/>
+ <classEntry path="com.adobe.cairngorm.vo.ValueObject"/>
+
+ <classEntry path="com.adobe.ac.Observe"/>
+ <classEntry path="com.adobe.ac.Observer"/>
+ <classEntry path="com.adobe.ac.ObserveValue"/>
+ <classEntry path="com.adobe.ac.SmartObserve"/>
+
+ <classEntry path="com.universalmind.cairngorm.business.Delegate"/>
+ <classEntry
path="com.universalmind.cairngorm.business.ServiceLocator"/>
+ <classEntry path="com.universalmind.cairngorm.commands.Command"/>
+ <classEntry path="com.universalmind.cairngorm.control.BaseController"/>
+ <classEntry
path="com.universalmind.cairngorm.control.FrontController"/>
+ <classEntry
path="com.universalmind.cairngorm.control.ModuleController"/>
+ <classEntry
path="com.universalmind.cairngorm.events.AnnounceFaultEvent"/>
+ <classEntry path="com.universalmind.cairngorm.events.Callbacks"/>
+ <classEntry path="com.universalmind.cairngorm.events.IUMEvent"/>
+ <classEntry path="com.universalmind.cairngorm.events.UMEvent"/>
+ <classEntry
path="com.universalmind.cairngorm.events.generator.EventGenerator"/>
+ <classEntry
path="com.universalmind.cairngorm.events.generator.IEventGenerator"/>
+ <classEntry path="com.universalmind.cairngorm.vo.IValueObject"/>
+ </includeClasses>
+ <includeResources>
+ <resourceEntry destPath="locale/en_US/CairngormMessages.properties"
sourcePath="locale/en_US/CairngormMessages.properties"/>
+ <resourceEntry destPath="cairngorm-manifest.xml"
sourcePath="cairngorm-manifest.xml"/>
+ </includeResources>
+ <namespaceManifests>
+ <namespaceManifestEntry manifest="cairngorm-manifest.xml"
namespace="http://www.adobe.com/2006/cairngorm"/>
+ </namespaceManifests>
+</flexLibProperties>
+</FlexMetadata>
=======================================
--- /dev/null
+++ /trunk/code/src/cairngorm-manifest.xml Thu Feb 18 14:33:27 2010
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<componentPackage>
+
+ <component id="FrontController"
class="com.universalmind.cairngorm.control.FrontController" />
+ <component id="ServiceLocator"
class="com.adobe.cairngorm.business.ServiceLocator"/>
+ <component id="EventGenerator"
class="com.universalmind.cairngorm.events.generator.EventGenerator" />
+ <component id="SmartObserve" class="com.adobe.ac.SmartObserve" />
+
+</componentPackage>
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/ac/Observe.as Thu Feb 18 14:33:27 2010
@@ -0,0 +1,41 @@
+package com.adobe.ac
+{
+ public class Observe extends Observer
+ {
+ private var _handler : Function;
+ private var _source : Object;
+
+ override public function get handler() : Function
+ {
+ return _handler;
+ }
+
+ public function set handler( value : Function ) : void
+ {
+ _handler = value;
+ if( value != null )
+ {
+ isHandlerInitialized = true;
+ if( isHandlerInitialized && isSourceInitialized )
+ {
+ callHandler();
+ }
+ }
+ }
+
+ override public function get source() : Object
+ {
+ return _source;
+ }
+
+ public function set source( value : Object ) : void
+ {
+ _source = value;
+ isSourceInitialized = true;
+ if( isHandlerInitialized && isSourceInitialized )
+ {
+ callHandler();
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/ac/ObserveValue.as Thu Feb 18 14:33:27 2010
@@ -0,0 +1,72 @@
+package com.adobe.ac
+{
+ public class ObserveValue extends Observer
+ {
+ private var isValueInitialized : Boolean = false;
+ private var _handler : Function;
+ private var _source : Object;
+ private var _value : Object;
+
+ override public function get handler() : Function
+ {
+ return _handler;
+ }
+
+ public function set handler( value : Function ) : void
+ {
+ _handler = value;
+ if( value != null )
+ {
+ isHandlerInitialized = true;
+ if( isHandlerInitialized && isSourceInitialized && isValueInitialized )
+ {
+ callHandler();
+ }
+ }
+ }
+
+ override public function get source() : Object
+ {
+ return _source;
+ }
+
+ public function set source( value : Object ) : void
+ {
+ _source = value;
+ isSourceInitialized = true;
+ if( isHandlerInitialized && isSourceInitialized && isValueInitialized )
+ {
+ callHandler();
+ }
+ }
+
+ public function get value() : Object
+ {
+ return _value;
+ }
+
+ public function set value( _value : Object ) : void
+ {
+ this._value = _value;
+ isValueInitialized = true;
+ if( isHandlerInitialized && isSourceInitialized && isValueInitialized )
+ {
+ callHandler();
+ }
+ }
+
+ override protected function callHandler() : void
+ {
+ if( source != value ) return;
+
+ try
+ {
+ handler.call();
+ }
+ catch( e : Error )
+ {
+ delay( e );
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/ac/Observer.as Thu Feb 18 14:33:27 2010
@@ -0,0 +1,57 @@
+package com.adobe.ac
+{
+ import mx.core.Application;
+ import mx.core.UIComponent;
+
+ public class Observer
+ {
+ protected var isHandlerInitialized : Boolean = false;
+ protected var isSourceInitialized : Boolean = false;
+
+ public function get handler() : Function
+ {
+ return null;
+ }
+
+ public function get source() : Object
+ {
+ return null;
+ }
+
+ public function execute( method : Function, ...params : Array ) : Object
+ {
+ var returnValue : Object;
+ try
+ {
+ returnValue = method.apply( null, params );
+ }
+ catch( e : Error )
+ {
+ delay( e );
+ }
+ return returnValue;
+ }
+
+ protected function callHandler() : void
+ {
+ try
+ {
+ handler(source );
+ }
+ catch( e : Error )
+ {
+ delay( e );
+ }
+ }
+
+ protected function delay( e : Error ) : void
+ {
+ UIComponent( Application.application ).callLater( throwException, [ e ]
);
+ }
+
+ private function throwException( e : Error ) : void
+ {
+ throw e;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/ac/SmartObserve.as Thu Feb 18 14:33:27 2010
@@ -0,0 +1,39 @@
+package com.adobe.ac
+{
+ import mx.core.IMXMLObject;
+
+ public class SmartObserve extends Observer implements IMXMLObject
+ {
+ public var id : String = "";
+
+ override public function get handler() : Function { return _handler; }
+ public function set handler( value : Function ) : void {
+ _handler = value;
+ invoke();
+ }
+
+ override public function get source() : Object { return _source; }
+ public function set source( value : Object ) : void {
+ _source = value;
+ invoke();
+ }
+
+ public function initialized(document:Object, id:String):void {
+ this._initialized = true;
+ this.id = id;
+
+ invoke();
+ }
+
+ private function invoke():void {
+ if (_initialized && _handler && _source) {
+ callHandler();
+ }
+ }
+
+ private var _handler : Function = null;
+ private var _source : Object = null;
+ private var _initialized : Boolean = false;
+
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/CairngormError.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,66 @@
+/*
+
+Copyright (c) 2007. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm
+{
+ import mx.resources.IResourceManager;
+ import mx.resources.ResourceBundle;
+ import mx.resources.ResourceManager;
+ import mx.utils.StringUtil;
+
+ /**
+ * Error class thrown when a Cairngorm error occurs.
+ * Used to substitute data in error messages.
+ */
+ public class CairngormError extends Error
+ {
+ [ResourceBundle("CairngormMessages")]
+ private static var rb : ResourceBundle;
+
+ public function CairngormError( errorCode : String, ... rest )
+ {
+ super( formatMessage( errorCode, rest.toString() ) );
+ }
+
+ private function formatMessage( errorCode : String, ... rest ) : String {
+ var rMngr : IResourceManager = ResourceManager.getInstance();
+ var bndlText : String =
rMngr.getString(rb.bundleName,errorCode);
+ var message : String = StringUtil.substitute(bndlText,
rest );
+
+ return StringUtil.substitute( "{0}: {1}", errorCode, message);
+ }
+
+ protected function get resourceBundle() : ResourceBundle
+ {
+ return rb;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/CairngormMessageCodes.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,65 @@
+/*
+
+Copyright (c) 2007. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm
+{
+ /**
+ * Stores Cairngorm message codes.
+ *
+ * <p>All messages/error codes must match the regular expression:
+ *
+ * C\d{4}[EWI]
+ *
+ * 1. The application prefix e.g. 'C'.
+ *
+ * 2. A four-digit error code that must be unique.
+ *
+ * 3. A single character severity indicator
+ * (E: error, W: warning, I: informational).</p>
+ */
+ public class CairngormMessageCodes
+ {
+ public static const SINGLETON_EXCEPTION : String = "C0001E";
+ public static const SERVICE_NOT_FOUND : String = "C0002E";
+ public static const COMMAND_ALREADY_REGISTERED : String = "C0003E";
+ public static const COMMAND_NOT_FOUND : String = "C0004E";
+ public static const VIEW_ALREADY_REGISTERED : String = "C0005E";
+ public static const VIEW_NOT_FOUND : String = "C0006E";
+ public static const REMOTE_OBJECT_NOT_FOUND : String = "C0007E";
+ public static const HTTP_SERVICE_NOT_FOUND : String = "C0008E";
+ public static const WEB_SERVICE_NOT_FOUND : String = "C0009E";
+ public static const CONSUMER_NOT_FOUND : String = "C0010E";
+ public static const PRODUCER_NOT_FOUND : String = "C0012E";
+ public static const DATA_SERVICE_NOT_FOUND : String = "C0013E";
+ public static const ABSTRACT_METHOD_CALLED : String = "C0014E";
+ public static const COMMAND_NOT_REGISTERED : String = "C0015E";
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/AbstractServices.as Thu
Feb 18 14:33:27 2010
@@ -0,0 +1,104 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm.business
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+
+ import flash.utils.describeType;
+
+ /**
+ * Used to manage all services defined on the IServiceLocator instance.
+ */
+ public class AbstractServices implements IServices
+ {
+ /**
+ * Register the services.
+ * @param serviceLocator the IServiceLocator isntance.
+ */
+ public function register( serviceLocator : IServiceLocator ) : void
+ {
+ throw new CairngormError(
CairngormMessageCodes.ABSTRACT_METHOD_CALLED, "register" );
+ }
+
+ /**
+ * Return the service with the given name.
+ * @param name the name of the service.
+ * @return the service.
+ */
+ public function getService( name : String ) : Object
+ {
+ throw new CairngormError(
CairngormMessageCodes.ABSTRACT_METHOD_CALLED, "getService" );
+ }
+
+ /**
+ * Set the credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public function setCredentials( username : String, password : String
) : void
+ {
+ throw new CairngormError(
CairngormMessageCodes.ABSTRACT_METHOD_CALLED, "setCredentials" );
+ }
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public function setRemoteCredentials( username : String, password :
String ) : void
+ {
+ throw new CairngormError(
CairngormMessageCodes.ABSTRACT_METHOD_CALLED, "setRemoteCredentials" );
+ }
+
+ /**
+ * Log the user out of all registered services.
+ */
+ public function logout() : void
+ {
+ throw new CairngormError(
CairngormMessageCodes.ABSTRACT_METHOD_CALLED, "logout" );
+ }
+
+ /**
+ * Return all the accessors on this object.
+ * @param serviceLocator the IServiceLocator instance.
+ * @return this object's accessors.
+ */
+ protected function getAccessors( serviceLocator : IServiceLocator
) : XMLList
+ {
+ var description : XML = describeType( serviceLocator );
+ var accessors : XMLList = description.accessor.( @access
== "readwrite" ).@name;
+
+ return accessors;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/HTTPServices.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,130 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm.business
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+
+ import flash.utils.Dictionary;
+
+ import mx.rpc.http.HTTPService;
+
+ /**
+ * Used to manage all HTTPService's defined on the IServiceLocator
instance.
+ */
+ internal class HTTPServices extends AbstractServices
+ {
+ private var services : Dictionary = new Dictionary();
+
+ /**
+ * Register the services.
+ * @param serviceLocator the IServiceLocator instance.
+ */
+ public override function register( serviceLocator : IServiceLocator
) : void
+ {
+ var accessors : XMLList = getAccessors( serviceLocator );
+
+ for ( var i : uint = 0; i < accessors.length(); i++ )
+ {
+ var name : String = accessors[ i ];
+ var obj : Object = serviceLocator[ name ];
+
+ if ( obj is HTTPService )
+ {
+ services[ name ] = obj;
+ }
+ }
+ }
+
+ /**
+ * Return the service with the given name.
+ * @param name the name of the service.
+ * @return the service.
+ */
+ public override function getService( name : String ) : Object
+ {
+ var service : HTTPService = services[ name ];
+
+ if ( service == null )
+ {
+ throw new CairngormError(
CairngormMessageCodes.HTTP_SERVICE_NOT_FOUND, name );
+ }
+
+ return service;
+ }
+
+ /**
+ * Set the credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public override function setCredentials(
+ username : String, password : String ) : void
+ {
+ for ( var name : String in services )
+ {
+ var service : HTTPService = services[ name ];
+
+ service.logout();
+ service.setCredentials( username, password );
+ }
+ }
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public override function setRemoteCredentials( username : String,
password : String ) : void
+ {
+ for ( var name : String in services )
+ {
+ var service : HTTPService = services[ name ];
+
+ service.setRemoteCredentials( username, password );
+ }
+ }
+
+ /**
+ * Log the user out of all registered services.
+ */
+ public override function logout() : void
+ {
+ for ( var name : String in services )
+ {
+ var service : HTTPService = services[ name ];
+
+ service.logout();
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/IServiceLocator.as Thu Feb
18 14:33:27 2010
@@ -0,0 +1,89 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.business
+{
+ import mx.rpc.http.HTTPService;
+ import mx.rpc.remoting.RemoteObject;
+ import mx.rpc.soap.WebService;
+
+ /**
+ * IServiceLocator defines an interface for service locator. Its
intention is
+ * to support unit testing.
+ */
+ public interface IServiceLocator
+ {
+
+
+ /**
+ * Return the HTTPService for the given service id.
+ * @param name the name of the HTTPService.
+ * @return the RemoteObject.
+ */
+ function getHTTPService( name : String ) : HTTPService;
+
+ /**
+ * Return the RemoteObject for the given service id.
+ * @param name the name of the RemoteObject.
+ * @return the RemoteObject.
+ */
+ function getRemoteObject( name : String ) : RemoteObject;
+
+ /**
+ * Return the WebService for the given service id.
+ * @param name the name of the WebService.
+ * @return the RemoteObject.
+ */
+ function getWebService( name : String ) : WebService;
+
+ /**
+ * Set the credentials for all registered services. Note that services
+ * that use a proxy or a third-party adapter to a remote endpoint will
+ * need to setRemoteCredentials instead.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ function setCredentials( username : String, password : String ) :
void;
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ function setRemoteCredentials( username : String, password : String
) : void
+
+ /**
+ * Logs the user out of all registered services.
+ */
+ function logout() : void;
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/IServices.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,40 @@
+package com.adobe.cairngorm.business
+{
+ /**
+ * IServices defines an interface for managing services on an
IServiceLocator.
+ */
+ public interface IServices
+ {
+ /**
+ * Register the services.
+ * @param serviceLocator the IServiceLocator instance.
+ */
+ function register( serviceLocator : IServiceLocator ) : void;
+
+ /**
+ * Return the service with the given name.
+ * @param name the name of the service.
+ * @return the service.
+ */
+ function getService( name : String ) : Object;
+
+ /**
+ * Set the credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ function setCredentials( username : String, password : String ) :
void;
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ function setRemoteCredentials( username : String, password : String
) : void;
+
+ /**
+ * Log the user out of all registered services.
+ */
+ function logout() : void;
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/RemoteObjects.as Thu Feb
18 14:33:27 2010
@@ -0,0 +1,130 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm.business
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+
+ import flash.utils.Dictionary;
+
+ import mx.rpc.remoting.RemoteObject;
+
+ /**
+ * Used to manage all RemoteObject's defined on the IServiceLocator
instance.
+ */
+ internal class RemoteObjects extends AbstractServices
+ {
+ private var services : Dictionary = new Dictionary();
+
+ /**
+ * Register the services.
+ * @param serviceLocator the IServiceLocator instance.
+ */
+ public override function register( serviceLocator : IServiceLocator
) : void
+ {
+ var accessors : XMLList = getAccessors( serviceLocator );
+
+ for ( var i : uint = 0; i < accessors.length(); i++ )
+ {
+ var name : String = accessors[ i ];
+ var obj : Object = serviceLocator[ name ];
+
+ if ( obj is RemoteObject )
+ {
+ services[ name ] = obj;
+ }
+ }
+ }
+
+ /**
+ * Return the service with the given name.
+ * @param name the name of the service.
+ * @return the service.
+ */
+ public override function getService( name : String ) : Object
+ {
+ var service : RemoteObject = services[ name ];
+
+ if ( service == null )
+ {
+ throw new CairngormError(
+ CairngormMessageCodes.REMOTE_OBJECT_NOT_FOUND, name );
+ }
+
+ return service;
+ }
+
+ /**
+ * Set the credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public override function setCredentials( username : String,
password : String ) : void
+ {
+ for ( var name : String in services )
+ {
+ var service : RemoteObject = services[ name ];
+
+ service.logout();
+ service.setCredentials( username, password );
+ }
+ }
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public override function setRemoteCredentials( username : String,
password : String ) : void
+ {
+ for ( var name : String in services )
+ {
+ var service : RemoteObject = services[ name ];
+
+ service.setRemoteCredentials( username, password );
+ }
+ }
+
+ /**
+ * Log the user out of all registered services.
+ */
+ public override function logout() : void
+ {
+ for ( var name : String in services )
+ {
+ var service : RemoteObject = services[ name ];
+
+ service.logout();
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/Responder.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,101 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.business
+{
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1, replaced by
mx.rpc.IResponder</strong></p>
+ *
+ * The Responder interface is implemented by classes that wish to handle
+ * data returned as the result of a service-call to the server.
+ *
+ * <p>Typically, a server-side call will be made using a service
+ * that is defined on the ServiceLocator. These services will either be
+ * remote calls onto Java Objects (RemoteObject), Web Service
invocations
+ * (WebService) or XML over HTTP/HTTPS (HTTPService) service calls.</p>
+ *
+ * <p>The results from these server calls will be handled by an object
that has
+ * been passed to the ServiceLocator as the designated "responder" (the
+ * class willing to handle the response).</p>
+ *
+ * <p>Typically in the Cairngorm
+ * architecture, the Responder interface is implemented by a concrete
+ * implementation of an ICommand class that will use a BusinessDelegate
+ * class to handle invocation of server-side business logic.</p>
+ *
+ * @see mx.rpc.IResponder
+ * @see com.adobe.cairngorm.commands.ICommand
+ */
+ public interface Responder
+ {
+ /**
+ * The onResult method interface is used to mark the method on a
+ * concrete Responder that will handle the results from a successful
+ * call to a server-side service. The actual data returned will be
+ * held in the event.
+ *
+ * @param event An object containing the data passed back from the
+ * service call, it is recommended that this be immediately narrowed
+ * within the concrete responder by using an appropriate cast. For
+ * instance, if you invoke a Java method that returns an AccountVO
+ * value object, cast event.result to an AccountVO as follows:
+ * <p>
+ * <code> var customerAccount:AccountVO = AccountVO( event.result
);</code>
+ * </p>
+ * <p>
+ * It is considered good practice when building applications with the
+ * Cairngorm framework, to indicate the return types from the server
+ * by appropriate casting.
+ * </p>
+ *
+ * <p>
+ * Java Developers should take care not to use
+ * the Java casting notation - a common mistake for RIA developers
+ * migrating from J2EE development.
+ * </p>
+ */
+ [Deprecated(replacement="mx.rpc.IResponder.fault")]
+ function onResult( event : * = null ) : void;
+
+ /**
+ * The onFault method interface is used to mark the method on a
+ * concrete Responder that will handle the information from a failed
+ * call to a server-side service. The actual data returned will be
+ * held in the event.
+ *
+ * @param event An object containing the data passed back from the
+ * service call
+ */
+ [Deprecated(replacement="mx.rpc.IResponder.result")]
+ function onFault( event : * = null ) : void;
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/ServiceLocator.as Thu Feb
18 14:33:27 2010
@@ -0,0 +1,232 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.business
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+
+ import mx.rpc.AbstractInvoker;
+ import mx.rpc.AbstractService;
+ import mx.rpc.http.HTTPService;
+ import mx.rpc.remoting.RemoteObject;
+ import mx.rpc.soap.WebService;
+
+ /**
+ * The ServiceLocator allows service to be located and security
+ * credentials to be managed.
+ *
+ * Although credentials are set against a service they apply to the
channel
+ * i.e. the set of services belonging to the channel share the same
+ * credentials.
+ *
+ * You must always make sure you call logout at the end of the user's
+ * session.
+ */
+ public class ServiceLocator implements IServiceLocator
+ {
+ protected static var _instance : ServiceLocator;
+
+ private var _httpServices : HTTPServices;
+ private var _remoteObjects : RemoteObjects;
+ private var _webServices : WebServices;
+
+ /**
+ * Return the ServiceLocator _instance.
+ * @return the _instance.
+ */
+ public static function getInstance() : ServiceLocator
+ {
+ if ( _instance == null )
+ {
+ _instance = new ServiceLocator();
+ }
+
+ return _instance;
+ }
+
+ // Constructor should be private but current AS3.0 does not allow it
+ public function ServiceLocator()
+ {
+ if ( _instance != null )
+ {
+ throw new CairngormError(
CairngormMessageCodes.SINGLETON_EXCEPTION, "ServiceLocator" );
+ }
+
+ _instance = this;
+ }
+
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1</strong></p>
+ *
+ * Returns the service defined for the id, to allow services to be
looked up
+ * using the ServiceLocator by a canonical name.
+ *
+ * <p>If no service exists for the service name, an Error will be
thrown.</p>
+ * @param The id of the service to be returned. This is the id
defined in the
+ * concrete service locator implementation.
+ */
+ [Deprecated("You should now use one of the strongly typed methods
for returning a service.")]
+ public function getService( serviceId : String ) : AbstractService
+ {
+ return AbstractService( getServiceForId( serviceId ) );
+ }
+
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1</strong></p>
+ *
+ * Returns an AbstractInvoker defined for the id, to allow services
to be looked up
+ * using the ServiceLocator by a canonical name.
+ *
+ * <p>If no service exists for the service name, an Error will be
thrown.</p>
+ * @param The id of the service to be returned. This is the id
defined in the
+ * concrete service locator implementation.
+ */
+ [Deprecated("You should now use one of the strongly typed methods
for returning a service.")]
+ public function getInvokerService( serviceId : String ) :
AbstractInvoker
+ {
+ return AbstractInvoker( getServiceForId( serviceId ) );
+ }
+
+ /**
+ * Return the HTTPService for the given name.
+ * @param name the name of the HTTPService
+ * @return the HTTPService.
+ */
+ public function getHTTPService( name : String ) : HTTPService
+ {
+ return HTTPService( httpServices.getService( name ) );
+ }
+
+ /**
+ * Return the RemoteObject for the given name.
+ * @param name the name of the RemoteObject.
+ * @return the RemoteObject.
+ */
+ public function getRemoteObject( name : String ) : RemoteObject
+ {
+ return RemoteObject( remoteObjects.getService( name ) );
+ }
+
+ /**
+ * Return the WebService for the given name.
+ * @param name the name of the WebService.
+ * @return the WebService.
+ */
+ public function getWebService( name : String ) : WebService
+ {
+ return WebService( webServices.getService( name ) );
+ }
+
+ /**
+ * Set the credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public function setCredentials( username : String, password : String
) : void
+ {
+ httpServices.setCredentials( username, password );
+ remoteObjects.setCredentials( username, password );
+ webServices.setCredentials( username, password );
+ }
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public function setRemoteCredentials( username : String, password :
String ) : void
+ {
+ httpServices.setRemoteCredentials( username, password );
+ remoteObjects.setRemoteCredentials( username, password );
+ webServices.setRemoteCredentials( username, password );
+ }
+
+ /**
+ * Logs the user out of all registered services.
+ */
+ public function logout() : void
+ {
+ httpServices.logout();
+ remoteObjects.logout();
+ webServices.logout();
+ }
+
+ private function get httpServices() : HTTPServices
+ {
+ if ( _httpServices == null )
+ {
+ _httpServices = new HTTPServices();
+ _httpServices.register( this );
+ }
+
+ return _httpServices;
+ }
+
+ private function get remoteObjects() : RemoteObjects
+ {
+ if ( _remoteObjects == null )
+ {
+ _remoteObjects = new RemoteObjects();
+ _remoteObjects.register( this );
+ }
+
+ return _remoteObjects;
+ }
+
+ private function get webServices() : WebServices
+ {
+ if ( _webServices == null )
+ {
+ _webServices = new WebServices();
+ _webServices.register( this );
+ }
+
+ return _webServices;
+ }
+
+ /**
+ * Return the service with the given id.
+ * @param serviceId the id of the service to return.
+ * @return the service.
+ */
+ private function getServiceForId( serviceId : String ) : Object
+ {
+ if ( this[ serviceId ] == null )
+ {
+ throw new CairngormError(
CairngormMessageCodes.SERVICE_NOT_FOUND, serviceId );
+ }
+
+ return this[ serviceId ];
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/business/WebServices.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,135 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm.business
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+
+ import flash.utils.Dictionary;
+
+ import mx.rpc.soap.WebService;
+
+ /**
+ * Used to manage all WebService's defined on the IServiceLocator
instance.
+ */
+ internal class WebServices extends AbstractServices
+ {
+ private var services : Dictionary = new Dictionary();
+
+ /**
+ * Register the services.
+ * @param serviceLocator the IServiceLocator instance.
+ */
+ public override function register( serviceLocator : IServiceLocator
) : void
+ {
+ var accessors : XMLList = getAccessors( serviceLocator );
+
+ for ( var i : uint = 0; i < accessors.length(); i++ )
+ {
+ var name : String = accessors[ i ];
+ var obj : Object = serviceLocator[ name ];
+
+ if ( obj is WebService )
+ {
+ var wService : WebService = WebService( obj );
+ if ((wService.wsdl != "") && (wService.wsdl != null)) {
+ wService.loadWSDL();
+ }
+
+ services[ name ] = obj;
+ }
+ }
+ }
+
+ /**
+ * Return the service with the given name.
+ * @param name the name of the service.
+ * @return the service.
+ */
+ public override function getService( name : String ) : Object
+ {
+ var service : WebService = services[ name ];
+
+ if ( service == null )
+ {
+ throw new CairngormError(
+ CairngormMessageCodes.WEB_SERVICE_NOT_FOUND, name );
+ }
+
+ return service;
+ }
+
+ /**
+ * Set the credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public override function setCredentials( username : String,
password : String ) : void
+ {
+ for ( var name : String in services )
+ {
+ var service : WebService = services[ name ];
+
+ service.logout();
+ service.setCredentials( username, password );
+ }
+ }
+
+ /**
+ * Set the remote credentials for all registered services.
+ * @param username the username to set.
+ * @param password the password to set.
+ */
+ public override function setRemoteCredentials( username : String,
password : String ) : void
+ {
+ for ( var name : String in services )
+ {
+ var service : WebService = services[ name ];
+
+ service.setRemoteCredentials( username, password );
+ }
+ }
+
+ /**
+ * Log the user out of all registered services.
+ */
+ public override function logout() : void
+ {
+ for ( var name : String in services )
+ {
+ var service : WebService = services[ name ];
+
+ service.logout();
+ }
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/commands/Command.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,98 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm.commands
+{
+ import com.adobe.cairngorm.commands.ICommand;
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1, replaced by
com.adobe.cairngorm.commands.ICommand</strong></p>
+ *
+ * The Command interface enforces the contract between the Front
+ * Controller and concrete command classes in your application.
+ *
+ * <p>In a Cairngorm application, the application specific Front
Controller
+ * will listen for events of interest, dispatching control to
appropriate
+ * command classes according to the type of the event broadcast.</p>
+ *
+ * <p>
+ * When an event is broadcasted by the Front Controller, it will
+ * lookup its list of registered commands, to find the command capable
+ * of carrying out the appropriate work in response to the user gesture
+ * that has caused the event.
+ * </p>
+ *
+ * <p>
+ * When the event that a command is registered against is broadcast,
+ * the Front Controller class will invoke the command by calling its
+ * execute() method, which can be considered the entry point to a
+ * command.
+ * </p>
+ *
+ * @see com.adobe.cairngorm.commands.ICommand
+ * @see com.adobe.cairngorm.control.FrontController
+ * @see com.adobe.cairngorm.control.CairngormEventDispatcher
+ */
+ public interface Command extends ICommand
+ {
+ /** Called by the Front Controller to execute the command.
+ *
+ * <p>The single entry point into a command, the
+ * execute() method is called by the Front Controller when a
+ * user-gesture indicates that the user wishes to perform a
+ * task for which a particularconcrete command class has been
+ * provided.</p>
+ *
+ * @param event When the Front Controller receives notification
+ * of a user gesture, the Event that it receives contains both the
+ * type of the event (indicating which command should handle the
+ * work) but also any data associated with the event.
+ *
+ * <p>
+ * For instance, if a "login" event has been broadcasted,
+ * to which the controller has registered the LoginCommand,
+ * the event may also contain some associated data, such as
+ * the number of prior attempts at login have been made
+ * already. In this case, the event.type would be set to
+ * "login" while other properties define in the custom login
+ * event object would contain (by way of example)
+ * an attribute such as attemptedLogins.
+ * </p>
+ *
+ * <p>
+ * By careful use of custom event objects, the same
+ * concrete command class is capable of responding in slightly
+ * different ways to similar user gesture requests.
+ * </p>
+ */
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/commands/ICommand.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,96 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+package com.adobe.cairngorm.commands
+{
+ import com.adobe.cairngorm.control.CairngormEvent;
+
+ /**
+ *
+ * The ICommand interface enforces the contract between the Front
+ * Controller and concrete command classes in your application.
+ *
+ * <p>In a Cairngorm application, the application specific Front
Controller
+ * will listen for events of interest, dispatching control to
appropriate
+ * command classes according to the type of the event broadcast.</p>
+ *
+ * <p>
+ * When an event is broadcasted by the Front Controller, it will
+ * lookup its list of registered commands, to find the command capable
+ * of carrying out the appropriate work in response to the user gesture
+ * that has caused the event.
+ * </p>
+ *
+ * <p>
+ * When the event that an command is registered against is broadcast,
+ * the Front Controller class will invoke the command by calling its
+ * execute() method, which can be considered the entry point to a
+ * command.
+ * </p>
+ *
+ * @see com.adobe.cairngorm.control.FrontController
+ * @see com.adobe.cairngorm.control.CairngormEventDispatcher
+ */
+ public interface ICommand
+ {
+ /** Called by the Front Controller to execute the command.
+ *
+ * <p>The single entry point into an ICommand, the
+ * execute() method is called by the Front Controller when a
+ * user-gesture indicates that the user wishes to perform a
+ * task for which a particularconcrete command class has been
+ * provided.</p>
+ *
+ * @param event When the Front Controller receives notification
+ * of a user gesture, the Event that it receives contains both the
+ * type of the event (indicating which command should handle the
+ * work) but also any data associated with the event.
+ *
+ * <p>
+ * For instance, if a "login" event has been broadcasted,
+ * to which the controller has registered the LoginCommand,
+ * the event may also contain some associated data, such as
+ * the number of prior attempts at login have been made
+ * already. In this case, the event.type would be set to
+ * "login" while other properties define in the custom login
+ * event object would contain (by way of example)
+ * an attribute such as attemptedLogins.
+ * </p>
+ *
+ * <p>
+ * By careful use of custom event objects, the same
+ * concrete command class is capable of responding in slightly
+ * different ways to similar user gesture requests.
+ * </p>
+ */
+ function execute( event : CairngormEvent ) : void;
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/commands/SequenceCommand.as Thu Feb
18 14:33:27 2010
@@ -0,0 +1,137 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.commands
+{
+ import com.adobe.cairngorm.control.CairngormEvent;
+ import com.adobe.cairngorm.control.CairngormEventDispatcher;
+
+ /**
+ * The SequenceCommand is provided as a "psuedo-abstract" (since
ActionScript
+ * has no real concept of abstract classes) base-class that can be
extended when
+ * you wish to chain commands together for a single user-gesture, or
establish
+ * some simple form of decision-based workflow.
+ *
+ * <p>
+ * By extending SequenceCommand, you can specify the event that should
be
+ * broadcast to the controller (causing another command execution
+ * without a further user-gesture) when the current command has
completed
+ * execution.
+ * </p>
+ *
+ * <p>
+ * For a command implementing the Responder interface, you may choose to
+ * sequence a subsequent command on successful completion of the
command,
+ * in the onResult() handler, or on failure of the command in the
onFault()
+ * method.
+ * </p>
+ *
+ * <p>
+ * For commands that do not implement the Responder interface, you can
+ * simply chain commands by causing the sequenced command to be invoked
+ * as the last action in your command's execute() method.
+ * </p>
+ *
+ * <p>
+ * <b>Usage</b>
+ * </p>
+ *
+ * <p>
+ * In the constructor of a concrete SequenceCommand implementation, you
+ * should set nextEvent to the event that is responsible for calling
your
+ * subsequent command.
+ * </p>
+ *
+ * <p>
+ * Alternatively, you can override the implicit nextEvent getter, to
+ * programmatically decide at runtime which event should be broadcast
+ * next.
+ * </p>
+ *
+ * <p>
+ * Invocation of the next command in the sequence is explicitly
controlled by
+ * the developer, by calling the executeNextCommand() method provided
in the
+ * SequenceCommand base-class. This can be called either in the body
of the execute() method
+ * (for synchronous sequencing) or in the body of an onResult() or
onFault()
+ * handler (for asynchronous sequencing, that can also support
conditional
+ * workflow).
+ * </p>
+ *
+ * @see com.adobe.cairngorm.commands.ICommand
+ * @see com.adobe.cairngorm.control.CairngormEventDispatcher
+ */
+ public class SequenceCommand implements ICommand
+ {
+ /**
+ * The next event in the sequence.
+ */
+ public var nextEvent : CairngormEvent;
+
+ /**
+ * Constructor, with optional nextEvent.
+ */
+ public function SequenceCommand( nextEvent : CairngormEvent = null
) : void
+ {
+ super();
+ this.nextEvent = nextEvent;
+ }
+
+ /**
+ * Abstract implementation of the execute() method.
+ *
+ * <p>ActionScript does not explicity support abstract methods and
abstract classes, so this concrete
+ * implementation of the interface method must be overridden by the
developer.</p>
+ *
+ */
+ public function execute( event : CairngormEvent ) : void
+ {
+ // abstract, so this method must be provided. Rather than
convolute additional framework classes to enforce
+ // abstract classes, we instead delegate responsibility to the
developer of a SequenceCommand to ensure that
+ // they provide a concrete implementation of this method.
+ }
+
+ /**
+ * Call to execute the next command in the sequence.
+ *
+ * <p>Called explicitly by the developer within a concrete
SequenceCommand implementation, this method causes the
+ * event registered with nextEvent to be broadcast, for the next
command in the sequence to be called
+ * without further user-gesture.</p>
+ *
+ */
+ public function executeNextCommand() : void
+ {
+ var isSequenceCommand : Boolean = ( nextEvent != null );
+ if( isSequenceCommand )
+ CairngormEventDispatcher.getInstance().dispatchEvent(
nextEvent );
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/control/CairngormEvent.as Thu Feb
18 14:33:27 2010
@@ -0,0 +1,80 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.control
+{
+ import flash.events.Event;
+
+ /**
+ * The CairngormEvent class is used to differentiate Cairngorm events
+ * from events raised by the underlying Flex framework (or
+ * similar). It is mandatory for Cairngorm event dispatching.
+ *
+ * <p>For more information on how event dispatching works in Cairngorm,
+ * please check with CairngormEventDispatcher.</p>
+ * <p>
+ * Events are typically broadcast as the result of a user gesture
occuring
+ * in the application, such as a button click, a menu selection, a
double
+ * click, a drag and drop operation, etc.
+ * </p>
+ *
+ * @see com.adobe.cairngorm.control.CairngormEventDispatcher
+ */
+ public class CairngormEvent extends Event
+ {
+ /**
+ * The data property can be used to hold information to be passed
with the event
+ * in cases where the developer does not want to extend the
CairngormEvent class.
+ * However, it is recommended that specific classes are created for
each type
+ * of event to be dispatched.
+ */
+ public var data : *;
+
+ /**
+ * Constructor, takes the event name (type) and data object
(defaults to null)
+ * and also defaults the standard Flex event properties bubbles and
cancelable
+ * to true and false respectively.
+ */
+ public function CairngormEvent( type : String, bubbles : Boolean =
false, cancelable : Boolean = false )
+ {
+ super( type, bubbles, cancelable );
+ }
+
+ /**
+ * Dispatch this event via the Cairngorm event dispatcher.
+ */
+ public function dispatch() : Boolean
+ {
+ return CairngormEventDispatcher.getInstance().dispatchEvent( this
);
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/control/CairngormEventDispatcher.as
Thu Feb 18 14:33:27 2010
@@ -0,0 +1,132 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.control
+{
+ import flash.events.IEventDispatcher;
+ import flash.events.EventDispatcher;
+
+ /**
+ * The CairngormEventDispatcher class is a singleton class, used by the
application
+ * developer to broadcast events that correspond to user gestures and
requests.
+ *
+ * <p>The singleton implementation of the CairngormEventDispatcher
ensures that one
+ * and only one class can be responsible for broadcasting events that
the
+ * FrontController is subscribed to listen and react to.</p>
+ *
+ * <p>
+ * Since the CairngormEventDispatcher implements singleton access, use
of the
+ * singleton is simple to distribute throughout your application. At
+ * any point in your application, should you capture a user gesture
+ * (such as in a click handler, or a dragComplete handler, etc) then
+ * simply use a code idiom as follows:
+ * </p>
+ *
+ * <pre>
+ * //LoginEvent inherits from com.adobe.cairngorm.control.CairngormEvent
+ * var eventObject : LoginEvent = new LoginEvent();
+ * eventObject.username = username.text;
+ * eventObject.password = username.password;
+ *
+ * CairngormEventDispatcher.getInstance().dispatchEvent( eventObject );
+ * </pre>
+ *
+ * @see com.adobe.cairngorm.control.FrontController
+ * @see com.adobe.cairngorm.control.CairngormEvent
+ * @see flash.events.IEventDispatcher
+ */
+
+ public class CairngormEventDispatcher
+ {
+ private static var instance : CairngormEventDispatcher;
+ private var eventDispatcher : IEventDispatcher;
+
+ /**
+ * Returns the single instance of the dispatcher
+ */
+ public static function getInstance() : CairngormEventDispatcher
+ {
+ if ( instance == null )
+ instance = new CairngormEventDispatcher();
+
+ return instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ public function CairngormEventDispatcher( target:IEventDispatcher =
null )
+ {
+ eventDispatcher = new EventDispatcher( target );
+ }
+
+ /**
+ * Adds an event listener.
+ */
+ public function addEventListener( type:String, listener:Function,
useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean =
false ) : void
+ {
+ eventDispatcher.addEventListener( type, listener, useCapture,
priority, useWeakReference );
+ }
+
+ /**
+ * Removes an event listener.
+ */
+ public function removeEventListener( type:String, listener:Function,
useCapture:Boolean = false ) : void
+ {
+ eventDispatcher.removeEventListener( type, listener, useCapture );
+ }
+
+ /**
+ * Dispatches a cairngorm event.
+ */
+ public function dispatchEvent( event:CairngormEvent ) : Boolean
+ {
+ return eventDispatcher.dispatchEvent( event );
+ }
+
+ /**
+ * Returns whether an event listener exists.
+ */
+ public function hasEventListener( type:String ) : Boolean
+ {
+ return eventDispatcher.hasEventListener( type );
+ }
+
+ /**
+ * Returns whether an event will trigger.
+ */
+ public function willTrigger(type:String) : Boolean
+ {
+ return eventDispatcher.willTrigger( type );
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/control/FrontController.as Thu Feb
18 14:33:27 2010
@@ -0,0 +1,222 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.control
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+ import com.adobe.cairngorm.commands.ICommand;
+
+ import flash.utils.Dictionary;
+
+ /**
+ * A base class for an application specific front controller,
+ * that is able to dispatch control following particular user gestures
to appropriate
+ * command classes.
+ *
+ * <p>
+ * The Front Controller is the centralised request handling class in a
+ * Cairngorm application. Throughout the application architecture are
+ * scattered a number of
CairngormEventDispatcher.getInstance().dispatchEvent( event )
+ * method calls, that signal to the listening controller that a user
gesture
+ * has occured.
+ * </p>
+ *
+ * <p>
+ * The role of the Front Controller is to first register all the
different
+ * events that it is capable of handling against worker classes, called
+ * command classes. On hearing an application event, the Front
Controller
+ * will look up its table of registered events, find the appropriate
+ * command for handling of the event, before dispatching control to the
+ * command by calling its execute() method.
+ * </p>
+ *
+ * <p>
+ * Commands are added to the front controller with a weak reference,
+ * meaning that when the command is garbage collected, the reference in
+ * the controller is also garbage collected.
+ * </p>
+ *
+ * <p>
+ * The Front Controller is a base-class that listen for events
+ * dispatched by CairngormEventDispatcher. In a
+ * Cairngorm application, the developer should create a class that
+ * extends the FrontController, and in the constructor of their
+ * application specific controller, they should make numerous calls to
+ * addCommand() to register all the expected events with application
+ * specific command classes.
+ * </p>
+ *
+ * <p>
+ * Consider a LoginController, that is the main controller for a Login
+ * application that has 2 user gestures - Login and Logout. The
application
+ * will have 2 buttons, "Login" and "Logout" and in the click handler
for
+ * each button, one of the following methods is executed:
+ * </p>
+ *
+ * <pre>
+ * public function doLogin() : void
+ * {
+ * var event : LoginEvent = new LoginEvent( username.text,
password.text );
+ * CairngormEventDispatcher.getInstance.dispatchEvent( event );
+ * }
+ *
+ * public function doLogout() : void
+ * {
+ * var event : LogoutEvent = new LogoutEvent();
+ * CairngormEventDispatcher.getInstance.dispatchEvent( event );
+ * }
+ * </pre>
+ *
+ * <p>
+ * We would create LoginController as follows:
+ * </p>
+ *
+ * <pre>
+ * class LoginController extends
com.adobe.cairngorm.control.FrontController
+ * {
+ * public function LoginController()
+ * {
+ * initialiseCommands();
+ * }
+ *
+ * public function initialiseCommands() : void
+ * {
+ * addCommand( LoginEvent.EVENT_LOGIN, LoginCommand );
+ * addCommand( LogoutEvent.EVENT_LOGOUT, LogoutCommand );
+ * }
+ *
+ * }
+ * </pre>
+ *
+ * <p>
+ * In our concrete implementation of a FrontController,
LoginController, we
+ * register the 2 events that are expected for broadcast - login and
logout -
+ * using the addCommand() method of the parent FrontController class, to
+ * assign a command class to each event.
+ * </p>
+ *
+ * <p>
+ * Adding a new use-case to a Cairngorm application is as simple as
+ * registering the event against a command in the application Front
Controller,
+ * and then creating the concrete command class.
+ * </p>
+ *
+ * <p>
+ * The concrete implementation of the FrontController, LoginController,
+ * should be created once and once only (as we only want a single
controller
+ * in our application architecture). Typically, in our main
application, we
+ * would declare our FrontController child class as a tag, which should
be placed
+ * above any tags which have a dependency on the FrontController
+ * </p>
+ *
+ * <pre>
+ * &lt;mx:Application
xmlns:control="com.domain.project.control.LoginController" ... &gt;
+ *
+ * &lt;control:LoginController id="controller" /&gt;
+ *
+ * ...
+ *
+ * </pre>
+ *
+ * @see com.adobe.cairngorm.commands.ICommand
+ */
+ public class FrontController
+ {
+ /**
+ * Dictionary of event name to command class mappings
+ */
+ protected var commands : Dictionary = new Dictionary();
+
+ /**
+ * Registers a ICommand class with the Front Controller, against an
event name
+ * and listens for events with that name.
+ *
+ * <p>When an event is broadcast that matches commandName,
+ * the ICommand class referred to by commandRef receives control of
the
+ * application, by having its execute() method invoked.</p>
+ *
+ * @param commandName The name of the event that will be broadcast by
the
+ * when a particular user gesture occurs, eg "login"
+ */
+ public function addCommand( commandName : String, commandRef :
Class, useWeakReference : Boolean = true ) : void
+ {
+ if( commands[ commandName ] != null )
+ throw new CairngormError(
CairngormMessageCodes.COMMAND_ALREADY_REGISTERED, commandName );
+
+ commands[ commandName ] = commandRef;
+ CairngormEventDispatcher.getInstance().addEventListener(
commandName, executeCommand, false, 0, useWeakReference );
+ }
+
+ /**
+ * Executes the command
+ */
+ protected function executeCommand( event : CairngormEvent ) : void
+ {
+ var commandToInitialise : Class = getCommand( event.type );
+ var commandToExecute : ICommand = new commandToInitialise();
+
+ commandToExecute.execute( event );
+ }
+
+ /**
+ * Deregisters an ICommand class with the given event name from the
Front Controller
+ *
+ * @param commandName The name of the event that will be broadcast by
the
+ * when a particular user gesture occurs, eg "login"
+ *
+ */
+ public function removeCommand( commandName : String ) : void
+ {
+ if( commands[ commandName ] === null)
+ throw new CairngormError(
CairngormMessageCodes.COMMAND_NOT_REGISTERED, commandName);
+
+ CairngormEventDispatcher.getInstance().removeEventListener(
commandName, executeCommand );
+ commands[ commandName ] = null;
+ delete commands[ commandName ];
+ }
+
+
+ /**
+ * Returns the command class registered with the command name.
+ */
+ protected function getCommand( commandName : String ) : Class
+ {
+ var command : Class = commands[ commandName ];
+
+ if ( command == null )
+ throw new CairngormError(
CairngormMessageCodes.COMMAND_NOT_FOUND, commandName );
+
+ return command;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/model/IModelLocator.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,80 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.model
+{
+ /**
+ * Marker interface used to mark the custom ModelLocator.
+ *
+ * <p>IModelLocator is the marker interface used by Cairngorm
applications
+ * to implement the model in an Model-View-Controller architecture.</p>
+ * <p>The model locator in an application is a singleton that the
application
+ * uses to store the client side model. An example implementation might
be:</p>
+ * <pre>
+ * [Bindable]
+ * public class ShopModelLocator implements IModelLocator
+ * {
+ * private static var instance : ShopModelLocator;
+ *
+ * public function ShopModelLocator()
+ * {
+ * if ( instance != null )
+ * {
+ * throw new CairngormError(
+ *
CairngormMessageCodes.SINGLETON_EXCEPTION, "ShopModelLocator" );
+ * }
+ *
+ * instance = this;
+ * }
+ *
+ * public static function getInstance() : ShopModelLocator
+ * {
+ * if ( instance == null )
+ * instance = new ShopModelLocator();
+ *
+ * return instance;
+ * }
+ *
+ * public var products : ICollectionView;
+ * }
+ * </pre>
+ *
+ * <p>Throughout the rest of the application, the developer can then
access
+ * the products from the model, as follows:</p>
+ * <pre>
+ * var products : ICollectionView =
ShopModelLocator.getInstance().products;
+ * </pre>
+ */
+ public interface IModelLocator
+ {
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/model/ModelLocator.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,82 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.model
+{
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1, replaced by
com.adobe.cairngorm.model.IModelLocator</strong></p>
+ *
+ * Marker interface used to mark the custom ModelLocator.
+ *
+ * <p>ModelLocator is the marker interface used by Cairngorm
applications
+ * to implement the model in an Model-View-Controller architecture.</p>
+ * <p>The model locator in an application is a singleton that the
application
+ * uses to store the client side model. An example implementation might
be:</p>
+ * <pre>
+ * [Bindable]
+ * public class ShopModelLocator implements ModelLocator
+ * {
+ * private static var instance : ShopModelLocator;
+ *
+ * public function ShopModelLocator()
+ * {
+ * if ( instance != null )
+ * {
+ * throw new CairngormError(
+ *
CairngormMessageCodes.SINGLETON_EXCEPTION, "ShopModelLocator" );
+ * }
+ *
+ * instance = this;
+ * }
+ *
+ * public static function getInstance() : ShopModelLocator
+ * {
+ * if ( instance == null )
+ * instance = new ShopModelLocator();
+ *
+ * return instance;
+ * }
+ *
+ * public var products : ICollectionView;
+ * }
+ * </pre>
+ *
+ * <p>Throughout the rest of the application, the developer can then
access
+ * the products from the model, as follows:</p>
+ * <pre>
+ * var products : ICollectionView =
ShopModelLocator.getInstance().products;
+ * </pre>
+ */
+ public interface ModelLocator extends IModelLocator
+ {
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/view/ViewHelper.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,128 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.view
+{
+ import flash.events.Event;
+ import mx.core.IMXMLObject;
+
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1.</strong></p>
+ *
+ * Used to isolate command classes from the implementation details of a
view.
+ *
+ * <p>Model-View-Controller (MVC) best practices specify that command
classes
+ * should interact with the view using the model (see the ModelLocator
class),
+ * but, in some instances, command classes may require to both
interrogate and
+ * update the view directly. Prior to performing any business logic,
the command
+ * class may require to fetch values that have been set on the view;
following
+ * completion of any business logic, the final task may be for a
+ * command class to update the View (user interface) with any results
returned,
+ * or perhaps to switch the View entirely (to a different screen).</p>
+ *
+ * <p>
+ * By encapsulating all the logic necessary for interrogating and
+ * updating a particular View into a single helper class, we remove
+ * the need for the command classes to have any knowledge about the
+ * implementation of the View. The ViewHelper class decouples our
+ * presentation from the control of the application.
+ * </p>
+ *
+ * <p>
+ * A ViewHelper belongs to a particular View in the application; when
+ * a ViewHelper is created, its id is used to register
+ * against a particular View component (such as a particular
+ * tab in a TabNavigator, or a particular screen in a ViewStack). The
+ * developer then uses the ViewLocator to locate the particular
+ * ViewHelper for interrogation or update of a particular View.
+ * </p>
+ *
+ * @see com.adobe.cairngorm.model.ModelLocator
+ * @see com.adobe.cairngorm.view.ViewLocator
+ */
+
+ public class ViewHelper implements IMXMLObject
+ {
+ /**
+ * The view referred to by this view helper
+ */
+ protected var view : Object;
+
+ /**
+ * The id of the view
+ */
+ protected var id : String;
+
+ /**
+ * On initialization, the view is initialized with the
<code>ViewLocator</code>
+ * with the <code>ViewLocator</code>, using its <code>id</code>.
+ * On Event.REMOVED and Event.ADDED events of a view,
+ * the view is registered or unregistered from the
<code>ViewLocator</code>.
+ * <p>The <code>initialized</code> method is called by the Flex
component
+ * framework after a component has been initialized, so long as the
+ * component implements <code>mx.core.IMXMLObject</code>.</p>
+ */
+ public function initialized( document : Object, id : String ) : void
+ {
+ this.view = document;
+ this.id = id;
+
+ view.addEventListener( Event.ADDED, registerView );
+ view.addEventListener( Event.REMOVED, unregisterView );
+ }
+
+ /**
+ * Registers the view from the ViewLocator when added to the display
list.
+ * @see com.adobe.cairngorm.view.ViewLocator
+ */
+ private function registerView( event : Event ) : void
+ {
+ if ( event.target == view )
+ {
+ ViewLocator.getInstance().register( id, this );
+ }
+ }
+
+ /**
+ * Unregisters the view from the ViewLocator when taken off the
display list.
+ * @see com.adobe.cairngorm.view.ViewLocator
+ */
+ private function unregisterView( event : Event ) : void
+ {
+ if( event.target == view )
+ {
+ ViewLocator.getInstance().unregister( id );
+ }
+ }
+ }
+}
+
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/view/ViewLocator.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,199 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.view
+{
+ import com.adobe.cairngorm.CairngormError;
+ import com.adobe.cairngorm.CairngormMessageCodes;
+
+ import flash.utils.Dictionary;
+
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1.</strong></p>
+ *
+ * The ViewLocator is a singleton class, that is used to retreive
ViewHelper
+ * classes that can manipulate (get/set/switch) the user interface of a
+ * Cairngorm RIA.
+ *
+ * <p>Model-View-Controller (MVC) best practices specify that command
classes
+ * should interact with the view using the model (see the ModelLocator
class),
+ * but in some instance, command classes may require the assistance of
+ * ViewHelpers to get/set the user interface associated with the work
they
+ * are designed to perform. ViewHelper classes contain methods that
allow
+ * them to interrogate (get) individual elements of the view, such as
the
+ * values of form fields, and to update the user interface, such as
setting the
+ * data provider on DataGrids or Listcomponents. Additionally, a
command may
+ * choose to toggle the user interface from one view to another - for
instance,
+ * to take the user to a checkout screen.</p>
+ *
+ * <p>
+ * The ViewLocator class is used to allow commands to instantly retrieve
+ * the appropriate ViewHelper. A command need only know the canonical
+ * name of a ViewHelper and the ViewLocator will return an instance of
+ * the appropriate ViewHelper class. In this way, command classes can
+ * manipulate the View irrespective of its implementation.
+ * </p>
+ *
+ * @see com.adobe.cairngorm.model.ModelLocator
+ * @see com.adobe.cairngorm.view.ViewHelper
+ * @see com.adobe.cairngorm.commands.ICommand
+ */
+ public class ViewLocator
+ {
+ private static var viewLocator : ViewLocator;
+ private var viewHelpers : Dictionary;
+
+ /**
+ * Singleton access to the ViewLocator is assured through the static
getInstance()
+ * method, which is used to retrieve the only ViewLocator instance
in a Cairngorm
+ * application.
+ *
+ * <p>Wherever there is a need to retreive the ViewLocator instance,
it is achieved
+ * using the following code:</p>
+ *
+ * <pre>
+ * var viewLocator:ViewLocator = ViewLocator.getInstance();
+ * </pre>
+ */
+ public static function getInstance() : ViewLocator
+ {
+ if ( viewLocator == null )
+ viewLocator = new ViewLocator();
+
+ return viewLocator;
+ }
+
+ /**
+ * The ViewLocator constructor should only be created
+ * through the static singleton getInstance() method. ViewLocator
+ * maintains a hash map of ViewHelpers, keyed on viewName with a
+ * particular view as the value stored in the hash map.
+ */
+ public function ViewLocator()
+ {
+ if ( ViewLocator.viewLocator != null )
+ {
+ throw new CairngormError(
+ CairngormMessageCodes.SINGLETON_EXCEPTION, "ViewLocator" );
+ }
+
+ viewHelpers = new Dictionary();
+ }
+
+ /**
+ * Registers a viewHelper under a canonical viewName.
+ *
+ * <p>In order that the application developer need not know
+ * the implementation of the view, a ViewHelper capable of
manipulating
+ * a given view is registered under a simple canonical name.</p>
+ * <p>
+ * For example, a LoginViewHelper may allow the manipulation of a
+ * Login window, that may start life as a PopUpWindow, but later be
+ * changed to a screen in a ViewStack. By registering the
LoginViewHelper
+ * with the viewName "login", then any code that fetches the
ViewHelper
+ * by it's name "login", and then calls methods on the ViewHelper, is
+ * completely insulated from any changes in the implementation of the
+ * view, and the implementation of the ViewHelper.
+ * </p>
+ * <p>
+ * If a view is already registered with the canonical name, and Error
+ * is thrown.
+ * </p>
+ * @param viewName A simple canonical name for the view that the
ViewHelper
+ * will manipulate, eg "login"
+ * @param viewHelper An instance of a ViewHelper
+ */
+ public function register( viewName : String, viewHelper : ViewHelper
) : void
+ {
+ if ( registrationExistsFor( viewName ) )
+ {
+ throw new CairngormError(
+ CairngormMessageCodes.VIEW_ALREADY_REGISTERED, viewName );
+ }
+
+ viewHelpers[ viewName ] = viewHelper;
+ }
+
+ /**
+ * Unregisters a viewHelper using its canonical name.
+ *
+ * @param viewName The canonical name for the view to be removed
+ */
+ public function unregister( viewName : String ) : void
+ {
+ if ( !registrationExistsFor( viewName ) )
+ {
+ throw new CairngormError(
+ CairngormMessageCodes.VIEW_NOT_FOUND, viewName );
+ }
+
+ delete viewHelpers[ viewName ];
+ }
+
+ /**
+ * Retrieves the ViewHelper instance that has previously been
registered
+ * with viewName.
+ *
+ * @param viewName The name of the view for which we wish to
retrieve a
+ * ViewHelper, eg "login"
+ * @returns The ViewHelper instance that is required to manipulate
the
+ * view registered with viewName
+ */
+ public function getViewHelper( viewName : String ) : ViewHelper
+ {
+ if ( !registrationExistsFor( viewName ) )
+ {
+ throw new CairngormError(
+ CairngormMessageCodes.VIEW_NOT_FOUND, viewName );
+ }
+
+ return viewHelpers[ viewName ];
+ }
+
+ /**
+ * Returns whether a view has been registered with a canonical name.
+ *
+ * <p>If two views are registered with the same canonical name,
+ * the second entry will overwrite the first. This method can be
used to check
+ * whether a view has already been registered with a canonical
name.</p>
+ *
+ * @param The canonical name for the view that the ViewHelper will
check, eg
+ * "login"
+ * @return A Boolean that indicates if a view is already registered
with that
+ * view name
+ */
+ public function registrationExistsFor( viewName : String ) : Boolean
+ {
+ return viewHelpers[ viewName ] != undefined;
+ }
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/vo/IValueObject.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,50 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.vo
+{
+ /**
+ * The IValueObject interface is a marker interface that improves
+ * readability of code by identifying the classes within a Cairngorm
+ * application that are to be used as value objects for passing data
+ * between tiers of an application.
+ *
+ * <p>
+ * Currently, this interface does not require the implementation of any
+ * methods; the developer is free to extend this interface according to
+ * their preferred ValueObject implementation.
+ * </p>
+ */
+ public interface IValueObject
+ {
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/adobe/cairngorm/vo/ValueObject.as Thu Feb 18
14:33:27 2010
@@ -0,0 +1,56 @@
+/*
+
+Copyright (c) 2006. Adobe Systems Incorporated.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice,
+ this list of conditions and the following disclaimer in the
documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of Adobe Systems Incorporated nor the names of its
+ contributors may be used to endorse or promote products derived from
this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+@ignore
+*/
+
+package com.adobe.cairngorm.vo
+{
+ import com.adobe.cairngorm.vo.IValueObject;
+
+ /**
+ * <p><strong>Deprecated as of Cairngorm 2.1, replaced by
com.adobe.cairngorm.vo.IValueObject</strong></p>
+ *
+ * The ValueObject interface is a marker interface that improves
+ * readability of code by identifying the classes within a Cairngorm
+ * application that are to be used as value objects for passing data
+ * between tiers of an application.
+ *
+ * <p>
+ * Currently, this interface does not require the implementation of any
+ * methods; the developer is free to extend this interface according to
+ * their preferred ValueObject implementation.
+ * </p>
+ *
+ * @see com.adobe.cairngorm.vo.IValueObject
+ */
+ public interface ValueObject extends IValueObject
+ {
+ }
+}
=======================================
--- /dev/null
+++ /trunk/code/src/com/universalmind/cairngorm/business/Delegate.as Thu
Feb 18 14:33:27 2010
@@ -0,0 +1,393 @@
+/*
+Copyright (c) 2008, Universal Mind
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the Universal Mind nor the names of its
contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY UNIVERSAL MIND AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Author: Thomas Burleson, Principal Architect
+ Tho...@UniversalMind.com
+ Darron Schall, Principal Architect
+
+@ignore
+*/
+
+package com.universalmind.cairngorm.business
+{
+ import mx.core.mx_internal;
+ import mx.rpc.AsyncToken;
+ import mx.rpc.IResponder;
+ import mx.rpc.events.FaultEvent;
+ import mx.rpc.events.ResultEvent;
+ import mx.rpc.soap.mxml.WebService;
+ import mx.utils.ObjectUtil;
+ import mx.utils.StringUtil;
+
+ /**
+ * A base class used to access remote data services or local storage
mechanisms.
+ * A Delegate subclass is usually used for 1-to-1 mappings to services
and API calls on the remote server
+ *
+ * <p>
+ * While some MVC approaches deprecate the use of Delegates as an
un-necessary layer
+ * and use the Command classes to directly access the
Services[.mxml]-based services,
+ * that bypass is not recommended.
+ *
+ * This base class provides several functional features that reduce
complexities
+ * for subclasses:
+ * a) Implicit getter "service" that will return an internal lookup
of the service with the name specified in the
+ * Delegate constructor
+ * b) getServiceByName() that will look up the service by name from
the ServiceLocator singleton
+ * c) prepareHandlers() that will connect any IResponder handlers to
the AsyncToken produced by calls to remote dataservices
+ *
+ * </p>
+ *
+ * <p>
+ * The Delegate class is ideal class to:
+ * a) to queue multiple server calls for 1 command request
+ * b) to transform the data before delivery to the command.
+ * e.g.
+ * Transform incoming structures to value objects
+ * Transform outgoing value objects to XML
+ * </p>
+ *
+ * <p>
+ * Delegates use a responder constructor argument that will be used to
announce
+ * responses (result or fault) for asynchronous events. The responders
is typically an
+ * instance of the Command class. However, it may also be ANY class
that supports the IResponder
+ * interface.
+ *
+ * Below is sample code
+ * </p>
+ *
+ * @example The following is an example Delegate subclass that (a) uses
intermediate responders,
+ * (b) transformation utils, and (c) notifyCallers() [usually a Command
instance].
+ * <listing version="3.0">
+ * public class LoginDelegate extends Delegate {
+ *
+ * public function
LoginDelegate(handlers:IResponder,serviceID:String = "") {
+ * if (serviceID == "") serviceID = "serviceLogin";
+ * super(handlers,serviceID);
+ * }
+ *
+ * public function loginUser(user:UserVO) : void {
+ * var token : AsyncToken = service.loginUser(user);
+ * var handlers : Callbacks = new
Callbacks(onResults_loginUser);
+ *
+ * // Here we want to use an intermediate handler BEFORE we
use the original
+ * // responder.
+ * prepareHandlers(token,handlers);
+ * }
+ *
+ * public function findMovieTemplate( ownerID:String, templateID:int
):void {
+ * // Note how we set the webService.request param in order to
recieve
+ * // a proper request token!
+ *
+ * var ws : WebService = service as WebService;
+ * ws.FindTemplate.request = { guid: ownerID, id: templateID };
+ *
+ * var token : AsyncToken = ws.FindTemplate.send();
+ * prepareHandlers(token);
+ * }
+ *
+ * public function onResults_doLogin(event:ResultEvent):void {
+ * var response : LoginResponseVO = (event.result as
LoginResponseVO);
+ * var login : LoginUtils = new LoginUtils(response);
+ * if (login.status ==
LoginUtils.ERROR_USER_ALREADY_CONNECTED) {
+ * response.errorCode = LoginUtils.LOGIN_GOOD;
+ * }
+ *
+ * // This uses [internally] the original delegate
responder...
+ * notifyCallers(new ResultEvent(response));
+ * }
+ * }
+ * </listing>
+ *
+ * @see com.universalmind.cairngorm.events.Callbacks
+ */
+ public class Delegate {
+
+ /**
+ * public read-only access to current Responder
+ *
+ * @return The current responder registered to handle reponses. Note:
this should not be confused with
+ * intermediate responders that are used in the example code. This is
the responder used internally when
+ * notifyCallers() is invoked.
+ */
+ public function get responder():IResponder {
+ return __responder;
+ }
+
+ /**
+ * Utility method to get a service by name; useful if a delegate call
needs a service
+ * that is different originally registered in the Delegate constructor
+ *
+ * @return An instance of either a WebService, HTTPService,
RemoteObject, or null.
+ */
+ public function getServiceByName(serviceName:String = ""):Object {
+ return ((serviceName != "") ?
serviceRegistry.findServiceByName(serviceName, false) : null);
+ }
+
+ /**
+ * Getter that performs an internal lookup of the service using the
ServiceLocator. Note the serviceName
+ * used is the one originally registered in the Delegate constructor.
The Delegate subclass NEVER have to use
+ * or import a ServiceLocator; such details are encapsulated and
handled by this Delegate parent class.
+ *
+ * @return An instance of either a WebService, HTTPService,
RemoteObject, or null.
+ */
+ public function get service():Object {
+ // Set up response handlers DIRECTLY to the command unless overriden
later
+ // with another call to prepareHandlers
+ if (__service == null) {
+ if (__serviceName != "") __service =
serviceRegistry.findServiceByName(__serviceName, false);
+
+ if (__service is WebService) {
+ var ws : WebService = __service as WebService;
+
+ use namespace mx_internal;
+ if (ws.wsdlFault == true) {
+ var message : String = StringUtil.substitute("The
Webservice {0} :: WSDL '{1}' was not loaded
properly.",[ws.service,ws.wsdl]);
+ throw new Error(message);
+ }
+ }
+ }
+
+ return __service;
+ }
+
+ /**
+ * Constructor that allows easy registration of responder and the
ID/name of the service
+ * instance that should be used for remote calls
+ *
+ * @param commandHandlers This responder that will be used as the
synchronous or asynchronous response
+ * to a delegate call
+ *
+ * @param serviceName This is the ID or name of the service
[HTTPService, RemoteObject, WebService] that
+ * should be used to perform the remote dataservice call. This
service instance is retrieved via an internal
+ * call to the ServiceLocator.
+ */
+ public function Delegate(commandHandlers:IResponder =
null,serviceName:String="") {
+ // Usually the responder is the calling command instance... but not
always
+ __responder = commandHandlers;
+ __serviceName = serviceName;
+
+ }
+
+
+ //
*******************************************************************************************************************
+ // PrepareHandler variations
+ //
*******************************************************************************************************************
+ /**
+ * Static utility method used to quickly add responder handlers to an
AsyncToken
+ *
+ * @param token AsyncToken that is returned from a
AbstractMethod call
+ * @param resultHandler Function that should be invoked asynchronously
to handle the ResultEvent
+ * @param faultHandler Function that should be invoked asynchronously
to handle the FaultEvent
+ *
+ */
+ public static function
prepareResponder(token:AsyncToken,resultHandler:Function,faultHandler:Function):void
{
+ if (token != null) {
+ token.addResponder(new mx.rpc.Responder(resultHandler,faultHandler));
+ }
+ }
+
+ /**
+ * Utility method used to add responder handlers (and options) to an
AsyncToken
+ *
+ * @param token AsyncToken that is returned from a
AbstractMethod call
+ * @param options Generic object that contains one or more
properties/objects that should be cached while waiting for a response from
the aysnchronous call
+ *
+ * @param faultHandler Callbacks instance to specific overrides to
the current responder. This allows
+ * inidividual methods to have custom handlers internal to the Delegate
subclass. Such solutions would be used to transform data
+ * before a Command responder is then called.
+ *
+ */
+ public function prepareHandlersWithOptions(
token:AsyncToken=null ,options:*=null, handlers:IResponder = null):void {
+ if (token != null) token.options = options;
+ prepareHandlers(token, handlers);
+ }
+
+ /**
+ * Utility method used to add responder handlers (and options) to an
AsyncToken. If the service token has not been configured
+ * properly, this method will throw an error announcing an
initialization issue with the service.
+ *
+ * @param token AsyncToken that is returned from a
AbstractMethod call
+ * @param faultHandler Callbacks instance to specific overrides to
the current responder. This allows
+ * inidividual methods to have custom handlers internal to the Delegate
subclass. Such solutions would be used to transform data
+ * before a Command responder is then called.
+ *
+ * @throws Error Announces that the service instance has not been
initialized properly.
+ */
+ public function
prepareHandlers(token:AsyncToken=null,handlers:IResponder =null):void {
+ // Normally we have 1 call per service so the default handler
implementation works
+ // but if we have multiple call options, how do we assign different
handlers to
+ // different calls? .... alternateHandlers...
+ if (token == null || token.message == null) {
+ var ws : WebService = (this.service as WebService);
+ if ((ws && !ws.canLoadWSDL()) || (ws == null)) {
+ var msg : String = "The Service for Delegate '{0}' has not been
initialized properly.";
+ var classInfo : Object = ObjectUtil.getClassInfo(this);
+ throw new
Error(StringUtil.substitute(msg,[String(classInfo['name'])]));
+ }
+ }
+
+ Delegate.prepareResponder(token, getResultHandler(handlers),
getFaultHandler(handlers));
+ }
+
+ /**
+ * This method allows a delegate method to manually announce a
response to the the original responder.
+ * This method is normally not used since the prepareHandlers() call
connects the asynchronous handlers for the
+ * responder DIRECTLY to the remote call. In such cases the delegate
is bypassed completely.
+ *
+ * <p>
+ * However, if the delegate call wishes to "massage" the incoming
response before notifying the original responder
+ * then prepareHandlers() is given an "intermediate" responder... and
the developer is then responsible for manually invoking
+ * the original responder. Below is an example for a LoginDelegate
subclass:
+ *
+ * <pre>
+ * public function loginUser(user:UserVO) : void {
+ * var token : AsyncToken = service.loginUser(user);
+ * var handlers : Callbacks = new Callbacks(onResults_loginUser);
+ *
+ * // Here we want to use an intermediate handler BEFORE we use
the original
+ * // responder.
+ * prepareHandlers(token,handlers);
+ * }
+ *
+ * public function onResults_doLogin(event:ResultEvent):void {
+ * var response : LoginResponseVO = (event.result as
LoginResponseVO);
+ * if (response.errorCode == ERROR_USER_ALREADY_CONNECTED) {
+ * response.errorCode = LOGIN_GOOD;
+ * }
+ *
+ * // This uses [internally] the original delegate responder...
+ * notifyCaller(response,event);
+ * }
+ * </pre>
+ *
+ * @results This is the data or event to return to the "original"
IResponder
+ * @srcEvent This is the original event generated as response to
the Delegates asynchronous call
+ */
+ public function notifyCaller(results:* = null, srcEvent:* = null):void {
+ // Default result handler simply forwards
+ // the event to the view handler... if available
+ var isData : Boolean = (results != ResultEvent) && (results !=
FaultEvent);
+
+ if (isData && (srcEvent != null)) {
+ // Let's package the new data inside a clone of the original event
+ // Since this is coming from a Delegate, the call is most likely
a Command
+ // we usually expects results directly back from the FlashPlayer;
which delivers
+ // an event NOT data!
+
+ var rEv : ResultEvent = srcEvent as ResultEvent;
+ var fEv : FaultEvent = srcEvent as FaultEvent;
+
+ if (rEv != null) results = new
ResultEvent(rEv.type,false,false,results,rEv.token,rEv.message);
+ else if (fEv != null) results = new
FaultEvent(fEv.type,false,false,fEv.fault,fEv.token,fEv.message);
+ }
+
+ if (results is FaultEvent) this.onFault(results);
+ else this.onResult(results);
+
+ }
+
+
+ // *********************** **********************************
+ // Stub Handlers for IResponder
+ // *********************** ********************************
+
+ /**
+ * @private - This method is ONLY necessary to allow Delegates
to "implement" the IResponder interface;
+ */
+ public function onResult(event:*):void {
+ if (responder != null) responder.result(event);
+ else throwError(ON_RESULT);
+ }
+
+ /**
+ * @private - This method is ONLY necessary to allow Delegates
to "implement" the IResponder interface;
+ */
+ public function onFault(event:*=null):void {
+ if (responder != null) responder.fault(event);
+ else throwError(ON_FAULT);
+ }
+
+
+ // *********************** **********************************
+ // Private utility methods
+ // *********************** ********************************
+
+ private function
getResultHandler(delegateHandlers:IResponder=null):Function {
+ // Did the Delegate subclass have specific methods that should handler
the results 1st?
+ // This 1st handler is where the factories could convert the incoming
data...
+ return makeMethodClosure(ON_RESULT, delegateHandlers );
+ }
+
+ private function
getFaultHandler(delegateHandlers:IResponder=null):Function {
+ // Did the Delegate subclass have specific methods that should handler
the results 1st?
+ // This 1st handler is where the factories could convert the incoming
data...
+ return makeMethodClosure(ON_FAULT,delegateHandlers );
+ }
+
+ private function
makeMethodClosure(method:String,scope:IResponder=null):Function {
+
+ var results : Function = null;
+
+ if (scope == null) scope = this.responder;
+ switch(method) {
+ case ON_RESULT: results = scope.result;
+ if (results == null) results = responder.result;
+ break;
+ case ON_FAULT: results = scope.fault;
+ if (results == null) results = responder.fault;
+ break;
+ }
+
+ return results;
+ }
+
+ // *********************** **********************************
+ // Private Attributes
+ // *********************** ********************************
+
+ private function throwError(eventType:String):void {
+ var msg : String = StringUtil.substitute("Delegate for {0} does not
have any eventHandlers for the {1} event.", [__serviceName,eventType]);
+ throw (new Error(msg));
+ }
+
+ private function get serviceRegistry(): ServiceLocator {
+ // Note this means that developers must take care that the proper
instance is created...
+ var locator : com.universalmind.cairngorm.business.ServiceLocator =
com.universalmind.cairngorm.business.ServiceLocator(com.universalmind.cairngorm.business.ServiceLocator.getInstance());
+ if (locator == null) {
+ throw new Error("com.universalmind.cairngorm.business.ServiceLocator
instance is not available!");
+ }
+
+ return locator;
+ }
+
+
+ // *********************** **********************************
+ // Private Attributes
+ // *********************** ********************************
+
+ protected var __service : *;
+ protected var __serviceName : String;
+ protected var __responder : IResponder;
+
+
+ static private const ON_FAULT : String = "onFault";
+ static private const ON_RESULT: String = "onResult";
+ }
+}
=======================================
***Additional files exist in this changeset.***

Reply all
Reply to author
Forward
0 new messages