Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Single Proxy to Web Service with Multiple VO objects  (Read 13102 times)
DrFooMod2
Newbie
*
Posts: 6


View Profile Email
« on: March 26, 2009, 09:01:55 »

The way I understand it, I should have a single proxy per VO.  Say for example an XML web service has three method calls.  Am I expected to create a Proxy for each method call and subsequent return value?  Wouldn't it make more sense to have a single Proxy to a single web service?  Could I have a single VO that has constituent VOs with method return data?

My client is a j2me app on a BlackBerry.  I'm using JSR 172 to generate stubs and handle to parsing, etc.  The service is a WCF web service written in C#.

Thanks.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: March 26, 2009, 09:37:10 »

I'm not sure exactly where you got that idea, but it's not quite right. You *can* have a one to one relationship or a one to many. The only difference is that the data property of the Proxy will either be a single VO or an array / collection type. It's all up to you and your data.

-=Cliff>
Logged
DrFooMod2
Newbie
*
Posts: 6


View Profile Email
« Reply #2 on: March 26, 2009, 12:52:16 »

To answer your question, this is where I got the idea:

http://forums.puremvc.org/index.php?topic=424.msg1768#msg1768
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: March 26, 2009, 04:04:25 »

That was specific advice tailored to his situation. In his case the VOs were webservice definitions and each of those proxies would need to be able to handle with a single webservice. The each of those proxies would presumably be concerned with providing access to the web service that the VO describes. Since proxies often do more than hold a complex object, but also expose convenience methods for working with that object, it made sense to have a one to one relationship between the proxy and vo in that case.

-=Cliff>
Logged
DrFooMod2
Newbie
*
Posts: 6


View Profile Email
« Reply #4 on: March 26, 2009, 08:11:41 »

Using the notification engine, then I could just pass a VO back from a Proxy in the Body property of an implementation of INotification, right?  Is there any reason why the VO couldn't remain in the Proxy?  If you look in ItemDataProxy in the login sample, there is a getItems() method, which when you think of it, defeats the purpose of the IProxy.getData() method.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: March 27, 2009, 04:16:42 »

Yes you can keep the data in the proxy, which is usually the case. Depending on your need and style, you may either keep the data and send a refefence, keep the data and send no reference (recipients retrieve the proxy if they want it), or keep the data and send a reference to the proxy itself (obviating the need to retrieve it). If a Mediator talks often with a Proxy and you never intend to remove the proxy, you may retrieve a reference to it in onRegister and the middle option is easiest, as you don't need to cast anything coming out of the note body(proxy or vo). You already have a ref to the proxy and work with typed returns on its methods.

IProxy.getData() is a method that returns type Object. Generally you'll add a getter that calls getData and returns the result cast to its actual data type. The generic getter is useful for tools such as Kap Labs' PureMVC Console, which may not know your proxy data type but still wish to access it.

The same holds true for Mediators and the generic getViewComponent method.

-=Cliff>
Logged
DrFooMod2
Newbie
*
Posts: 6


View Profile Email
« Reply #6 on: March 27, 2009, 07:03:30 »

My experience up till now with frameworks such as PureMVC is the CAB/Smart Client Software Factory from MS.  This framework is using the MVP pattern.  When you look at PureMVC from that perspective, isn't the Mediator essentially the Presenter to the View because the Controller interacts with the Mediator and not the View?  Also, in CAB (Client Application Block), they have the concept of a Service that interacts with data.  This seems to be the analog to a Proxy object.  Services are preregistered at startup and are injected into actors by way of the ObjectBuilder Dependency Injection Framework.  However from what I've read, doing dependency injection in j2me is difficult to do do the lack of reflection.  Has this concept come up in the context of PureMVC?


P.S. Don;t think I'm trying to break your balls here.  I'm just trying to come out of this with a deep understanding of how the framework operates. :)
« Last Edit: March 27, 2009, 07:33:21 by DrFooMod2 » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #7 on: March 27, 2009, 07:42:35 »

I don't know CAB and so have no way of looking at PureMVC from its perspective. If you want a deep understanding of the framework, I would suggest a quick read of the Framework Overview and Best Practices documents as opposed to trying to understand how it compares to other frameworks. I am always happy to answer questions about the framework, but I put a lot of effort into those documents and you'll get far a far more focused explaination than the off-the-cuff responses you'll get here, where 90% or more of my answers are fat-fingered into a tiny box on my Blackberry, and neccessarily brief.

-=Cliff>
Logged
DrFooMod2
Newbie
*
Posts: 6


View Profile Email
« Reply #8 on: March 27, 2009, 07:53:57 »

I've read both docs, and yes, they are quite thorough.  In fact, surprisingly so.  Ok, here's another question.  Is there any reason why a notification can't originate from within a proxy?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #9 on: March 31, 2009, 06:33:57 »

Nope, there's no problem with that. As those docs indicate, Proxies can send but not receive notifications.

-=Cliff>
Logged
Pages: [1]
Print