既Adobe Flex的Web和桌面应用程序中工作 [英] Working with both adobe flex web and desktop application

查看:164
本文介绍了既Adobe Flex的Web和桌面应用程序中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Flex开发的应用程序。要求是同时开发一个web应用程序和桌面应用程序。我需要使用数据库来实现此应用程序。我得知有可用于空气应用的本地数据库。

I need to develop an application using flex. The requirement is to develop both a web app and a desktop application. I need to use a database for this application. I learned that there is a local database which can be used for air application.

我不想写出来两个应用程序,因此想重新使用尽可能多的code越好。

I do not want to end up writing two applications, hence would like to reuse as much code as possible.

所以,这里是我的计划是:

So, here is my plan for this:

  1. 请库项目。
  2. 在写这样一类HTTPService在与本地数据库在空气中进行交互。
  3. 在中间层,它会调用正确的服务(的HTTPService或自定义服务)的服务。
  4. 在UI只用上面说的中间层进行数据交互。

任何人都可以提出,如果这是可行的,也可以分享自己的previous经验或有任何其他的想法?

Can anyone suggest if this is feasible or can share their previous experience or have any other idea?

推荐答案

你的做法是正确的。您将需要创建所需的应用程序交谈,然后提供2种不同的实现服务的抽象:为Web应用程序1,这可能是通过AMF使用远程处理,web服务或HTTP服务,1个用于桌面应用程序,这将有一个SQLite的实现。

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.

这方法基本上是策略模式,这是在春天的ActionScript 框架的核心模式的实现。包括的是一个操作API ,这将帮助你创建的接口服务类,因为这些将有异步签名。的好处之一是,这里还创建存根服务实现,所以你可以不依赖于实际实现的Web或桌面客户端测试您的应用程序支持。该框架还提供了不同的配置机制,这样就可以部署应用程序,并提供了在运行时必须使用的策略。

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.

我做了春天ActionScript中的谈话中,我讨论了操作的API: http://parleys.com/#sl=25&st=5&id=1566

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

在code,你的服务code可能是这样的:

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
  }
}

最终的结果是,你的应用程序会谈IUserService和一无所知实际的实现。该实现可配置和在Spring ActionScript中容器管理,自动为你注入。

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.

这篇关于既Adobe Flex的Web和桌面应用程序中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