Prana Framework 0.6 Released

ActionScript, Flex, Prana No Comments »

I'm pleased to announce that the Prana Framework 0.6 release is now available.

Prana

Download | API Documentation | Changelog

In this release the following remarkable changes and additions have been made:

  • the IoC container is now ActionScript 3 compatible
  • command factories for Cairngorm's FrontController
  • more PureMVC experimenting

ActionScript 3 compatibility

We got lots of reactions from people who wanted to use Prana in ActionScript projects but couldn't because Prana relied heavily on some Flex framework specific classes. Well, we have now resolved this issue by completely refactoring the IoC container and parser so that all Flex dependencies are removed. As a result we now have 2 different application context implementations. The first one is the standard XMLApplicationContext which is aimed to be ActionScript 3 compatible. The second one is the FlexXMLApplicationContext which actually extends the XMLApplicationContext and adds support for Flex specific classes like ArrayCollection. The application context and the XML parsers are now configurable with XML node parsers and reference resolvers so it would theoretically be possible now to extend the XML dialect with your own tags and have them parsed by the application context.

Command Factories for Cairngorm's FrontController

In order to reach maximum flexibility in setting up commands and business delegates, we have introduced the option to create custom command factories that plug into Cairngorm's FrontController. The FrontController actually allready acts as a command factory since it takes an event name, looks up its corresponding command and instantiates that command. We have abstracted that behavior so that it is now possible to write a custom implementation of a command factory and register it with the FrontController. This is very handy when you want commands to handle different implementations of business delegates without the need to instantiate a business delegate directly in a command, making it hard to test and change.

What follows is an example of a command that is configured with a business delegate at runtime via the IoC container.

Actionscript:
  1. public class AuthenticateUserCommand extends AbstractResponderCommand {
  2.   override public function execute(event:CairngormEvent):void {
  3.     super.execute(event);
  4.     var e:AuthenticateUserEvent = event as AuthenticateUserEvent;
  5.     IUserDelegate(businessDelegate).authenticate(e.username, e.password);
  6.   }
  7. }

XML:
  1. <object id="frontController" class=“org.pranaframework.cairngorm.control.CairngormFrontController">
  2.   <method-invocation name="addCommandFactory">
  3.     <arg>
  4.       <object id="userDelegateFactory" class="org.pranaframework.cairngorm.business.BusinessDelegateFactory">
  5.         <property name="delegateClass" value="com.domain.business.UserRemoteObjectDelegate" type="Class" />
  6.         <property name="service" ref="userService"></property>
  7.       </object>
  8.     </arg>
  9.     <arg>
  10.       <array>
  11.         <value type="Class">com.domain.commands.AuthenticateUserCommand</value>
  12.         <value type="Class">com.domain.commands.AuthenticateSSOUserCommand</value>
  13.       </array>
  14.     </arg>
  15.   </method-invocation>
  16. </object>

Notice that we are registering the command factory with the FrontController via the "method-invocation" element. This is a new XML element that was introduced this release and that is actually preprocessed to a MethodInvokingFactoryObject.

Further, we are configuring the FrontController with a BusinessDelegateFactory which is available in the Prana Cairngorm extensions. We need to specify a name of the business delegate class we want the factory to create and also pass in a reference to the appropriate service. We also need to make clear to the FrontController what commands need to be created via this factory. As you can see we added 2 types of commands, a AuthenticateUserCommand and a AuthenticateSSOUserCommand.

When the FrontController receives an event, it will look up the corresponding command (just like it works in Cairngorm), but instead of creating a command via its class name on the fly, the controller will lookup the command factory it needs to use and then use that factory to create the command. In the example, a command will be created and a business delegate will be injected.

More PureMVC Experimenting

The Prana-PureMVC team has been playing around with some new ideas around better integration between the two frameworks. Some of the key changes and improvements are:

  • changes in internal implementation which are not so much visible from the end user standpoint, but can potentially have some impact on wider prana/puremvc acceptance
  • new feature which enables significant reduction of name constants during registration, retrieval and removal of puremvc elements (proxies, mediators and commands)
  • new feature which enables additional and different startup idiom with which prana can be initialized late instead of up front as it had to be before

For a full and in depth discussion on these changes, please see the text file at "prana-sample-anotherArch101Demo/resources/docs/pranaPureMvcIntegration-FurtherDevelopment.txt".

Conclusion

We hope you enjoy this release and we are always interested to hear from you. So if you have any comments or suggestions, be sure to join our forum at http://prana.herrodius.com.

