Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

Paul D. Murphy

Better Lemonade Mousetraps

Provider Conclusion

This will be my last post about the provider issue. I've worked out a couple of solutions and for a while I was keen on moving to a provider command object. The only problem with a command object is that properly implement you have to change the way the Microsoft system works. After a lot of consideration I decided that building on top of what Microsoft has decided to publish made the most sense.

So after deciding to make building on top of Microsoft a design goal I went back over the code and had a little epiphany. This happened when a question about the IsReusable property on the IHttpHandler interface came across my inbox. I thought, “IsReusable, what a great solution”.

Most of my problems with the provider design pattern are listed in previous posts. With the IHttpHandler interface there is a companion IHttpHandlerFactory that controls the creation of the handlers. With my provider framework solution, I am taking the same approach.

First I’ve included a set of helper classes to deal with the configuration aspects of providers. Second I’ve built an extension to the ProviderBase that will be used in the service host code, at this time it doesn’t do anything. Finally, I’ve built a provider factory that oversees the creation of ManagedProvider’s.

The ManagedProviderFactory is an intelligent factory that caches and holds instances of ManagedProviderBase and ManagedProviderPool classes. The rule to apply when creating a ManagedProvider is return true for IsReusable if the provider doesn’t hold state (i.e. access member variables) and false if it does. If a ManagedProvider is not reusable the ManagedProviderFactory creates and caches a pool of ManagedProviders to pull from.

The threading issues are removed from the actual provider implementation and contained in the factory. The threading solution that I currently implement is not a very good solution and should not be used in a high performance environment. The solution is a simple one, designed to show the concept. As I continue to develop the ServiceHost project the threading solution will work itself out.

You can download the code here. I HAVE NOT written any tests cases or made any effort to test the code. It's very possible that it doesn't work at all. I am posting it now so you can get a feel for the direction that I am taking to solve the problems inherit to the current provider design pattern.

You will need Visual Studio 2005 C# Express Edition Beta 1 to open the project.

Sponsor
Published Wednesday, June 30, 2004 1:11 AM by pmurphy

Comments

 

pmurphy said:

I'm very interested in the Provider technologies and still trying to 100% understand it. I believe I see where you are going and it appears to be a good direction. Looking forward to more posts on this subject. :)
June 30, 2004 1:54 AM
 

pmurphy said:

I couldn't download your code to take a look at what you've come up with, but it sounds like we've had some of the same ideas. Classes to handle the configuration aspects of providers, and the provider factory class itself. I really like your idea of a resource pool for providers -- I wrote a basic resource pool for a colleague around the same time I first built my configuration library for plugins -- it never occurred to me to combine the two.

Anyway, if it's not too much like revisiting the past, I'd be interested in hearing your thoughts on my own plugin/provider library. You can find <a href="http://www.adamboddington.com/blog/dotnet/sevencamels-framework-configuration/">here</a>.
June 22, 2005 11:52 PM
 

TrackBack said:

June 30, 2004 1:59 AM
 

TrackBack said:

June 30, 2004 12:23 PM
 

TrackBack said:

June 30, 2004 12:31 PM
 

TrackBack said:

July 3, 2004 7:51 AM
Anonymous comments are disabled