Revision: 936ca5ba1f96
Author: christianedwardgruber <[email protected]>
Date: Tue Feb 7 07:37:23 2012
Log: Edited wiki page Multibindings through web user interface.
http://code.google.com/p/google-guice/source/detail?r=936ca5ba1f96&repo=wiki
Modified:
/Multibindings.wiki
=======================================
--- /Multibindings.wiki Mon Feb 21 17:37:33 2011
+++ /Multibindings.wiki Tue Feb 7 07:37:23 2012
@@ -5,7 +5,7 @@
==Using Multibindings to host Plugins==
Multibindings make it easy to support plugins in your application. Made
popular by [http://www.eclipseplugincentral.com/ IDEs] and
[https://addons.mozilla.org/en-US/firefox/ browsers], this pattern exposes
APIs for extending the behaviour of an application.
-Neither the plugin consumer nor the plugin author need write much setup
code for extensible applications with Guice. Simply define an interface,
bind implementations, and inject implementations! To illustrate, we'll use
plugins to summarize ugly URIs like `http://bit.ly/1mzgW1` into something
readable on Twitter.
+Neither the plugin consumer nor the plugin author need write much setup
code for extensible applications with Guice. Simply define an interface,
bind implementations, and inject sets of implementations! Any module can
create a new Multibinder to contribute bindings to a set of
implementations. To illustrate, we'll use plugins to summarize ugly URIs
like `http://bit.ly/1mzgW1` into something readable on Twitter.
First, we define an interface that plugin authors can implement. This is
usually an interface that lends itself to several implementations. For this
example, we would write a different implementation for each website that we
could summarize.
{{{
@@ -80,6 +80,9 @@
}
}
}}}
+
+_*Note:* The method `Multibinder.newSetBinder()` can be confusing. This
operation creates a new binder, but doesn't override any existing
bindings. Any thusly-created binders simply contribute more bindings to
the Set._
+
Finally we must register the plugins themselves. The simplest mechanism to
do so is to list them programatically:
{{{
--
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.