Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged upstream changes to fork (April 14)

Signed-off-by: Thomas Burleson <ThomasBurleson@Gmail.com>
  • Loading branch information...
commit 936c603f7842599c409c2b646972f5d3c02c26a2 1 parent 9c54f72
@ThomasBurleson authored
View
1  .gitignore
@@ -12,6 +12,7 @@
.project
.sourceMate
.sourceMateMetadataSettings
+setEnv.sh
Icon
Thumbs.db
View
12 CONTRIBUTORS.textile
@@ -0,0 +1,12 @@
+h2. Framework Contributors
+
+* "Chris Scott":http://github.com/asstrochris
+* "Ben Clinkinbeard":http://github.com/bclinkinbeard
+* "Sönke Rohde":http://github.com/srohde
+* "Ryan Campbell":http://github.com/ryancampbell
+* "Darron Schall":http://github.com/darronschall
+* "David Tucker":http://github.com/davidtucker
+* "John Yanarella":http://github.com/johnyanarella
+* "Cliff Meyers":http://github.com/cliffmeyers
+* "Brian Kotek":http://github.com/brian428
+* "Adam Lehman":adrocknaphobia@gmail.com
View
45 build/build.xml
@@ -7,15 +7,17 @@
<!-- Configuration -->
<!-- ============================== -->
+
<property environment="env" />
+ <!-- Configuration -->
+ <property file="${basedir}/build/build.properties" />
+
<!-- Setup Flex Ant Resources -->
+ <!--property name="FLEX_HOME" location="${flex.sdk}" /-->
<property name="FLEX_HOME" location="${env.FLEX_HOME}" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
- <!-- Configuration -->
- <property file="${basedir}/build/build.properties" />
-
<!-- ============================== -->
<!-- Clean and Init Targets -->
<!-- ============================== -->
@@ -52,11 +54,35 @@
<mkdir dir="${report.loc}" />
</target>
+ <target name="setDefaults">
+ <echo>setting compiler defautls</echo>
+
+ <!-- set defaults for mobile -->
+ <condition property="mobile" value="false">
+ <not>
+ <isset property="${mobile}"/>
+ </not>
+ </condition>
+ <condition property="webDesktop" value="false">
+ <istrue value="${mobile}"/>
+ </condition>
+ <property name="webDesktop" value="true"/>
+ <echo>
+ set desktop:${webDesktop}, mobile:${mobile}
+ </echo>
+ </target>
+
+ <target name="echoProps" depends="setDefaults">
+ <echo>
+ Desktop: ${webDesktop}, Mobile: ${mobile}
+ </echo>
+ </target>
+
<!-- ======================================= -->
<!-- Compile, Document, and Package Targets -->
<!-- ======================================= -->
- <target name="compile" depends="init" description="Compile the library .swc file">
+ <target name="compile" depends="init,setDefaults" description="Compile the library .swc file">
<!-- set up list of classes to include in library -->
<fileset id="src.include.fileset" dir="${src.loc}">
@@ -73,22 +99,27 @@
</chainedmapper>
</compositemapper>
</pathconvert>
-
+
<compc output="${bin.loc}/${swiz.name}.swc" include-classes="${src.include.classes}">
<source-path path-element="${src.loc}" />
<namespace uri="${swiz.namespace}" manifest="${src.loc}/manifest.xml" />
<include-namespaces uri="${swiz.namespace}" />
+ <!-- add mobile / web compiler args -->
+ <compiler.define name="CONFIG::mobile" value="${mobile}" />
+ <compiler.define name="CONFIG::webDesktop" value="${webDesktop}" />
+
<!-- Configure the flex framework libraries as external link dependencies -->
<external-library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="locale/{locale}" />
</external-library-path>
-
+
+ <keep-as3-metadata name="Inject"/>
<keep-as3-metadata name="Autowire"/>
<keep-as3-metadata name="Dispatcher"/>
- <keep-as3-metadata name="Inject"/>
+ <keep-as3-metadata name="EventHandler"/>
<keep-as3-metadata name="Mediate"/>
<keep-as3-metadata name="PostConstruct"/>
<keep-as3-metadata name="PreDestroy"/>
View
45 src/org/swizframework/core/BeanFactory.as
@@ -27,7 +27,9 @@ package org.swizframework.core
import mx.modules.Module;
import org.swizframework.events.BeanEvent;
+ import org.swizframework.events.SwizEvent;
import org.swizframework.processors.IBeanProcessor;
+ import org.swizframework.processors.IFactoryProcessor;
import org.swizframework.processors.IMetadataProcessor;
import org.swizframework.processors.IProcessor;
import org.swizframework.reflection.TypeCache;
@@ -59,6 +61,8 @@ package org.swizframework.core
protected var isListeningForEnterFrame:Boolean = false;
+ public var waitForSetup:Boolean = false;
+
// ========================================
// public properties
// ========================================
@@ -102,6 +106,19 @@ package org.swizframework.core
addBeanProvider( beanProvider, false );
}
+ // run any factory processors before setting up any beans
+ runFactoryProcessors();
+
+ // todo: everything else shoud be delayed if the factoryProcessor initialized an aop autoproxy processor
+ completeBeanFactorySetup();
+ }
+
+ public function completeBeanFactorySetup():void
+ {
+ if( waitForSetup ) return;
+
+ logger.info( "BeanFactory completing setup" );
+
// bean setup has to be delayed until after all startup beans have been added
for each( var bean:Bean in beans )
{
@@ -139,6 +156,8 @@ package org.swizframework.core
else
setUpBean( createBeanFromSource( swiz.dispatcher ) );
}
+
+ swiz.dispatcher.dispatchEvent( new SwizEvent( SwizEvent.LOAD_COMPLETE, swiz ) );
}
public function tearDown():void
@@ -179,7 +198,7 @@ package org.swizframework.core
{
for each( var bean:Bean in beans )
{
- if( bean is Prototype && Prototype( bean ).singleton == false )
+ if( bean is Prototype && ( Prototype( bean ).singleton == false || Prototype( bean ).initialized == false ) )
continue;
else if( bean.source === source )
return bean;
@@ -301,6 +320,21 @@ package org.swizframework.core
}
/**
+ * Executes any Factory Processors
+ */
+ public function runFactoryProcessors():void
+ {
+ for each( var processor:IProcessor in swiz.processors )
+ {
+ // Handle Metadata Processors
+ if( processor is IFactoryProcessor )
+ {
+ IFactoryProcessor( processor ).setUpFactory( this );
+ }
+ }
+ }
+
+ /**
* Initialze Bean
*/
public function setUpBean( bean:Bean ):void
@@ -315,6 +349,10 @@ package org.swizframework.core
for each( processor in swiz.processors )
{
+ // skip factory processors
+ if( processor is IFactoryProcessor )
+ continue;
+
// Handle Metadata Processors
if( processor is IMetadataProcessor )
{
@@ -330,6 +368,7 @@ package org.swizframework.core
metadataProcessor.setUpMetadataTags( metadataTags, bean );
}
+ // Handle Bean Processors
if( processor is IBeanProcessor )
{
IBeanProcessor( processor ).setUpBean( bean );
@@ -344,6 +383,10 @@ package org.swizframework.core
{
for each( var processor:IProcessor in swiz.processors )
{
+ // skip factory processors
+ if( processor is IFactoryProcessor )
+ continue;
+
// Handle Metadata Processors
if( processor is IMetadataProcessor )
{
View
6 src/org/swizframework/events/SwizEvent.as
@@ -36,6 +36,12 @@ package org.swizframework.events
public static const CREATED:String = "swizCreated";
/**
+ * The BeanEvent.LOAD_COMPLETE constant defines the value of the type property
+ * of an initial load complete event object.
+ */
+ public static const LOAD_COMPLETE:String = "loadComplete";
+
+ /**
* The BeanEvent.REMOVED constant defines the value of the type property
* of a beanRemoved event object.
*/
View
52 src/org/swizframework/metadata/Injection.as
@@ -1,52 +0,0 @@
-/*
- * Copyright 2010 Swiz Framework Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.swizframework.metadata
-{
- import org.swizframework.core.Bean;
-
- /**
- * Represents a deferred request for injection.
- */
- public class Injection
- {
- // ========================================
- // public properties
- // ========================================
-
- /**
- * The corresponding [Inject] tag.
- */
- public var injectTag:InjectMetadataTag;
-
- /**
- * The object that contains the [Inject] tag.
- */
- public var bean:Bean;
-
- // ========================================
- // constructor
- // ========================================
-
- public function Injection( injectTag:InjectMetadataTag = null, bean:Bean = null )
- {
- super();
-
- this.injectTag = injectTag;
- this.bean = bean;
- }
- }
-}
View
18 src/org/swizframework/processors/IFactoryProcessor.as
@@ -0,0 +1,18 @@
+package org.swizframework.processors
+{
+ import org.swizframework.core.IBeanFactory;
+
+ public interface IFactoryProcessor extends IProcessor
+ {
+ // ========================================
+ // public methods
+ // ========================================
+
+ /**
+ * Process the swin bean factory itself. Executes after all beans are loded but NOT yet set up.
+ *
+ * @param factory: the IBeanFactory instance to process
+ */
+ function setUpFactory( factory:IBeanFactory ):void;
+ }
+}
View
7 src/org/swizframework/processors/ProcessorPriority.as
@@ -31,6 +31,13 @@ package org.swizframework.processors
{
/**
+ * Built-in <code>AutoProxyProcessor</code> runs before any bean setup (as an IFactoryProcessor).
+ *
+ * @see org.swizframework.processors.AutoProxyProcessor
+ */
+ public static const AUTO_PROXY :int = 900;
+
+ /**
* Built-in <code>PreDestroyProcessor</code> runs during tear down to allow components to do any
* necessary cleanup to ensure proper disposal.
*
View
24 src/org/swizframework/utils/DomainUtil.as
@@ -18,8 +18,11 @@ package org.swizframework.utils
{
import flash.system.ApplicationDomain;
- import mx.modules.Module;
- import mx.modules.ModuleManager;
+ CONFIG::webDesktop
+ {
+ import mx.modules.Module;
+ import mx.modules.ModuleManager;
+ }
public class DomainUtil
{
@@ -46,14 +49,21 @@ package org.swizframework.utils
*/
public static function getModuleDomain( object:Object ):ApplicationDomain
{
- if( object is Module )
+ CONFIG::mobile
{
- var moduleInfo:Object = ModuleManager.getAssociatedFactory( object ).info();
- return moduleInfo.currentDomain;
+ return null;
}
- else
+ CONFIG::webDesktop
{
- return null;
+ if( object is Module )
+ {
+ var moduleInfo:Object = ModuleManager.getAssociatedFactory( object ).info();
+ return moduleInfo.currentDomain;
+ }
+ else
+ {
+ return null;
+ }
}
}
}
View
47 src/org/swizframework/utils/chain/AbstractChain.as
@@ -55,13 +55,19 @@ package org.swizframework.utils.chain
_chain = value;
}
- protected var _isComplete:Boolean;
+ protected var _isComplete:Boolean = true;
+ protected var _isError:Boolean = false;
public function get isComplete():Boolean
{
return _isComplete;
}
+ public function get isError():Boolean
+ {
+ return _isError;
+ }
+
/**
* Backing variable for <code>position</code> getter/setter.
*/
@@ -127,8 +133,13 @@ package org.swizframework.utils.chain
*/
public function start():void
{
- position = -1;
- proceed();
+ if( _isComplete )
+ {
+ _isComplete = false;
+ _isError = false;
+ position = -1;
+ proceed();
+ }
}
public function stepComplete():void
@@ -157,24 +168,27 @@ package org.swizframework.utils.chain
if( position == -1 )
dispatchEvent( new ChainEvent( ChainEvent.CHAIN_START ) );
- if( mode == ChainType.SEQUENCE )
+ if( !_isError )
{
- if( hasNext() )
+ if( mode == ChainType.SEQUENCE )
{
- position++;
- IChain( this ).doProceed();
+ if( hasNext() )
+ {
+ position++;
+ IChain( this ).doProceed();
+ }
+ else
+ {
+ complete();
+ }
}
else
{
- complete();
- }
- }
- else
- {
- for( var i:int = 0; i < steps.length; i++ )
- {
- position = i;
- IChain( this ).doProceed();
+ for( var i:int = 0; i < steps.length; i++ )
+ {
+ position = i;
+ IChain( this ).doProceed();
+ }
}
}
}
@@ -220,6 +234,7 @@ package org.swizframework.utils.chain
{
dispatchEvent( new ChainEvent( ChainEvent.CHAIN_FAIL ) );
+ _isError = true;
_isComplete = true;
if( chain != null )
View
31 src/org/swizframework/utils/chain/BaseChainStep.as
@@ -36,6 +36,22 @@ package org.swizframework.utils.chain
_chain = value;
}
+ /**
+ * Backing variable for <code>failed</code> property.
+ */
+ protected var _failed:Boolean = false;
+
+ /**
+ * Indicates whether this step failed.
+ */
+ public function get failed():Boolean
+ {
+ return _failed;
+ }
+
+ /**
+ * Backing variable for <code>isComplete</code> property.
+ */
protected var _isComplete:Boolean = false;
public function get isComplete():Boolean
@@ -53,10 +69,14 @@ package org.swizframework.utils.chain
*/
public function complete():void
{
- _isComplete = true;
-
- if( chain != null )
- chain.stepComplete();
+ // before calling complete(), check if the chain step has been marked as error
+ if( !_failed)
+ {
+ _isComplete = true;
+
+ if( chain != null )
+ chain.stepComplete();
+ }
}
/**
@@ -64,6 +84,9 @@ package org.swizframework.utils.chain
*/
public function error():void
{
+ _failed = true;
+ _isComplete = true;
+
if( chain != null )
chain.stepError();
}
View
13 src/org/swizframework/utils/chain/EventChainStep.as
@@ -38,11 +38,6 @@ package org.swizframework.utils.chain
* Backing variable for <code>event</code> property.
*/
protected var _event:Event;
-
- /**
- * Backing variable for <code>failed</code> property.
- */
- protected var _failed:Boolean = false;
/**
* Backing variable for <code>pendingCount</code> property.
@@ -75,14 +70,6 @@ package org.swizframework.utils.chain
}
/**
- * Indicates whether this step failed.
- */
- public function get failed():Boolean
- {
- return _failed;
- }
-
- /**
* Count of pending asynchronous operations for this step.
*/
public function get pendingCount():int
View
14 src/org/swizframework/utils/logging/AbstractSwizLoggingTarget.as
@@ -50,17 +50,17 @@ package org.swizframework.utils.logging
public function addLogger( logger:SwizLogger ):void
{
- if (logger)
+ if( logger )
{
- logger.addEventListener(SwizLogEvent.LOG_EVENT, logHandler);
+ logger.addEventListener( SwizLogEvent.LOG_EVENT, logHandler );
}
}
- public function removeLogger(logger:SwizLogger):void
+ public function removeLogger( logger:SwizLogger ):void
{
- if (logger)
+ if( logger )
{
- logger.removeEventListener(SwizLogEvent.LOG_EVENT, logHandler);
+ logger.removeEventListener( SwizLogEvent.LOG_EVENT, logHandler );
}
}
@@ -72,8 +72,8 @@ package org.swizframework.utils.logging
protected function logHandler( event:SwizLogEvent ):void
{
- if (event.level >= level)
- logEvent(event);
+ if( event.level >= level )
+ logEvent( event );
}
}
}
View
2  src/org/swizframework/utils/logging/SwizLogEvent.as
@@ -46,7 +46,7 @@ package org.swizframework.utils.logging
override public function clone():Event
{
- return new SwizLogEvent(message, level);
+ return new SwizLogEvent( message, level );
}
}
}
View
1  src/org/swizframework/utils/test/AutowiredTestCase.as
@@ -96,6 +96,7 @@ package org.swizframework.utils.test
/**
*
*/
+ // [Before("order=1"]
[Before]
public function constructSwizContext():void
{
Please sign in to comment.
Something went wrong with that request. Please try again.