I was creating a web level event receiver which was to be deployed to a SharePoint web application which had more than 100 site collections. So I decided to create it as web application level scoped solution. But, only after I tried deploying it did I understand that a web level event receiver cannot be deployed at web application scope.
Somehow, I wanted to deploy the event receiver such that it gets executed for the site collections in a web application. I cannot manually activate the feature as there are more than 100 site collections.
It is then I got an idea that we can deploy the solution using a PowerShell script and activate the feature in all the site collections in the web application.
Here is a good blog post describing how to activate a feature in all the site collections in a web application using PowerShell script: http://basementjack.com/uncategorized/powershell-to-activate-a-sharepoint-2010-feature-on-every-site-collection-in-a-web-app/
But what if a user is creating a new site collection in the web application, and the feature also must get activated automatically instead of manually activating it in the newly created site collection? We can achieve this by creating a feature stapler.
A Feature stapler is a feature in itself which when deployed at a web application level (or at any level) will automatically activate a feature whose feature id is defined in the feature.xml of the feature stapler.
Here is a good blog post which explains how to create a feature stapler: http://blogs.msdn.com/b/kunal_mukherjee/archive/2011/01/11/feature-stapling-in-sharepoint-2010.aspx