Polaris |
|
ActiveNaming | Grid API | Coordinator | Presentation | Polaris A | Polaris B | Download |
Polaris A implementationOverviewPolaris 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. Client classesPolLogin.ascx.csPolLogin implements a form with a User and a Password fields. When the user clicks on the Login button the OnLogin method is called. Parameters
OnLoginOnLogin 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.ascx.csPolCommit 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. Parameters
OnCommitOnCommit commits the transaction with:
If the Commit failed (returned false) OnCommit analyses the objects returned in ht and displays an error message. OnRollbackOnRollback rollbacks the transaction with:
If the Commit failed (returned false) OnRollback analyses the objects returned in ht and displays an error message. ShoppingBasket.ascx.csShoppingBasket.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. Parameters
Page_LoadPage_Load is called when the control is loaded. Page_Load
OnArticleChangedOnArticleChanged is called when the user selects another article on the DropDown list. OnArticleChanged sets the unit price according to the selected article. OnAddOnAdd is called when the user clicks on the Add button. OnAdd
OnDeleteOnDelete is called when the user clicks on the Delete button of the Datagrid. OnDelete
PreparePrepare is called when the transaction source calls Commit. Prepare
CommitCommit is called when the transaction source calls Commit. Commit
RollbackRollback is called when the transaction source calls Rollback. Rollback cleans up the basket. SmartProxy.csSmartProxy 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
ConstructorThe SmartProxy constructor
GetUrlGetUrl 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. GetCandidateGetCandidate is called by the SmartProxy constructor. GetCandidate calls the ActiveNaming.GetCandidate method of its controlling PageBox. Server classesRangeLoc.aspx.csRangeLoc.aspx is a page allowing to set the keyRange of a Web service instance.
Page_LoadPage_Load is called when RangeLoc.aspx is loaded. Page_Load
OnSetOnSet is called when the user clicks on the Set button. OnSet
GetProxyGetProxy is called by Page_Load and by OnSet. GetProxy creates and checks an ActiveNaming proxy. ShoppingOrder.asmx.csShoppingOrder.asmx simulates database updates. It implements two methods, CheckAccount and Order. CheckAccountCheckAccount 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. OrderOrder returns true.
Contact:support@pagebox.net |