Working with both adobe flex web and desktop application

╄→尐↘猪︶ㄣ 提交于 2019-12-02 09:13:48

Your approach is correct. You will need to create an abstraction of the services you want the application to talk to and then provide 2 different implementations: 1 for the web app, which might use remoting via AMF, webservices or http services and 1 for the desktop app, which will have a SQLite implementation.

This approach is basically an implementation of the strategy pattern, which is a core pattern in the Spring ActionScript framework. Included is an Operation API that will help you with creating the interfaces for the service classes, as these will have asynchronous signatures. The nice things is that there is also support for creating stub service implementations so you can test your application without relying on an actual implementation for the web or the desktop client. The framework also provides different configuration mechanism, so that you can deploy your application and provide the strategy that must be used at runtime.

I did a talk on Spring ActionScript in which I discuss the Operation API: http://parleys.com/#sl=25&st=5&id=1566

In code, your service code might something like this:

// interface
public interface IUserService {
  function getUserByID(id:String):IOperation;
}

// implementation A
public class UserServiceA implements IUserService {
  public function getUserByID(id:String):IOperation {
    // return implementation specific operation
  }
}

// implementation B
public class UserServiceB implements IUserService {
  public function getUserByID(id:String):IOperation {
    // return implementation specific operation
  }
}

The end results is that your application talks to IUserService and knows nothing about the actual implementations. The implementations can be configured and managed in the Spring ActionScript container and injected automatically for you.

Florian F

It's a good start. You will need also to isolate platform dependant code.

See this post for some details:

File() FileStream in web app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!