Plug-Ins and Dynamic Controllers
Posted in BlogSvc, MVC by JarrettV on 2/11/2009 11:57:48 PM - CSTUpdate: The content of this post is out of date. The concept of plug-ins has since been expanded to support more scenarios, including widgets, plug-ins, and controllers.
The next release contains new support for plug-ins as described in previous posts. Plug-ins are supported using the Dependency Injection framework StructureMap.
The following types are pluggable:
| Service Level Plug-ins | Default Type | Collection Plug-ins | Default Type |
|---|---|---|---|
| ILogService | NLogService | IRouteService | AtomPubRouteService |
| IController | N/A | IAtomPubService | AtomPubService |
| IUserRepository | FileUserRepository | IAnnotateService | AnnotateService |
| IAppServiceRepository | FileAppServiceRepository | ICleanContentService | XhtmlCleanContentService |
| IAtomEntryRepository | FileAtomEntryRepository | ||
| IMediaRepository | FileMediaRepository | ||
| IAppCategoriesRepository | FileAppCategoriesRepository | ||
| IAuthorizeService | ServiceAuthorizeService |
The Service Level plug-ins can all be controlled using the <StructureMap> configuration section in the web.config file.
The following example shows how to set properties on the blog collection to use the Blog Plug-in:
The RouteService registers routes on the collections first. Then it registers the default routes. Special care must be taken when registering routes so they occur in the correct order. Also, plug-in routes should take care to use the collection constraint so that routes are properly overridden only on collections using the RouteService plug-in.
Controllers are dynamically instantiated using the StructureMap ObjectFactory. Therefore, plug-ins can provide new routes and handle them with new controllers. Currently, new routes are limited to collection plugins that fire the RegisterRoutes event. This will be extended in the future to support routes outside of collections for things such as widgets.
I am currently flushing out the Widget story and I'm leaning towards a combination of techniques using PartialRequests and Modularity. If you have any suggestions for widget support, please leave a comment below.
Comments
None.