Speaking at the Flex on Java eXchange in London

ActionScript, Air, Conferences, Flex, Spring ActionScript, Talks No Comments »

I’ll be speaking at the first Flex on Java eXchange in London on June 16th. My talk will be an introduction to the Spring ActionScript framework, along with other presentations on Flex and Java connectivity and enterprise Flex development.

From the Skills Matter website:

Skills Matter is pleased to organise the first Flex on Java eXchange. This Annual Flex and Java conference brings together the leading experts on RIA, Flex, Java, Spring and Grails with London’s JEE and web development community, for an informal day of deep technical insight and friendly discussion.

Come learn about Java and Flex integration technologies, MVC frameworks, tools, plugins, best practices and innovative ideas from the creators of those technologies and from the industry’s innovators.

In case you’re in the neighborhood, be sure to join!

More info: http://skillsmatter.com/event/java-jee/flex-on-java-exchange-2010


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

Spring ActionScript at the Devoxx Conference

ActionScript, Conferences, Flex, Spring ActionScript 1 Comment »

devoxxOn November 18th, I’ll be doing a presentation on Spring ActionScript at this year’s Devoxx conference in Antwerp, Belgium. The conference formerly known as JavaPolis is the biggest European (Java) Developers conference.This 5 day conference has an impressive speaker list each year, lots of quality content and is extremely cheap compared to other conferences. So even with the economic crisis, there is no reason not to be there…

Here’s the abstract of my presentation (link):

Spring ActionScript is an offshoot of Java Spring and brings Inversion of Control to the Flash Platform. Primarily focusing on Flex and AIR development, you’ll learn how this framework can be used to build testable and maintainable applications. We’ll take a look at the different kinds of configuration options and will also see how the minimal MVCS infrastructure fits into an application.

If you’re there and are interested in Flex development, then this session is for you.

I’m currently preparing samples and slides, so if you have anything in particular you would like to see covered, feel free to leave something in the comments. Or if you are attending the conference and would like to meet up, leave a comment as well.

Looking forward to seeing you there!


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

Spring ActionScript at FlexCamp 2008 Belgium

ActionScript, Conferences, Flex, Inversion of Control, Spring ActionScript, Talks 7 Comments »

Here's a rundown of the presentation I did on Spring ActionScript at the FlexCamp in Antwerp, Belgium. In 40 minutes I tried to cover the basic theory on Inversion of Control, Dependency Injection and the Spring ActionScript project in general. We then dove right into some code we've been writing for an enterprise app that extensively uses Spring ActionScript's IoC container.

Spring ActionScript
View SlideShare presentation or Upload your own. (tags: flash air)

Since time was limited (or in case you were not there), I'll run through the key features of the code I ran through and try to give some more explanation.

Targeting BlazeDS via remoting and messaging

Whenever I'm hitting a backend, I try to have the endpoints externally configured. This allows me to switch between different endpoints - different test or production servers for instance - just by specifying the ip and port in an external properties file. This means that you don't have to specify any compiler arguments that point to the services-config.xml or messaging-config.xml files.

You can set up a channelset and a consumer with the following code. Notice the "method-invocation" element that allows you to execute a method on the object you create. This allows us to directly pass in a channel to the channelset. (In case you are interested, the method-invocation element is preprocessed to an instance of MethodInvokingFactoryObject)

CODE:
  1. <object id="channelSet" class="mx.messaging.ChannelSet">
  2.     <method-invocation name="addChannel">
  3.         <arg>
  4.             <object id="streamingAMFChannel" class="mx.messaging.channels.StreamingAMFChannel">
  5.                 <property name="url" value="http://${host}:${port}/${context-root}/messagebroker/streamingamf" />
  6.             </object>
  7.         </arg>
  8.     </method-invocation>
  9. </object>
  10.  
  11. <object id="eventMessageFeedConsumer" class="mx.messaging.Consumer">
  12.     <property name="destination" value="eventMessageFeed" />
  13.     <property name="channelSet" ref="channelSet" />
  14. </object>

Have you noticed the placeholders "${...}" for the host, port and context-root? These are loaded from a properties file that is referenced in the application context file.

Here's the external properties file:

CODE:
  1. host=192.168.2.134
  2. port=8081
  3. context-root=server-web

