Extensibility and Events
Extensions Series
- Introduction and Events
- Database Scripts & Access with nHibernate
- Extension Settings
- Controllers & Views (coming soon!)
- WCF Http Extensions
FunnelWeb's extensibility system makes it possible to write interesting extensions to FunnelWeb using a MEF powered plug-in model.
When the application starts up, it uses MEF to scan a bin\Extensions folder
for classes implementing the IFunnelWebExtension interface:
public interface IFunnelWebExtension
{
void Initialize(ContainerBuilder builder);
}
Each extension gets a chance to contribute to the IOC container. Eventually we'll be able to use this to abstract things like data storage or spam filtering. For example, by placing "FunnelWeb.Raven.dll" into the bin\Extensions folder, you'll be able to use the RavenDB data provider.
The second thing that goes hand-in-hand with extensions is events.
The idea is that the application acts like a little service bus - a request comes in, ASP.NET MVC processes it, controllers do the bulk of the work, and finally the NHibernate transaction is committed.
During that processing chain, different parts of the app can raise events.
They do this by taking a dependency on IEventPublisher. For example, inside
the WikiController, when a comment is posted, it raises:
EventPublisher.Publish(new CommentPostedEvent(entry, comment));
An extension can then register with the IOC container that it has a new
IEventListener:
[FunnelWebExtension(FullName = "Beep when comments are posted", Publisher = "FunnelWeb", SupportLink = "http://code.google.com/p/funnelweb")]
public class MyExtension : IFunnelWebExtension
{
public void Initialize(ContainerBuilder builder)
{
builder.RegisterType<BeepWhenCommentsPosted>().As<IEventListener>().InstancePerLifetimeScope();
}
}
The event listener would look like this:
public class BeepWhenCommentsPosted: IEventListener
{
public void Handle(Event payload)
{
var commentDetails = payload as CommentPostedEvent;
if (commentDetails == null)
return;
Console.Beep();
}
Currently there's only one event - CommentPostedEvent - but in future we'll add a few more:
- Pingback posted
- Page not found
- Authentication failed
- Page edited
- Page viewed
It would then be easy to implement features like:
- Build a "most popular pages" list by counting the PageViewed events
- Build a pingback system that notifies other people's blogs if you revise a page to include links to their blog
- Build something to replace the "search" page by redirecting NotFound events to Google.com
If you're planning to implement any new features for FunnelWeb, it would be good to consider whether they would be better as extensions than editing the code directly.
Comments
JackNova
Great project
Oscar
Awesome post series. Any ideas on when the Controllers & Views article would be up?
Cheers, O.
Those
Cheerleader Porno: Handsome Tanned Cheerleader Gets Her Shaved Nookie Slammed Hard - Online Video Cheerleader Porno: Lesbian Cheerleaders - Online Video http://colonas.net/18/10-cheerleader-pornstars-in-locker-3some-pKD6Q.html - Cheerleader Porno: Cheerleader Pornstars In Locker 3some - Online Video http://colonas.net/38/10-beautiful-zdenka-podkapova-striptease-Q7Tfe.html - Cheerleader Porno: Beautiful Zdenka Podkapova Striptease - Online Video
Cheer Leader Free Online Porno Video
http://colonas.net/ - Cheerleader Porno
hydroxycut
www.funnelweblog.com has interesting content hydroxycut
Sergey
These are some really nice extensibility points. I've already learned so much by just starting reading through source code. I personally love the platform and I think the shear clean architecture will attract people. :) I will be definitely sharing my extensions in the future. Keep up the good work and blog posts!