使用 adobe flex web 和桌面应用程序 [英] Working with both adobe flex web and desktop application

查看:31
本文介绍了使用 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.

我不想最终编写两个应用程序,因此希望尽可能多地重用代码.

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

所以,这是我的计划:

  1. 制作一个图书馆项目.
  2. 编写一个类似 httpservice 的类,用于在空中与本地数据库交互.
  3. 负责调用正确服务(httpservice 或自定义服务)的中间层.
  4. UI 仅与上述中间层交互以获取数据.

任何人都可以建议这是否可行,或者可以分享他们以前的经验或有任何其他想法吗?

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

推荐答案

你的方法是正确的.您将需要创建您希望应用程序与之通信的服务的抽象,然后提供 2 个不同的实现:1 个用于 Web 应用程序,它可能通过 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.

这种方法基本上是策略模式的实现,策略模式是Spring ActionScript框架中的核心模式.包括一个 Operation 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.

我做了一个关于 Spring 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

在代码中,您的服务代码可能是这样的:

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天全站免登陆