And here's the import declaration in the application context xml file:

CODE:
  1. <property file="application-context.properties.txt" />

Of course, you can also specify remote objects in the application context. Here's an example:

CODE:
  1. <object id="remoteObject" class="mx.rpc.remoting.mxml.RemoteObject" abstract="true">
  2.     <property name="endpoint" value="http://${host}:${port}/${context-root}/messagebroker/amf" />
  3.     <property name="showBusyCursor" value="true" />
  4. </object>
  5.  
  6. <object id="userRemoteObject" parent="remoteObject">
  7.     <property name="destination" value="userService" />
  8. </object>

Notice that we actually split this up into 2 objects. The first object is an abstract remote object which we use as a parent object for concrete remote objects. Notice the "abstract=true" and the "parent=remoteObject" properties on these objects.

MVCS support

As part of the project we are working on, we also starting working on some experimental MVCS support. If you haven't heard of MVCS, be sure to check out at Joe Berkovitz' blog.

What we provide so far are some interfaces and abstract base classes for services, operations and commands. Let's look at some code for services and operations.

Here's an interface for a user service, which defines a "getAll" method.

CODE:
  1. public interface IUserService {
  2.   function getAll():IAsyncOperation;
  3. }

We now want to create a concrete service for that interface. For instance, this could be a remote object enabled service. For that, we have a abstract remote object service base class.

CODE:
  1. public class UserRemoteObjectService extends AbstractRemoteObjectService implements IUserService {
  2.        
  3.     public function UserRemoteObjectService(remoteObject:RemoteObject) {
  4.         super(remoteObject);
  5.     }
  6.  
  7.     public function getAll():IAsyncOperation {
  8.         var token:AsyncToken = remoteObject.getAll();
  9.         token.addResponder(new Responder(onGetAllResult, onGetAllFault));
  10.         return getOperation("getAll");
  11.     }
  12.        
  13.     private function onGetAllResult(event:ResultEvent):void {
  14.         getOperation("getAll").dispatchEvent(new AsyncOperationResultEvent(event.result));
  15.     }
  16.        
  17.     private function onGetAllFault(event:FaultEvent):void {
  18.         getOperation("getAll").dispatchEvent(new AsyncOperationErrorEvent(event.fault.faultDetail));
  19.     }
  20. }

For testing purposes, we could also create a mock user service:

CODE:
  1. public class UserMockService extends AbstractService implements IUserService {
  2.    
  3.     private static var logger:ILogger = Log.getLogger("UserMockService");
  4.    
  5.     public function UserMockService() {
  6.         logger.warn("Mock user service instantiated.");
  7.     }
  8.        
  9.     public function getAll():IAsyncOperation {
  10.         var users:ArrayCollection = new ArrayCollection();
  11.        
  12.         var user1:User= new User();
  13.         user1.name = "John";
  14.         users.addItem(user1);
  15.            
  16.         var user2:User= new User();
  17.         user2.name = "Peter";
  18.         users.addItem(user2);
  19.            
  20.         setTimeout(onGetUsersResult, Math.random()*3000, users);
  21.           CursorManager.setBusyCursor();
  22.            
  23.         return getOperation("getAll");
  24.     }
  25.        
  26.     private function onGetUsersResult(users:ArrayCollection):void {
  27.         var operation:IAsyncOperation = getOperation("getAll");
  28.         operation.dispatchEvent(new AsyncOperationResultEvent(users));
  29.         CursorManager.removeBusyCursor();
  30.     }
  31. }

We can now define these objects in the application context as follows:

CODE:
  1. <object id="userService" class="UserMockService"/>
  2.  
  3. ... or ...
  4.  
  5. <object id="userService" class="UserRemoteObjectService">
  6.     <constructor-arg>
  7.         <object id="userRemoteObject" parent="remoteObject">
  8.             <property name="destination" value="detectorGroupService" />
  9.         </object>
  10.     </constructor-arg>
  11. </object>

You can now use one of these implementations by calling the getAll() method. Make sure that you type the service to IUserService and not to a concrete implementation:

