|ActiveNaming||Grid API||Coordinator||Presentation||Polaris A||Polaris B||Download|
Polaris A implementation|
Polaris shows how to use the Coordinator API and the ActiveNaming Web service.
It is an example rather than a real application.
You certainly can reuse some parts of Polaris A in your applications, especially:
To simplify the packaging the PolClient project includes:
In real cases, the controls belong to different projects and can be implemented by different companies and the control assembler that uses these controls doesn’t necessarily have even access to the control sources.
PolLogin implements a form with a User and a Password fields. When the user clicks on the Login button the OnLogin method is called.
OnLogin stores the user name on the heap with:
The user name is added to the Head with a Session scope and its source is the ID of the PolLogin control.
PolCommit implements a form with a Commit button. When the user clicks on the Commit button the OnCommit method is called. When the user clicks on the Rollback button the OnRollback method is called.
OnCommit commits the transaction with:
If the Commit failed (returned false) OnCommit analyses the objects returned in ht and displays an error message.
OnRollback rollbacks the transaction with:
If the Commit failed (returned false) OnRollback analyses the objects returned in ht and displays an error message.
ShoppingBasket.ascx allows adding and removing articles to a basket.
The user can select articles on a dropdown list and enters the number of articles.
ShoppingBasket.ascx displays the basket content on a Datagrid.
ShoppingBasket implements the Transaction interface and therefore the Prepare, Commit and Rollback methods.
Page_Load is called when the control is loaded.
OnArticleChanged is called when the user selects another article on the DropDown list.
OnArticleChanged sets the unit price according to the selected article.
OnAdd is called when the user clicks on the Add button.
OnDelete is called when the user clicks on the Delete button of the Datagrid.
Prepare is called when the transaction source calls Commit.
Commit is called when the transaction source calls Commit.
Rollback is called when the transaction source calls Rollback.
Rollback cleans up the basket.
SmartProxy manages an ActiveNaming cache, wsHt.
wsHt is a Hashtable whose key is a WsKey object and value is a ArrayList.
The WsKey class manages a key that uniquely identifies a Web service and is made of:
A wsHt entry describes the response to an ActiveNaming.GetCandidate request.
Therefore the ArrayList is a list of the Candidates found by ActiveNaming.GetCandidate.
A Candidate is represented by a PolarisKey object. The PolarisKey class allows comparing a request with a PolarisKey object using:
A Web service instance manages a set of accounts. The account sets are replicated, which means that more than one Web service instance can manage an account. To choose an instance the SmartProxy
The SmartProxy constructor
GetUrl enumerates the csl ArrayList and selects entries that satisfy to two conditions
The user number falls in their range number
Their location is the same as the Polaris client
Then GetUrl uses Random to choose one of the selected entries.
GetCandidate is called by the SmartProxy constructor.
GetCandidate calls the ActiveNaming.GetCandidate method of its controlling PageBox.
RangeLoc.aspx is a page allowing to set the keyRange of a Web service instance.
Page_Load is called when RangeLoc.aspx is loaded.
OnSet is called when the user clicks on the Set button.
GetProxy is called by Page_Load and by OnSet.
GetProxy creates and checks an ActiveNaming proxy.
ShoppingOrder.asmx simulates database updates. It implements two methods, CheckAccount and Order.
CheckAccount is called by the Prepare method of the ShoppingBasket.ascx control to check if everything is ready before updating the database. Here it returns false when the account name starts with "mal" and true otherwise.
Order returns true.