Posts Tagged ‘ Swiz ’

Swiz Framework for Mobile Development (Source Example)

Source for Android/ iOS/ Blackberry Mobile App Universal-Currency.
Developed with Flex 4.5.1 SDK and AIR 2.7 SDK

The project does currency conversion, using HTTPService via SwizDAO Framework

Check the code base:

Dynamic Injection on runtime using BeanFactory

Met with requirement to inject object dynamically at runtime based on Push Message received.

Had a bit hard time finding solution, unusual with Swiz Framework.
Thought of sharing my experience here..
Step 1: In swiz Context assign the bean factory to your Bean Class

messenger.beanFactory = this.beanFactory;

Step 2:
In your bean class, Implement Interface IBeanFactoryAware
public class NativeMessenger implements IBeanFactoryAware

Step 3:
To Satisfy the implementation add the below code:
private var _beanFactory:IBeanFactory;
public function set beanFactory( beanFactory:IBeanFactory ):void{
_beanFactory = beanFactory;
Step 4:
Got access to Beanfactory
public var dynamicDAO:AbstractDAO;
protected function consumeHandler(event:MessageEvent =null) : void
var daoName:String = event.message.headers[“dynamicdao”];
dynamicDAO = _beanFactory.getBeanByName(daoName).source as AbstractDAO;

Now the dynamicDAO is assigned with the bean dynamically based on the consumer Message.

Project: Swiz DAO

Libraries Used:  Swiz, AS3Signals and FoomongerSwizFramework.
To create GenericDAO framework, like IBM Generic DAO (Java /Spring/ Hibernate)
About GenericDAO:
DAO is the Object which manages to perform CRUD Operation and other Common
Operations to be done over a ValueObject ( known as Pojo in Java ).
GenericDAO is a reusable DAO class which can be used generically.

In IBM GenericDAO, to add a new DAO, the steps to be done is simply,
  1. Add a valueobject (pojo).
  2. Add a hbm.xml mapping file for the valueobject.
  3. Add the 10-line Spring configuration file for the DAO.
Similarly, in AS3 Project Swiz DAO. We want to attain a similar feet of achievement.
Client Side GenericDAO model:
As we were working on a Client Side language, also we should be managing a persistent object Collection (for every valueObject) .
<swiz:Prototype name=”personDAO”
constructorArguments=”{[‘person’,personProcessor]}” type=”{AbstractDAO}”
Added, How it works in Github: DI Mechanism Link

Generic DAO in AS3

Built an AS3 Project to Work with GenericDAO using Swiz and AS3Signals

The project was inspired by Java Spring Framework:
IBM Generic Dao

The project uses the benefits of DI provided by Swiz 1.0.
The Deferred Instantiation of Swiz builds DAO Object only when [Inject] keyword is used.

Also, uses the latest Spark SkinnableComponent Framework for the View Part with Passive View.

The Source can be downloaded from SwizDAO Git
The below is the code from Swiz Context for a DAO Object:

<swiz:Prototype name=”taskDAO” constructorArguments=”{[‘task’,taskProcessor]}” type=”{AbstractDAO}” singleton=”true”/>

Update Info :