CODE:
  1. public function getUsers():void {
  2.     var operation:IAsyncOperation = _userService.getAll();
  3.     operation.addEventListener(AsyncOperationEvent.RESULT,
  4.         function(e:AsyncOperationResultEvent):void {
  5.             logger.info("Users loaded successfully.");
  6.             var users:ArrayCollection = ArrayCollection(e.result);
  7.         }
  8.     );
  9.     operation.addEventListener(AsyncOperationEvent.ERROR,
  10.         function(e:AsyncOperationErrorEvent):void {
  11.             logger.error("An error occurred when loading the users: " + e.fault);
  12.         }
  13.     );
  14. }

To implement your own services, you don't necessarely need to extend the AbstractService or AbstractRemoteObjectService class. These base classes just provide you with some convenient methods, like "getOperation" that creates a generic AsyncOperation for you.

You could of course also create an own implementation of the IAsyncOperation interface for your specific needs. For instance, you could create a GetAllUsersOperation that has all the logic for invoking a method on a remote object and that also deals with the result and fault handling of the remote call.

Presentation Model and Autowiring

I mentioned that we were using Presentation Model to seperate our UI state and logic from our views. This has worked surprisingly well for us and it certainly allows us to write better tests (for the presentation model). If you are new to Presentation Model and Presentation Patterns in general, I really recommend taking a look at the writings by Martin Fowler and Paul Williams.

Seperating logic and state from the view is one thing, but of course in order to use this combination you have to provide your view with an instance of a presentation model at some point. It's easy to read a presentation model from an application context, but injecting it is not that easy. Especially if your view component is nested a few levels deep inside other view components, it can be tricky to pass in the instance of the presentation model. We started of by passing in the presentation models from the root of the application through all components until we had finally reached the component that needed the presentation model. Needless to say that this approach required us to write a lot of extra code that really wasn't supposed to exist...

Enter custom metadata and SystemManager! Using the systemManager, you can listen to events that get fired when view components are added to the stage. This was exactly what we needed to know. Combined with a custom metadata element [Autowired], we now support dependencies being injected into views automatically.

Here's how it works. Suppose you have a UserPanel and a UserPanelPresentationModel. In you UserPanel you'll have a reference to that presentation model so you can actually use it in your view component. By adding the extra [Autowired] metadata you can mark a property (the presentation model) as a property that needs to be autowired when the view is created and added to the stage.

In your UserPanel.mxml file, you declare the presentation model as follows.

CODE:
  1. [Bindable]
  2. [Autowired]
  3. public var presentationModel:UserPanelPresentationModel;

Now all we need to do is listen to the ADDED event on the systemManager and write some glue code that injects the presentation models defined in the application context into the view components. This code goes in your main application file.

CODE:
  1. import mx.utils.DescribeTypeCache;
  2. import mx.utils.DescribeTypeCacheRecord;
  3.  
  4. ...
  5.  
  6. systemManager.addEventListener(Event.ADDED, onAdded);
  7.  
  8. ...
  9.  
  10. private function onAdded(event:Event):void {
  11.   var autowiredObject:Object = event.target;
  12.   var typeInfo:DescribeTypeCacheRecord = DescribeTypeCache.describeType(autowiredObject);
  13.  
  14.   for each (var metaDataNode:XML in typeInfo.typeDescription..metadata) {
  15.     if (metaDataNode.attribute("name") == "Autowired") {
  16.       var propertyNode:XML = metaDataNode.parent();
  17.       var property:String = propertyNode.@name.toString();
  18.       var objectName:String = property;
  19.       var autowireByType:Boolean = true;
  20.  
  21.       for each (var arg:XML in metaDataNode.arg) {
  22.         if (arg.attribute("value") == "byName") {
  23.           autowireByType = false;
  24.         }
  25.       }
  26.                        
  27.       if (autowireByType) {
  28.         var clazz:Class = ClassUtils.forName(propertyNode.@type.toString());
  29.         var objectNames:Array = m_applicationContext.getObjectNamesForType(clazz);
  30.         if (objectNames.length == 1) {
  31.           objectName = objectNames[0];
  32.         }
  33.       }
  34.                        
  35.       autowiredObject[property] = m_applicationContext.getObject(objectName);
  36.     }
  37.   }
  38. }

