如何在 Flex 和 Mate Framework 中使用强类型远程服务对象?
我对 Mate 框架比较陌生,但到目前为止我真的很喜欢我所看到的。我的应用程序大量使用
标签来调用后端的 BlazeDS/Java 服务方法。
然而,令我困扰的是,我必须将数百个远程方法的字符串名称输入到我的 EventMap 中,因为直到运行时才发现错误。让我感到困扰的是,直到请求到达服务器才发现参数结构的问题。此外,所有这些都使得提供模拟数据服务层变得更加困难(并非不可能)。
为了解决这些问题,我为每个具有方法的远程服务目标创建了一个 ActionScript3 接口。这些方法包装了“getOperation”和“send”调用。每个方法都会返回一个异步令牌,就像“发送”调用一样。
但是,我正在努力寻找一种从事件映射中调用这些强类型服务方法的方法。我正在寻找:
1) RemoteObjectInvoker 让方法属性采用 ActionScript 函数/方法而不是字符串远程方法名称。然后调用该方法来获取异步令牌,而不是在 getOperation 中使用字符串名称。
2) 禁止#1——是否有某种类似 MethodInvoker 的标签,但它可以处理异步令牌和结果/失败处理程序?
3) 排除 #2——我想我需要创建一个 Mate 扩展。也许是一个名为“AsyncMethodInvoker”的新标签。
关于最佳行动方案有什么想法吗?如果有必要的话我会抛弃Mate,但我真的很想保留它!
I am relatively new to the Mate framework, but so far really like what I see. My application makes a lot of use of the <RemoteObjectInvoker>
tag to call my BlazeDS/Java service methods on the back-end.
However, it is bothering me that I must enter the string name of hundreds of remote methods into my EventMap because errors are not discovered until runtime. It also bothers me that problems with the structure of the arguments are not discovered until the request hits the server. Furthermore, all of this makes it harder (not impossible) to provide a mock data services layer.
In order to solve these problems, I have created an ActionScript3 interface for each remote service destination that has methods. These methods wrap the "getOperation" and "send" calls. Each method returns an Async token, just like the "send" call does.
However, I am struggling for a way to invoke these strongly typed service methods from my Event map. I am looking for:
1) RemoteObjectInvoker to have the method attribute take an ActionScript function/method instead of a string remote method name. And then to call that method to get the async token rather than use the String name in getOperation.
2) Barring #1 -- Is there some kind of tag like MethodInvoker, but that can handle Async tokens and result/fail handlers?
3) Barring #2 -- I am thinking I'll need to create a Mate extension. Perhaps a new tag called "AsyncMethodInvoker".
Any idea as to the best course of action? I'll dump Mate if I have to, but I really want to keep it!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 API 中一个可用但未记录的类中找到了它。它称为委托调用程序,可以在此处找到:
http ://mate.asfusion.com/api_docs/com/asfusion/mate/actions/builders/DelegateInvoker.html
也已经有一个名为 AyncMethodInvoker 的标签,但 DelegateInvoker 似乎更适合远程服务调用。
Found it in an available, but undocumented class in the API. It is called the delegate invoker and can be found here:
http://mate.asfusion.com/api_docs/com/asfusion/mate/actions/builders/DelegateInvoker.html
There is also already a tag called AyncMethodInvoker as well, but the DelegateInvoker seems more appropriate for remote service calls.