New Posts New Posts RSS Feed: Is it possible to specify by code which BOS to use
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Is it possible to specify by code which BOS to use

 Post Reply Post Reply
Author
ouelletf View Drop Down
Newbie
Newbie
Avatar

Joined: 15-May-2009
Location: Québec, Canada
Posts: 9
Post Options Post Options   Quote ouelletf Quote  Post ReplyReply Direct Link To This Post Topic: Is it possible to specify by code which BOS to use
    Posted: 18-Nov-2009 at 3:37pm
Is it possible to specify which BOS to use (address, port and service name) from code.

Something similar to IDataSourceKeyResolver maybe ?

I want to allow the user to choose on which server he is logging on.
Back to Top
ouelletf View Drop Down
Newbie
Newbie
Avatar

Joined: 15-May-2009
Location: Québec, Canada
Posts: 9
Post Options Post Options   Quote ouelletf Quote  Post ReplyReply Direct Link To This Post Posted: 18-Nov-2009 at 3:41pm
Also it would be great to be able to specify an IDataSourceKeyResolver to the EntityManager ctor. Now we have to have a singleton that contain the connection parameters we which to use.
Back to Top
stephenmcd1 View Drop Down
DevForce MVP
DevForce MVP


Joined: 27-Oct-2009
Location: Los Angeles, CA
Posts: 166
Post Options Post Options   Quote stephenmcd1 Quote  Post ReplyReply Direct Link To This Post Posted: 19-Nov-2009 at 5:42pm

For configuring the BOS adddress through code, I've had luck by setting properties on the IdeaBladeConfig.Instance.ObjectServer object (ServerPort, RemoteBaseUrl, ServiceName, etc.).  As long as I set those up before using an EntityManager, things seem to work.  

I'm not sure if this is the best way though - I'd like to hear if there are other/better ways.

Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 20-Nov-2009 at 4:08pm
@ouelletf - Stephenmcd1's answer is the answer I would have given you (and my thanks to him). It is the way I would do it.
 
Do realize that once you have tried to reach the BOS from a client AppDomain, you are committed to that BOS address henceforth. A bunch of statics are set and we don't look at the IdeaBladeConfig again for that information.
 
Here at IdeaBlade we have discussed options for resetting that choice dynamically. Let me know if this is critical to you.
 
I do not understand the question about specifying a DataSourceKeyResolver to the EntityManager nor do I fathom the notion of providing an EntityManager with a connection string.
 
You never provide the EntityManager with a connection string. We don't want connection strings residing on the client; bad for security.
 
To switch data source contexts (which is the point of our DataSourceExtension facility), you provide a newly created EntityManager (EM) with a string, the "DataSourceExtension". This string is bundled with your requests for persistence operations. The BOS solders this extension (e.g., "Foo") to the DataSourcekey embedded in the operation request (e.g., "Default") yielding a full DataSourceKey ("Default_Foo") to be resolved by the DataSourceKeyResolver on the Server.
 
Let me repeat that phrase "on the Server". The Resolver is always on the server, never on the client. The Resolver is a class that implements IDataSourceKeyResolver - a class you define in one of your custom assemblies. You deploy that assembly into one of the locations mentioned in your server-side config as a "Probe Assembly" location. DevForce finds it and uses it instead of our default Resolver.
 
Any DataSourceKeyResolver takes the combined key (base + extension = "Default_Foo") and translates it to an EDM Key holding the proper connection string.
 
All of this is described in the Developers Guide better than I'm doing here; I'm just trying to give you the sense of it.
 
Our default DataSourceKeyResolver uses information inside your config file. Your Resolver (which implements IDataSourceKeyResolver) can do anything you want, including delegate to the default DevForce Resolver. Many people write a Resolver that calls out to some server-side connection string provider that they can maintain by whatever means feels convenient; it could be an Excel spreadsheet.
 
Hope this helps.
Back to Top
Cornholio View Drop Down
Newbie
Newbie
Avatar

Joined: 14-Feb-2011
Location: South Africa
Posts: 5
Post Options Post Options   Quote Cornholio Quote  Post ReplyReply Direct Link To This Post Posted: 14-Feb-2011 at 4:24am
Hi Ward,

Above you mentioned the possibility of dynamically resetting some statistics and re-using the IdeaBladeConfig.
How would I go about this?

We have multiple sites running their own BOS which our central services need to connect to on the fly.
Otherwise, is it possible to connect to multiple BOS'es at the same time?

Thanks

Back to Top
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Posted: 14-Feb-2011 at 9:18am
@cornholio -
 
Stephenmcd1 described succintly how you can set any of the client-side configurations in code:

"For configuring the BOS adddress through code, I've had luck by setting properties on the IdeaBladeConfig.Instance.ObjectServer object (ServerPort, RemoteBaseUrl, ServiceName, etc.). As long as I set those up before using an EntityManager, things seem to work."

Your client code could set the BOS address dynamically based on criteria you determine locally (IPAddress? User name? ComboBox?). Remember to do so BEFORE you defining or using an EntityManager (even implicitly)

Once an EntityManager has extracted what it needs from the IdeaBladeConfig.Instance , it never looks back. Changing it later won't do a thing.

If you need to switch among different BOS locations, you'll have to do that out-of-band somehow. One possibility is to run separate instances of your client application in different AppDomains. You can create and destroy those on the fly. Each AppDomain is its own little world with a private set of static values.
 
I emphasize the word "location" because you can reach multiple BOS instances behind a Load Balancer located a one particular address.
 
HTH
Back to Top
Cornholio View Drop Down
Newbie
Newbie
Avatar

Joined: 14-Feb-2011
Location: South Africa
Posts: 5
Post Options Post Options   Quote Cornholio Quote  Post ReplyReply Direct Link To This Post Posted: 15-Feb-2011 at 4:03am
@WardBell -

Thanks for your reply.
I understand that once an EntityManager has been created it will never go back to the IdeaBladeConfig.Instance.

I'm interested in the following statement you made above:
"Here at IdeaBlade we have discussed options for resetting that choice dynamically. Let me know if this is critical to you."

I was hoping there would be an easier way than Seperate AppDomains.

Maybe if I outline our situation a bit more:

We have a decentralized solution with each geographically remote site having their own BOS and Database (replicated with a master DB).

We are making use of the Subscription/Notification feature to see who is logged on, what version they are running, send them messages, install the latest version, etc.

Our central services need a way of easily checking with each BOS for the logged on users and sending notifications.
Restarting the app for each site unfortunately isnt an option.


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down