Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for swiz-47, moved error flag from event chain step to base chain…

… step and added handling in complete(). added support for swiz factory processors
  • Loading branch information...
commit 81dde8d8b7bb307ff09a9640a1160ef0a7d351c1 1 parent c21eaff
@asstrochris asstrochris authored
View
4 build/build.xml
@@ -87,11 +87,11 @@
<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="EventHandler"/>
- <keep-as3-metadata name="Inject"/>
<keep-as3-metadata name="Mediate"/>
<keep-as3-metadata name="PostConstruct"/>
<keep-as3-metadata name="PreDestroy"/>
View
43 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
@@ -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
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
21 src/org/swizframework/utils/chain/BaseChainStep.as
@@ -36,8 +36,23 @@ 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;
- protected var _isError:Boolean = false;
public function get isComplete():Boolean
{
@@ -55,7 +70,7 @@ package org.swizframework.utils.chain
public function complete():void
{
// before calling complete(), check if the chain step has been marked as error
- if( !_isError)
+ if( !_failed)
{
_isComplete = true;
@@ -69,7 +84,7 @@ package org.swizframework.utils.chain
*/
public function error():void
{
- _isError = true;
+ _failed = true;
_isComplete = true;
if( chain != null )
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
3  src/org/swizframework/utils/test/AutowiredTestCase.as
@@ -96,7 +96,8 @@ package org.swizframework.utils.test
/**
*
*/
- [Before(order=1]
+ // [Before("order=1"]
+ [Before]
public function constructSwizContext():void
{
Please sign in to comment.
Something went wrong with that request. Please try again.