Spring ActionScript 1.1 Released

ActionScript, Air, Flash, Flex, Inversion of Control, Spring ActionScript 3 Comments »

Dear community,

We're pleased to announce that Spring ActionScript 1.1 is now available.

Download | API Documentation | HTML Docs | Changelog

Besides a series of bugfixes, this release adds the following new features and enhancements:

Component Scanning & Context XML Namespace

Just like XML and MXML configuration, component scanning is a way to configure objects to be used in the application context. This is done by adding [Component] metadata to classes that you want to expose as objects to the container. The container will then scan all classes or the classes in a package you specify and create object definitions for the classes that have Component metadata. This means that you can configure your application with a minimum of XML or MXML configuration.

The newly added "context" namespace currently contains a "component-scan" and a "metadata-config" element. The first one enables component scanning as described above. The "metadata-config" registers common metadata processors and reduces the configuration needed to use these processors.

XML:
  1. <context:component-scan/>
  2. <context:metadata-config/>

For more info, see the documentation: Component Scanning

Test Framework

The Spring ActionScript integration testing support framework provides several abstract support classes that can simplify writing integration tests. These base test classes provide well defined hooks into the testing framework. Currently, only FlexUnit 4 is supported.

More info can be found in the Test Framework section of the documentation.

PostConstruct, PreDestroy and Inject Metadata

To be in line with industry standards, we added support for the PostConstruct, PreDestroy and Inject metadata.

PostConstruct and PreDestroy are annotations that allow you to call methods in a specific phase in the lifecycle of a component. The Inject metadata is used as an alias for the Autowired metadata.

More Information

For more general information on the Spring ActionScript framework, please see the following links:

Enjoy this release and have fun coding!


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Spring ActionScript 1.0 Released

ActionScript, Flex, Inversion of Control, Spring ActionScript 2 Comments »

Dear community,

We're pleased to announce that Spring ActionScript 1.0 is now available.

Download | API Documentation | HTML Docs | Changelog

Spring ActionScript is an offshoot of the Java Spring Framework written in ActionScript 3.0. The framework contains the following core features:

  • Inversion of Control container, configurable with XML or MXML
  • EventBus supporting loose communication between application components
  • Metadata/annotation processing used for autowiring, event handling, ...
  • Operation, Command and Task API
  • Utilities for abstracting server communication
  • Support for Modules
  • Extensions for the Cairngorm and PureMVC frameworks

The Spring Actionscript team would like to take this opportunity to thank everyone who took the time to report bugs, give suggestions and help out in any other kind of way. Without the dedicated Spring community behind us, the framework would not be where it is today. Thank all of you!

We would also like to thank the nice folks at SpringSource and especially Jeremy Grelle, our project sponsor, and Russel Miles, the Spring Extensions lead. Thanks guys for the support and the opportunity that you gave us.

As always, we're on the look out for new members to join the team. If you are willing to invest some of your spare time to write documentation, sample applications, fix bugs or develop new functionality then please don't hesitate to get in touch with us!

For the full list of changes please check the changelog. If you have any suggestions for new functionality or improvements to the existing code base, then please use JIRA to submit a feature request.

More Information

For more information on the Spring ActionScript framework, please see the following links:

Enjoy this release and have fun coding!


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Spring ActionScript: Café Townsend sample application

ActionScript, Air, Design Patterns, Domain-Driven Design, Flash, Flash Builder, Flex, Flex Builder, Inversion of Control, Spring ActionScript 11 Comments »

A new Spring ActionScript sample application is now available. This is the Café Townsend application, originally created as a sample application for the Cairngorm framework, that we ported to Spring ActionScript. This should make it easier to compare this implementation with the implementations of some of the other frameworks.

Open the Café Townsend sample.
(Be sure to check the source by right-clicking and choosing "View Source" from the context menu, click here to go to the source directly.)

Download the Flex/Flash Builder project and sources.

Discussion

In what follows, we will discuss the implementation details and motivate certain choices made in this design.

Package Structure

The first thing you might notice is the package structure, that might seem a bit odd at first since it is different from what most frameworks use or prescribe. This example follows the Layered Architecture, described by Eric Evans in the book Domain-Driven Design: Tackling Complexity in the Heart of Software (recommended reading). This architecture makes it easy to detect and apply the different layers of the application and forces us somewhat to have a clean separation of the responsibilities of each layer.

The layered architecture consists of four layers, as shown on the image below:

  • Presentation Layer: contains the user interface (the view component and in this example the presentation models)
  • Application Layer: coordinates the application and forms a communication channel between the UI and the domain
  • Domain Layer: the core of the software. This layer defines the entities and repositories/services that form the business logic of the application. For the most part only the interfaces for the services will be written here. This layer does not contain any implementation details.
  • Infrastructure Layer: provides implementation details for all other layers. Concrete implementations of services will be put here.

Note that it is certainly not needed to structure your application like this. Spring ActionScript does not impose or prescribe this structure, but we certainly think it is useful and wanted to introduce it in this example. Also note that while we have applied this architecture as packages in the same application, you might want to create different swc's or libraries for each of these layers so that they can easily be reused.

