Revision: 1420
Author: sberlin
Date: Sun Nov 21 09:32:21 2010
Log: Edited wiki page ExtendingGuice through web user interface.
http://code.google.com/p/google-guice/source/detail?r=1420
Modified:
/wiki/ExtendingGuice.wiki
=======================================
--- /wiki/ExtendingGuice.wiki Tue Sep 21 18:51:58 2010
+++ /wiki/ExtendingGuice.wiki Sun Nov 21 09:32:21 2010
@@ -2,7 +2,7 @@
The
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/package-summary.html
service provider interface] exposes Guice's internal models to aid in the
development in tools, extensions, and plugins.
-= Core Abstractions =
+=Core Abstractions=
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/InjectionPoint.html
InjectionPoint] || A constructor, field or method that can receive
injections. Typically this is a member with the `...@inject` annotation. For
non-private, no argument constructors, the member may omit the annotation.
Each injection point has a collection of dependencies. ||
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Key.html
Key] || A type, plus an optional binding annotation. ||
@@ -10,16 +10,20 @@
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/Element.html
Element] || A configuration unit, such as a `bind` or `requestInjection`
statement. Elements are
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/ElementVisitor.html
visitable]. ||
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Module.html
Module] || A collection of configuration elements.
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/Elements.html#getElements(java.lang.Iterable)
Extracting the elements] of a module enables *static analysis* and
*code-rewriting*. You can inspect, rewrite, and validate these elements,
and use them to build new modules. ||
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Injector.html
Injector] || Manages the application's object graph, as specified by
modules. SPI access to the injector works like *reflection*. It can be used
to retrieve the application's bindings and dependency graph. ||
+
+The [InspectingModules Elements SPI] page has more information about using
these classes.
<p>
-= Abstractions for Extension Authors =
-
-_(This documents an experimental, unreleased feature available in Guice
SVN only)_
+=Abstractions for Extension Authors=
+
+_(New in Guice 3.0)_
+
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/Toolable.html
@Toolable] || An annotation used on methods also annotated with `...@inject`.
This instructs Guice to inject the method even in `Stage.TOOL`. Typically
used for extensions that need to gather information to implement
`HasDependencies` or validate requirements and fail early for easier
testing. ||
||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/ProviderWithExtensionVisitor.html
ProviderWithExtensionVisitor] || An interface that provider instances
implement to allow extensions to visit custom subinterfaces of
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/BindingTargetVisitor.html
BindingTargetVisitor]. See [ExtensionSPI Extensions SPI] for more
information. ||
-<p>
-
-= Examples =
+
+The [ExtensionSPI Extensions SPI] page has more information about writing
extensions that expose an SPI
+
+=Examples=
Log a warning for each static injection in your Modules:
{{{
@@ -27,7 +31,7 @@
for (Element element : Elements.getElements(modules)) {
element.acceptVisitor(new DefaultElementVisitor<Void>() {
@Override
- public Void visitStaticInjectionRequest(StaticInjectionRequest
element) {
+ public Void visit(StaticInjectionRequest element) {
logger.warning("Static injection is fragile! Please fix "
+ element.getType().getName() + " at " +
element.getSource());
return null;
--
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.