How to use the SharePoint Service Locator? - p & p Developing SharePoint Applications guidance
- Posted: Sep 01, 2009 at 9:32 PM
- 20,677 Views
- 4 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- Mid Quality WMV (Lo-band, Mobile)
- MP3 (Audio only)
This video demonstrates how to use the SharePoint Guidance Library’s service locator implementation. The SharePoint service locator helps with decoupling service consumers, such as web parts, from service providers which may be in a separate assembly or
even separate WSP.
Quick Links:
Setting up the Contoso RI
Walkthrough of the Contoso Reference Implementation
How to use the configuration component?
How to use the logging components?
p&p Developing SharePoint Application Guidance
patterns & practices
Quick Links:
Setting up the Contoso RI
Walkthrough of the Contoso Reference Implementation
How to use the configuration component?
How to use the logging components?
p&p Developing SharePoint Application Guidance
patterns & practices
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
So, wasn't this the exact reason why we had the GAC in .NET framework ?
If I have referenced MyLogger.dll that implements ILogger() in MyWebPart.dll;
and if I happen to upgrade MyLogger.dll to version 2.0 (which uses a different implementation, but the interface is the same);
I should be able to configure my environment to use MyLogger.dll version 2.0 using .NET configuration.
Why do we need a service locator if the GAC can provide us the (modified) assembly to use at runtime?
Doesn't this add more complexity and configuration requirement to the whole project?
Hi H@2rC0d32,
The GAC and the Service Locator solve different problems.
In your example, MyWebPart has an explicit reference you MyLogger.DLL. You are right, you could upgrade MyLogger.dll. But you could never plug in MyOtherLogger.dll that also has a ILogger implementation, without recompiling your MyWebPart.dll.
The GAC is a centralized repository that allows you to share Assemblies between applications. This has nothing to do with decoupling components of an application, which is the primary responsibilty of the servicelocator.
Now to answer your question, why would you need a service locator?
(from the Composite Application Guidance) http://msdn.microsoft.com/en-us/library/cc707905.aspx
Another excellent explaination why decoupling is useful is provided by the Unity dependency injection container (http://www.codeplex.com/unity):
Unity addresses the issues faced by developers engaged in component-based software engineering. Modern business applications consist of custom business objects and components that perform specific or generic tasks within the application, in addition to components that individually address cross cutting concerns such as logging, authentication, authorization, caching, and exception handling.
The key to successfully building such applications is to achieve a decoupled or very loosely coupled design. Loosely coupled applications are more flexible and easier to maintain. They are also easier to test during development. You can mock up shims (lightweight mock implementations) of objects that have strong concrete dependencies; such as database connections, network connections, ERP connections, and rich user interface components.
Dependency injection is a prime technique for building loosely coupled applications. It provides ways to handle the dependencies between objects. For example, an object that processes customer information may depend on other objects that access the data store, validate the information, and check that the user is authorized to perform updates. Dependency injection techniques can ensure that the customer class correctly instantiates and populates all of these objects, especially where the dependencies may be abstract.
Hope this helps explaining why you would need a servicelocator.
Erwin van der valk
patterns & practices
www.erwinvandervalk.net
Nice Demo!
<a href= “http://www.fashionbrandwholesale.com” > nike dunk heels </a>
Remove this comment
Remove this thread
close