Presentation Layer & Presentation Models

This example uses the Presentation Model (PM) as the main presentation pattern for the UI layer. The PM allows us to extract all state and controller logic for the view into a separate class that is view agnostic. A view component contains a reference to its corresponding PM and delegates all UI actions to it. The view component can either instantiate the PM directly, or it can be given one, either by a parent component or by having it "injected" by the Spring ActionScript framework. The process of automatically injecting properties into a (view) component is known as "Autowiring" in Spring ActionScript. Note that since the PM is not a UI component and does not know anything about the view, it can be easily unit tested.

An example of autowiring can be found in the EmployeeLogin.mxml class:

Actionscript:
  1. [Autowired]
  2. [Bindable]
  3. public var presentationModel:EmployeeLoginPresentationModel;

The PMs used in this example will either delegate directly to the business logic (for instance for loading the employees) or will delegate to the Application Layer (for instance for logging the user out of the application). Here again, there is no strict rule to follow, but you can decide for your own what approach seems the bests.

Note that autowiring is disabled by default. This is because in bigger applications, there might be a significant performance hit when autowiring is used. It is adviced to finetune the autowiring by configuring the autowire processor to include or exclude certain classes. To enable autowiring, simply add the following to the XML configuration:

XML:
  1. <object id="autowiringStageProcessor" class="org.springextensions.actionscript.stage.DefaultAutowiringStageProcessor"/>

Application Layer

In some cases, the UI will delegate responsibilities to the Application Layer. Since the UI does not know about this layer, it needs a loosely coupled way of communicating with it. The communication channel that provides this capability in Spring ActionScript is the EventBus. It is implemented on top of Flash's event dispatching capability and forms a centralized medium for component and layer interaction.

In the example, the code behind the Logout button will dispatch an event via the EventBus. The application controller listens for this event and will handle it by invoking the logout method on the authentication service. Notice that the application controller takes the authentication service as a constructor argument and that the service is typed to the interface IAuthenticationService. The actual instance is provided in the (XML) configuration, were both the application controller and the authentication service and defined and linked to eachother.

Notice that the application controller does not explicitely listen for the logout event. Instead, it is sufficient to create a method and annotate it with the [EventHandler] metadata. Spring ActionScript will then introspect the controller, pick up all annotated methods and link them automatically with the event received from the EventBus.

Here's what the logout method looks like in the application controller:

Actionscript:
  1. [EventHandler]
  2. public function logout():void {
  3.   var operation:IOperation = _authenticationService.logout();
  4.   operation.addCompleteListener(logout_completeHandler);
  5. }

Notice that the name of the logout method corresponds to the event being dispatched, namely "logout" (see the ApplicationEvents class for that). You can however also choose the name of this method as you like and specify the name of the event as an attribute of the EventHandler metadata.

As with autowiring, the processing of the EventHandler metadata is not enabled by default. If you want to use this in your application, simply add the following to the XML configuration:

XML:
  1. <object id="eventHandlerProcessor" class="org.springextensions.actionscript.ioc.factory.config.EventHandlerMetaDataPostProcessor"/>

For more information on the EventBus, please refer to the documentation.

Domain Layer

The domain for this application is extremely simple. All it contains is an Employee entity and an employee service in the form of the IEmployeeService. Except for the actual entities of the domain, this layer does not contain any implementation details for the services it provides, but merely defines the interfaces for those services.

Infrastructure Layer

The infrastructure layer is where the technical details of the applications live. This layer provides the actual implementation of the services found in the other layers. Depending on the different contexts the application needs to be able to run in, you might provide different implementations of the services here. The implementations used in the application can then be defined the a Spring ActionScript Application Context. As an example, think of an application that needs to be able to connect to a set of services using Remote Objects in one scenario and needs to connect to a set of Webservices in another scenario. If we provide both implementations, we can easily reconfigure the application by changing the XML configuration of the application context.

Application Context

Once we have all components, we can bundle them together and prepare them to be used in the application. By doing this, we are configuring the context of the application. In Spring ActionScript this is done by instantiating a FlexXMLApplicationContext (in case you are working with Flex).

The application context in this example is configured using XML, but it could just as easily be configured using an MXML configuration. Both approaches have there pros and cons and you should decide what fits best for you project.

Looking at the Main.mxml class, which is the entry point of the application, we can see that a FlexXMLApplicationContext is instantiated and given the path to the external XML file (application-context.xml) that forms the application context's configuration. Now all we need to do is wait for the context to load before starting the application.

Conclusion

This example contains significantly less code than the original Cairngorm version. This is mainly because Spring ActionScript does not impose any strict architectural rules and provides the developer with plenty of choice for architecting things that best fit the application being developed. What might work in application A might not necessarily work well for application B or C. Being given so much freedom and choice might feel awkward at first, but you will notice that this is actual a good thing and you will benefit greatly from it.

If you have any remarks on this post, please leave them in comments or contact me. Whether they are errors, things that are unclear, or general questions... all feedback is welcome.

