Skip to content

rubyamf/rubyamf-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DESCRIPTION:

Demonstrates the configuration of RubyAMF 2.0 in a Ruby on Rails application and an associated Flex application.

A live version of the application can be found here.

INSTALLATION

  1. Clone the repository and run bundle install then rake db:create, db:migrate and db:seed.

  2. Launch the server on port [port] and fire it up on locahost:[port].

RUBY ON RAILS

  1. Global RubyAMF configurations are found at the bottom of config/application.rb.

  2. Parameter mappings are found in config/routes.rb for adding incoming parameters to the params hash.

  3. In-model class mappings are found in the app/models files.

  4. Using the ActionController#credentials attribute, which contains the :username and :password hash keys set with the Flash RemoteObject.setRemoteCredentials method, with Authogic authentication is shown in the UserSessionsController#create method.

  5. The use of deserialized objects in controllers is demonstrated in the various app/controllers files. Currently, RubyAMF 2.0 has not implemented scaffolding (converting objects to hashes that can be passed to the create, update_attributes, and build methods of ActiveRecord). Thus, all the examples demonstrate using de-serialized class instances in controller methods.

  6. TODO: Testing discussion.

FLEX

Currently due to a (yet un-found) regression in spark.controls.datagroup in SDK 4.5, the Flex application is built using Flex SDK 4.1. You will need to use SDK 4.1 if you want to compile and trace the Flex code.

  1. There are two different Flex applications included in this demo:

    Lite A read-only Flex application that demonstrates the basics of configuring a Flex application for remoting with source code found in app/flex/lite.

    Full A Flex application that demonstrates a complete CRUD application with source code found in app/flex/full.

  2. To configure the projects locally with FlashBuilder:

    1. Import the project from app/flex/.

    2. In Properties/Flex Compiler, configure and select Flex SDK 4.1.

    3. Configure the Properties/Flex Build Path (lite version)

  3. RubyAMF remoting in each of the applications is:

    1. Configured using remoting-config.xml and services-config.xml in the app/flex/config folder and including -services "../config/services-config.xml" in the compliler arguments.

    2. Defined for remote objects in the mxml file business.Services.

      • Note the use a static class variable that ensures that all remote classes are specifically referenced in the Flex application. If you do not do something like this you pull your hair out wondering why you keep getting un-mapped generic Objects back for certain classes when you are testing remote calls after setting up the classes. The reason this happens is you have not yet used the class anywhere and thus the compiler ignores it. Thus, this useful little hack.

LITE DEMO

  1. RubyAMF remote object configuration is found in the demolite.business.Services class.

  2. Mapped Models and Value Objects corresponding to remote classes are defined in the demo.models and demo.vos packages (see ruby classes for corresponding client package mapping definition).

  3. All remote calls are made and handled in the demolite.views.MainUI component.

FULL DEMO

Note this version is not fully functional yet.

  1. The full Flex application uses the Mate MVC framework for Flex. Unless otherwise noted, all of the classes discussed below are in the com.rubyamf.demo package.

  2. RubyAMF remoting is implemented in the LocalEventMap classes in the maps package in the AsyncMethodInvoker tag.

  3. Mapped Models and Value Objects corresponding to remote classes are defined in the models and vos packages (see corresponding ruby classes for associated in-model mapping definition).

  4. Managers (Mate’s terminology for Controller in MVC) handle all view interactions in their execute method. All remote results are handled in the callResult and callFault methods. Placing breakpoints at the first line of each of these methods will allow you to easily trace how calls are formulated and their results.

    In each manager, see the remoteCall method to see how call parameters are configured and the asynchronous call is dispatched to the corresponding LocalEventMap.

  5. The delegate class com.fosrias.library.business.RemoteService is responsible for the raw asynchronous calls. Placing breakpoints at the first line of the call, onResult and onFault methods will allow you to easily trace how the raw remote calls are configured and their raw results.

  6. The Flex application incorporates a debug console that you can open and close by dragging the white handle at the bottom of the application. Among other things, it displays remote call related timestamps.

  7. The managers.UserSessionsManager execute method demonstrates setting remote credentials.

  8. Tracing shorcuts:

    • Review business.Services class to see how the RemoteObject tags are configured for their corresponding controllers.

    • In all managers, except managers.MainManager, place break points at the beginning of the execute, remoteCall, callFault, and callResult methods to trace how user interaction translates to remote calls and how those calls are handled upon return.

    • In the com.fosrias.library.business.RemoteService class, place breakpoints at the beginning of the call, onFault, and onResult methods to trace raw call configuration and

LICENSE:

(The MIT License)

Copyright © 2011 Mark W. Foster

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A set of demo Ruby on Rails/Flex applications using RubyAMF 2.0

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published