Command objects

Command objects

Old forum URL: forums.lhotka.net/forums/t/460.aspx


devbanana posted on Saturday, June 24, 2006

Hi,
 
Just a few questions about command objects.
 
If they throw an exception while on the application server, what will be returned to the UI? Is it still DataPortalException?
 
Secondly, let's say a command object, as part of its execution on the application server, needs to use a business object. Can it call the business object just as the UI would, and will the business object know it is already on the application server?
 
For instance:
 
The UI calls the command object's Execute method. The command object goes over to the application server, let's say via .NET remoting, and as part of its execution calls a business object's factory method.
 
Will the business object know it doesn't need to be transfered, because it is already on the application server?
 
Thanks,
Brandon

RockfordLhotka replied on Saturday, June 24, 2006

Yes, exceptions from the data portal always come back as DataPortalException, with the original exception available through the BusinessException property.

And yes, any code running on the application server can call normal object factory methods and it should work fine. Your config file on the server won't have configured the data portal to be remote, so it will run locally, within the already established context of your server-side code.

devbanana replied on Sunday, June 25, 2006

hi,

 

Thanks for the reply. One more question.

 

Would using command objects be an appropriate implementation of trying to implement business processes? Also what if I need some transactional support, say for instance if the process is calling components that update or insert data, but possibly mixed with others that do not need such support, such as processing a credit card, for example.

 

I figured I could just have the Execute method return whatever type of return I need, such as a boolean to see if it executed successfully, or even a business object of some kind.

RockfordLhotka replied on Sunday, June 25, 2006

As with any transaction scheme, you need to be careful about when you start/stop the transaction.
 
If you decorate DataPortal_Execute() with the Transaction attribute, everything inside will be transactionally protected as you specify. If you want to mix transactional and non-transactional operations you need to start/end the transaction at a lower level. Of course that's the least of your worries, since you need to manually determine how to handle failure and "rollback" of the non-transactional portion of your process - and that can be really complex...
 
Rocky

devbanana replied on Sunday, June 25, 2006

hi,
 
If I decorate DataPortal_Execute with Transactional, would every method it refers to in any object have to be decorated with the same?
 
Thanks,
Brandon
 
----- Original Message -----
From: Rockford Lhotka
To: brandon@devbanana.com
Sent: Sunday, June 25, 2006 4:23 PM
Subject: RE: [CSLA .NET] Command objects

As with any transaction scheme, you need to be careful about when you start/stop the transaction.
 
If you decorate DataPortal_Execute() with the Transaction attribute, everything inside will be transactionally protected as you specify. If you want to mix transactional and non-transactional operations you need to start/end the transaction at a lower level. Of course that's the least of your worries, since you need to manually determine how to handle failure and "rollback" of the non-transactional portion of your process - and that can be really complex...
 
Rocky



RockfordLhotka replied on Sunday, June 25, 2006

No. Read chapter 4 to see how the transactional capabilities are implemented in the data portal.
 
Rocky


From: Brandon [mailto:cslanet@lhotka.net]
Sent: Sunday, June 25, 2006 4:38 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Command objects

hi,
 
If I decorate DataPortal_Execute with Transactional, would every method it refers to in any object have to be decorated with the same?
 
Thanks,
Brandon

Copyright (c) Marimer LLC