General information and document about Spring ActionScript can be found at http://www.springactionscript.org/

Related articles:


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Spring ActionScript 1.0RC1 Released

ActionScript, Air, Flex, Inversion of Control, Spring ActionScript 5 Comments »

Dear community,

I'm pleased to announce that the first release candidate for Spring ActionScript 1.0 is now available.

Download | API Documentation | HTML Docs | Changelog

This release is considered feature complete and announces the final stage before moving to a final 1.0 release.

Amongst the many updates and fixes, these are the most important ones:
- Operation API (docs, blog)
- EventBus (docs)
- Task API (docs)
- MXML Configuration (docs)

These changes will be discussed in a couple of follow-up blogposts, so please check back soon for that. In the meantime, please refer to the documentation provided for more information.

I would like to thank all of you who have given us valuable feedback and provided interesting ideas, sent in patches, reported bugs or helped us out in whatever way possible. Your support has been priceless in the development of this framework and it would not be as rich as it is now without you.

Special thanks go out to Martino for mastering the Maven build system and fixing a lot of the problems that stopped us from releasing earlier, and to Roland who has written 99,9% of the AWESOME documentation and took a natural lead in the development of 1.0RC1. You guys rock!

Enjoy this release and have fun coding!

Spring ActionScript 1.0RC1 Changelog

  • fixed constructor-arg type attribute was not declared in spring-actionscript-objects-1.0.xsd.

    config reference link

  • added unregisterStageProcessor() method to the IStageProcessorRegistry interface.

    ASDoc link

  • added DefaultFlexAutowireProcessor that handles binding using the [Autowired(name="objectName",property="property.chain")] metadata.

    documentation link

  • added PureMVC documentation section.

    puremvc documentation link

  • added autowiring support for injecting external property values using [Autowired(externalProperty="propertyName")].

    documentation link

  • added parent context support to IObjectFactory interface and AbstractObjectFactory implementation.

    documentation link

  • added skip-postprocessor and skip-metadata support for ObjectDefinition.

    skip-metadata link

    skip-postprocessor link

  • added name and value attribute support to the property XML element, for defining external properties directly in the configuration instead of an external properties file.

    docs link

  • added parent properties support to XMLObjectFactory.

    docs link

  • added IStageProcessorRegistry interface and FlexStageProcessorRegistry implementation to support stage wiring in a multi-module situation (Thanks to Arnoud for helping debug this).

    docs link

  • added extra functionality to the CairngormFrontController that enables to add commands that are being created by the application context (basically using the context as a commandFactory).

    cairngorm docs link

  • renamed SASCairngormEvent to SASCairngormModuleEvent.

    cairngorm docs link

  • ObjectUtils no longer has a dependency on the Flex framework.
  • added core.* package containing the Operation API.

    operation docs link

  • added core.event.* package containing the EventBus classes.

    eventbus docs link

  • added EventHandlerMetaDataPostProcessor for automatic handling of EventBus events.

    eventbus docs link

  • added parallel or sequencential execution to CompositeCommand class.

    operation docs link

  • added core.task.* package.

    operation docs link

  • added support for property chain retrieval in the FieldRetrievingObjectFactory, for example: Application.application.systemManager.stage can now be retrieved.
  • added support for compound property names in XML config.
  • added support for factory-object in AbstractObjectFactory..

    link

  • added TaskNamespaceHandler for core.task.* package.

    link

  • added createInstance(clazz:Class, constructorArguments:Array = null) method to the IObjectFactory interface to enable a factory to create objects with only annotations and have no object definition.

    link

  • added operation and service for remoting via NetConnection.

    link

  • added support for vector type in XML configuration..

    link

  • Allow adding mx.flash.Event items to EventSequence and facilitate custom trigger calculation. (Thanks Jurgen).
  • Added modulePolicy of type ModulePolicy to FlexStageProcessorRegistry that determines how modules will be handled.
  • Minor documentation fixes. (Thanks Mark).
  • added RouteEventsMetaDataPostProcessor to re-route events from arbitrary objects through the EventBus.

    link

  • Added IApplicationDomainAware and ApplicationDomainAwarePostProcessor to automatically inject the context's application domain in objects that need a reference.
  • Added MethodInvokingFactoryObject to be able to inject method results from other objects.

    link

  • Added util:invoke element as a configuration shortcut for the MethodInvokingFactoryObject.

    link

  • Added support for injecting the application context by using ref="this" in the configuration.

    link

  • Added Maven mojo to generate a flex-config file from an application context (Thanks Ryan).

    link


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 

Spring ActionScript Devoxx slides

ActionScript, Air, Flex, Inversion of Control, Spring ActionScript, Talks No Comments »

Here are the slides of the presentation I did on Spring ActionScript at the Devoxx conference 2009. The sample application will be available in the upcoming 0.9 release, so stay tuned. A pdf version is also available here.

If you have any specific questions you can post them in the comments or check our forum.

Enjoy.


Add to Bloglines - Digg This! - del.icio.us - Stumble It! - Twit This! - Technorati links - Share on Facebook - Feedburner
 
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in