Hope you 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
 

Prana Framework 0.5 Released

ActionScript, Flex, Inversion of Control, Prana 5 Comments »

I'm pleased to announce that the Prana Framework 0.5 release is now available.

Prana

Download | API Documentation | Changelog

In this release we further focused on bringing the core Inversion of Control container API closer to that of the well known Spring API. In addition, the release also contains the following:

  • an XSD for editing object definition XML files
  • application context classes that extend the object factory
  • support for external property files to be used in an application context
  • support for multiple configuration files
  • updated support for PureMVC 2.0.3
  • updated samples
  • several new utility methods and enhancements to the existing ones
  • complete new build system and project layout
  • setup wizard to configure prana inside eclipse
  • minor bugfixes

Using the XSD

The XML Schema Definition (XSD) is a useful aid in creating object definition XML files. It has the advantage that your object definition XML files will be validated as you create them and a good XML editor will also give you code hinting on the available elements and attributes. In order to use it, make sure you are using an XML editor that has XSD support and place the following in your XML file:

XML:
  1. <objects xmlns="http://www.pranaframework.org/objects"
  2.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.          xsi:schemaLocation="http://www.pranaframework.org/objects http://www.pranaframework.org/schema/objects/prana-objects-0.5.xsd ">

Note: There is a free XML editor available for Eclipse in the Eclipse Europa release. See the Web Tools Platform for more details.

The Application Context

As of this release, we have introduced the concept of the application context. This is actually an extension class of the object factory that offers additional functionality. As a result, we recommend updating your code to use the XMLApplicationContext instead of the XMLObjectDefinitionsLoader.

What follows is an example of how to use the XMLApplicationContext. All samples in this release have been updated to also use the XMLApplicationContext.

Actionscript:
  1. // load a single 'applicationContext.xml' config
  2. var applicationContext:XMLApplicationContext = new XMLApplicationContext("applicationContext.xml");
  3. applicationContext.addEventListener(Event.COMPLETE, onApplicationContextComplete);
  4. applicationContext.load();
  5.  
  6. // load multiple config files
  7. var applicationContext:XMLApplicationContext = new XMLApplicationContext(["applicationContext-1.xml", "applicationContext-2.xml"]);
  8. applicationContext.addEventListener(Event.COMPLETE, onApplicationContextComplete);
  9. applicationContext.load();

Note: There is no support for the <import> tag at this moment.

External Properties

Is some scenarios it might be useful to store certain properties of the config XML file externally so that you can easily change them without having to go through the entire config. The application context now allows you to specify external properties in separate Ant like *.properties files. You can then define property placeholders in your config files with the ${...} syntax.

Here's an example. Note that the path to the *.properties file is relative to the path of the config file.

XML:
  1. // in a file called strings.properties
  2. s1=First string
  3. s2=Second string
  4.  
  5. // in the config file
  6. <objects>
  7.  
  8.   <property file="strings.properties" />
  9.  
  10.   <object id="string1" class="String">
  11.     <constructor-arg value="${s1}"/>
  12.   </object>
  13.  
  14.   <object id="string2" class="String">
  15.     <constructor-arg value="${s2}"/>
  16.   </object>
  17.  
  18. </objects>

Building Prana and Setting up your Eclipse Environment

The way the Prana source tree is structured has changed drastically. The new project layout now allows us to create separate branches of the main source tree, the samples and the additional support projects. If you plan on building the sources yourself, please see the prana-install project and the documentation (prana-install/resources/docs/installation-instructions.txt) that contains instructions on how to set it up.

Here's the relevant part of the docs to give you a head start.

- Checkout "prana-install" project from https://prana.svn.sourceforge.net/svnroot/prana/prana-install/trunk
- Checkout other projects that you want to have in your Flex Builder workspace. You don't have to checkout all of them, but you must keep original names ("prana-main", "prana-main-tests" etc.) since a build system relies on them:
https://prana.svn.sourceforge.net/svnroot/prana/prana-main/trunk
https://prana.svn.sourceforge.net/svnroot/prana/prana-main-tests/trunk
https://prana.svn.sourceforge.net/svnroot/prana/prana-sample-cairngormStore/trunk
https://prana.svn.sourceforge.net/svnroot/prana/prana-sample-movieApp/trunk
https://prana.svn.sourceforge.net/svnroot/prana/prana-sample-puremvcArch101Demo/trunk
- Open main build file from "prana-install" project (prana-install/ant/build.xml) and run and "setup-projects" target.
- Answer to questions in GUI wizard.
- Wait until Flex Builder finishes building a workspace.
- That's it. Your workspace should now be fully configured.