You may have noticed that we do some extra checks on the attributes of the Autowired metadata. This is because the code above support autowiring by type (the default) and autowiring by name. Autowiring by type means that we will look in the context for objects that are of a certain type. If we find one, we will inject it. Autowiring by name means that we will look for objects in the context that have a certain id.

You can set up autowiring by name as follows:

CODE:
  1. [Bindable]
  2. [Autowired(mode="byName")]
  3. public var presentationModel:UserPanelPresentationModel;

Conclusion

I hope you now got a good understanding of some of the key features, best practices and what we are doing with Spring ActionScript in general. Don't hesitate to join our forum or the team if you want to help us out. We are really looking for more people to join, especially for working on samples and documentation.

http://forum.springframework.org/forumdisplay.php?f=60


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

2M08: Aral Balkan

Conferences No Comments »

[10.32] Aral is about to start. My laptop is running out of juice, so we'll see how far we get.

"Ruling the Web"

He brought a flying pig or so. He needs 12 volunteers. The Belgian crowd is frozen to their seats. I can't go of course, I need to blog ;-) He handing out post-it notes. He wants people to write down interesting things and paste the notes on the walls.

He shot his flying pig into the audience.

Showing FutureSplash Animator.

Snakes on a plane, hehehe. angryalien.com

32 Things every flasher should know. Flash Gordon FTW!

"Flash is 99% bad", Mr. Nielsen or was it the lama.

Skip intro, Flashturbation is bad.

[10.43] Going through the 32 things. Talks about the evolution of the ActionScript language.

My battery is about to die. Sorry guys.


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

2M08: Keynote with Serge Jespers and Jason Levine

Conferences, Flash No Comments »

I'm sitting at the keynote of Multi-Mania. Serge and Jason are talking about the history of Flash. Actually, Serge is talking to the crowd and Jason is adding some sound effects. They are quite a funny duo ;-)

[9.40] Serge is talking about The Open Screen Project.

Flash Player 10 now. Let's talk new features:
- custom filters and effects: Pixelbender, scripting language to write your own filters. You can use these custom filters in across application...Photoshop, Flash
- Rich text layout: Hebrew
- enhanced video support

MAKE SOME NOISE: The campaign by Andre Michelle. Serge is showing some examples made by the community. An equalizer built in Flash. Oldskooll Atari tunes interpreted at runtime.

Serge shows some more demos. Very performant filtering. And a 3D demo of Doom, awesome!

New services by Adobe:
- Scene7 imaging
- SHARE
- Pacifica
- Cocomo

More info on Pacifica: Voice over IP for Flash. Serge shows the Adobe Directory, internal tool to find colleagues. Serge is available! ;-) Adobe Directory is an AIR application that is connected to the Pacifica server and is able to call Cell Phones. Live demo...the phone actually rings! Applause...

Adobe Flash CS4: Demo time. Don't click that button Serge (he has a paper with instructions about what not to do ;-) )! He creates a motion tween, applause! Now moves the animation line. Oh no, Serge is going to click the button...I saw that! My god, this is stand-up comedy, hehe

Serge is showing 3D support. Rotating text in multiple axes. Jason should be the voice for movie trailers. "But wait! There's more".

Serge is connecting some balls. Inverse Kinematics FTW!!! This is awesome.

[10.10] Jason now takes over. He's hilarious, hahaha. Will be showing some new features. Talking about some new ways to work with video. He's very excited.

He shows OnLocation perhaps running on a Macintosh. Capture video and add relevant metadata. The metadata stays with the files troughout the production process. Now shows Premiere Pro. Speech Transcription, Speech to Text. Explains how the subtitles will be searchable. Scrubs the timeline, text is highlighted.

Jason also has a list. Don't show this next thing ;-)

Now shows SoundBooth. Editing multiple tracks. Synchronizes the changes between SoundBooth and Premiere.

Showing differences in loudness. Equalize volume levels. He's really good at sound effects. He spent a lot of time at the dark room...and still. "Who's the Gorilla, he's my brother!".

[10.21] Device Central now. Emulate playback of any type of content on mobile devices. Exports presets to After Effects. "You click render and.... you're done!"

Serge is taking over. MAX 2008 Europe, 1-4 December 2008 in Milan, Italy.

Applause, applause, applause...

...The End...


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