Revision: 1263
Author: sberlin
Date: Tue Sep 21 11:53:02 2010
Log: Edited wiki page ExtensionSPI through web user interface.
http://code.google.com/p/google-guice/source/detail?r=1263
Modified:
/wiki/ExtensionSPI.wiki
=======================================
--- /wiki/ExtensionSPI.wiki Tue Sep 21 11:50:45 2010
+++ /wiki/ExtensionSPI.wiki Tue Sep 21 11:53:02 2010
@@ -6,8 +6,8 @@
In Guice 2.0 we expanded our SPI to expose rich details about modules and
injectors. The elements API can inspect, extend and even rewrite Guice
configuration. It's an essential tool used by GIN, Modules.override(),
Grapher, Guiceberry's controllable injection, and others. In Guice 3.0 we
expanded the SPI to include extensions! Extensions such as Multibinder,
Assisted Inject, Servlets and others can expose their details through
programmatic inspection.
==How Extensions Participate==
-An extension author needs to do two things. First it must create a
subinterface of BindingTargetVisitor that is specific to its extension.
For example, the servlet extension has ServletModuleTargetVisitor, and the
Multibinder extension has MultibindingsTargetVisitor. The extension must
also bind the extension's provider instance to a
ProviderWithExtensionVisitor. The implementation of acceptExtensionVisitor
must do an instanceof check on the BindingTargetVisitor and call the
appropriate visit method. If the visitor is an instance of the extension's
visitor, it must visit the appropriate extension method, otherwise it must
visit the normal ProviderInstanceBinding.
-For example, this is what MapBinder & Multibinder do:
+An extension author needs to do two things. First it must create a
subinterface of `BindingTargetVisitor` that is specific to its extension.
For example, the servlet extension has `ServletModuleTargetVisitor`, and
the Multibinder extension has `MultibindingsTargetVisitor`. The extension
must also bind the extension's provider instance to a
`ProviderWithExtensionVisitor`. The implementation of
acceptExtensionVisitor must do an instanceof check on the
`BindingTargetVisitor` and call the appropriate visit method. If the
visitor is an instance of the extension's visitor, it must visit the
appropriate extension method, otherwise it must visit the normal
`ProviderInstanceBinding`.
+For example, this is what mapbinder does:
{{{
public <R, B> R acceptExtensionVisitor(BindingTargetVisitor<B, R>
visitor,
ProviderInstanceBinding<? extends B> binding) {
--
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.