Using Custom Objects with CSLA

Using Custom Objects with CSLA

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


isharko posted on Wednesday, October 10, 2007

Is it problem if we reference our pre-existing custom objects (DataAcess,Error,FileManipulation,Validation,etc objects that are specific to our company's environment) inside CSLA-based objects?

I have created a test csla objects that reference those and it works fine locally and on remote server (using remoting).

Thanks  

ajj3085 replied on Thursday, October 11, 2007

Sure.  The DataAccess though I'd limit to use only inside DataPortal_XYZ methods.  Validation might be tricker, but there's no reason you couldn't create Csla rules which wrap calls to your Validation layer, if Csla validation is much different than your current implementation.

isharko replied on Thursday, October 11, 2007

Thank you for your response, Ajj3085.

 

I am confused about the mobile objects concept.

As far as I understand CSLA objects (that are supposed to be send back and forth between client and server) have to be serialized and then all the objects refernced in them have to be serialized also.

Since custom objects are not serializable how come it still works?

Thank you in advance 

ajj3085 replied on Thursday, October 11, 2007

Did you really setup the DataPortal to do remoting?  To do this, you need to setup IIS to host the application server and set some configuration file settings.  Unless you do this,  you're running in local mode, where everything happens on the client, so nothing is getting serialized,  unless you're doing some N-level undo or Cloning of objects.  Have you tried these methods?

I'm not sure what you mean that custom objects aren't serializable; anything is, as long as you mark the classes with Serializable. 

Andy

isharko replied on Thursday, October 11, 2007

Thank you again for your response, Andy.

Yes, I did setup Dataportal to do remoting, used IIS  on a different server to host the objects and set config file. Followed Rocky's instructions in the book step by step.

By not serializable I meant that there is no serializable atributes in any of our custom objects (we could add it if need to).

I didn't tried cloning or n-level undo. I have only used dataportal's fetch method to populate object's props.

I guess that is why it worked? When are the objects are sent across the network only when the need to update themselves?

Igor.

ajj3085 replied on Thursday, October 11, 2007

ahh.

Well if you're only using your objects on the server (in DataPortal_XYZ code), then you're objects don't need to be serializable.  If your BO holds a reference to one of those object and needs to cross the bounderies you'd be in trouble.  It sounds like you only used your custom libraries in the DP_XYZ methods, and if your BOs won't hold any reference to them outside of the method call, they don't need to be serializable.

The Csla based busienss objects travel across the network only when you call DataPortal.Fetch (or Update, Insert, etc).  When the DP_XYZ methods finished, your BOs are again serialized back to the client. 

Chapter 4 of the book explains this process pretty well; check it out for more details.

HTH
Andy

isharko replied on Thursday, October 11, 2007

Your responses were really helpful.

Thank you.

Copyright (c) Marimer LLC