To check if everything is set up correctly, you can try some of targets from each project's main build file located in "[project-name]/ant/build.xml".

For example:
- prana-main/ant/build.xml -> "release" target
- this target creates release archives in "prana-main/antbuild/release"
- prana-main-tests/ant/build.xml -> "tests-run" target
- this target runs tests and creates HTML report in "prana-main-tests/antbuild/reports/tests/html"
- prana-sample-[sample-name]/ant/build.xml -> "run-defaultApp" target
- this target runs the sample in a configured browser

If you don't want to checkout the sources from SVN, you can download the prana-projects-0.5.zip file that contains all projects. It is then possible to import those projects in your Eclipse environment. Please see the readme file that comes with the prana-projects-0.5 distribution for more info.

Conclusion

We hope this release will prove valuable to all Flex developers out there. Whether you're just using Prana's utilities, the Cairngorm or PureMVC extensions or the full blown IoC container, there definitely will be something helpful for you.

Don't hesitate to get in touch with the development team and other Prana users via our mailinglist. We appreciate all feedback, be it questions, comments, new ideas or code contributions.

Hope you 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
 

Speaking at the Dutch Flex Usergroup

ActionScript, Conferences, Flex, Prana, Talks No Comments »

FlugrJust a quick note to let you know that I'll be giving a presentation on Prana at the Dutch Flex Usergroup called Flugr on the 13th of June. So if you're in the neighborhood (Utrecht) and would like to meet, feel free to visit the event.




The following sessions will be given:

- Benjamin Dobbler & Stephan Janssen: The creation of Parleys
- Nicolas Lierman: Advanced Flex
- myself: The Prana Framework

For more info, please visit the Flugr website at http://www.flugr.nl/


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

Do DDD Repositories and Flex make sense?

ActionScript, Air, Domain-Driven Design, Flex 3 Comments »

I have been thinking about some of the concepts and patterns described in the Domain-Driven Design book and how they could be implemented in a Flex or AIR environment.

One thing that interests me in particular is the use of a Repository as a container for Domain Objects. In short, a Repository is responsible for fetching, persisting and manipulating objects. Its intent is to shield the client from the implementation details of the data storage or the remote services that are used to get and manipulate objects.

However, there seems to be a fundamental problem in creating an ActionScript implementation. Since remote services are handled asynchronously, it is impossible to create a Repository as it is originally described by Eric Evans.

Here's a snippet of a post (by myself) on the DDD list:

Would it be correct to assume that repositories don't make much sense if you are dealing with async remote calls? Or should I say that async data fetching is a problem currently not addressed by DDD? Quoting Eric Evans in the DDD book (p. 157): "The client of a REPOSITORY should be given the illusion that the objects are in memory.". That being said, it is no problem to call a method on a repository and have it return the objects immediately if the objects are in memory. But, if the objects are sent back asynchronously, the whole point of encapsulating that behavior is gone since the client needs to "listen" for a response on the repository. So it knows about the implementation details of the repository.

As a reply, someone offered to try to make the call synchronous by waiting for a result. Although I think that might work, for instance by entering a loop until the result is received, I'm not completely sure as I haven't tried this. Here's my reply:

The problem I see is that the UI will be locked/frozen until the response is received because the code runs in a single thread within the Flash player. That means it won't be possible to create a (animated) loading screen to give the user some visual feedback. This would probably not be a problem with remote calls that return a small amount of data and a fast remote connection, but it certainly will be a (usability) problem if the connection is slow or if we are loading large chunks of data.

Conclusion

So my conclusion at this moment is that implementing Repository in Flex doesn't make much sense since the client still needs to know about some of the technical details of the implementation. Locking the UI would most certainly lead to usability problems (if it would even be possible). On the other hand, a Repository could be perfectly implemented as intended in an AIR application that uses an embedded SQLite database and synchronous calls, but the UI would also be locked.

Thoughts?


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

Flex Builder 3 on Vista: Trial Expired Solved

Flex 2 Comments »

There seem to be some problems with the Flex 3 licenses. Matt Chotin posted some info here and here.

However if you are installing the trial version, the info provided about removing the license.properties file on Windows is not correct if you're on Vista.

The correct path is C:\Users\[USERNAME]\AppData\Local\VirtualStore\ProgramData\
Adobe\Flex\license.properties

After you removed this file, restart Eclipse and you'll be prompted with the license window that states you can continue the 60 day trial.

Have fun!


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 Login