Comment #3 on issue 524 by sberlin: Extension introspection API
http://code.google.com/p/google-guice/issues/detail?id=524

Attached are two patches for an extension SPI.

 1) guice-extension-spi.txt
This is a small patch that changes Guice so that extensions can provide their own SPI. All it does is introduce a new 'ProviderWithExtensionVisitor' interface that has an 'acceptExtensionVisitor' method. The existing ProviderInstanceBindingImpl class now checks to see if the providerInstance it is calling visit on is an instance of ProviderWithExtensionVisitor, and if so, it delegates the visitation to ProviderWithExtensionVisitor.acceptExtensionVisitor. This is the hook where extensions take over.

 2) servlet-extension-spi.txt
This is a minor reworking of the servlet extension so that it can expose its bindings through the SPI. It creates a new public interface 'ServletModuleTargetVisitor' that has these methods:
    visitFilterBinding(String, Key, Map)
    visitFilterBinding(String, Filter, Map)
    visitFilterRegexBinding(String, Key, Map)
    visitFilterRegexBinding(String, Filter, Map)
    visitServletBinding(String, Key, Map)
    visitServletBinding(String, HttpServlet, Map)
    visitServletRegexBinding(String, Key, Map)
    visitServletRegexBinding(String, HttpServlet, Map)
and calls those methods for any filter(..) or serve(..) methods created in the ServletModule. In order to support this, I had to change the internals of the extension so that each ServletDefinition and FilterDefinition was bound on its own, instead of through a List. The only actual effect this will have is that there will be an additional binding in the Injector for each pattern.

Attachments:
        guice-extension-spi.txt  3.9 KB
        servlet-extension-spi.txt  46.4 KB

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to