MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

Server-Side DataPortal Calling to another External CSLA Service? #83

Open gstempeck opened 9 years ago

gstempeck commented 9 years ago

We have a CSLA Business Layer that has been growing for 6 years and is so large that we've undertaken modularizing and splitting our parts of the Business Layer into Domain Problem / Business Area specific Business Layers.

Last time I tried to add another CSLA Business Layer Reference to an existing CSLA Business Layer, I found that trying to call from BL1 -> BL2 on the server-side (DataPortal) resulted in CSLA reflecting and trying to execute the code for BL2 within the BL1 service instead of jumping to the Endpoint of BL2.

What is the right way to handle BL1 talking to a completely separate service / endpoint that hosts BL2 with CSLA?

jonnybee commented 9 years ago

You first need to create your own implementation of the DataPortalProxyFactory that creates the correct DataPortalProxy (local/remote) for a given objectType. The DataPortalProxyFactory to use a setting on the ApplicationContext.

Next you need to create your own subclasses of the proxys and figure out a way to determine which endpoint to use. One possible solution is to have a custom attribute on the BO to determine that it is hosted on another remote "server" and config name for the "remote" server.

gstempeck commented 9 years ago

Awesome! Thanks jonnybee - we currently have an attribute that defines the endpoint name on our AssemblyInfo for the DLL/BusinessLayer and already have our own DataPortalProxyFactory so it sounds like we're pretty close and just need to focus on separate proxys for each of them.

BrettJaner commented 9 years ago

Hey jonneybee - Everything you stated sounds right, but there's one thing I still don't understand.

How would I know when to return the LocalProxy?

If I was on BusinessLayerOne's Server, and wanted the proxy for a business object type in BusinessLayerOne, I just want to return the LocalProxy instead of BusinessLayerOneProxy. Yet, if I was on BusinessLayerTwo's Server, I would want to return BusinessLayerOneProxy because I am remote.

jonnybee commented 9 years ago

Conditional compile directive on a class attribute or some other configuration like web.config or an xml file.