Author: limpbizkit
Date: Sun Nov 16 15:51:01 2008
New Revision: 675
Added:
wiki/ExtendingGuice.wiki
Log:
Created wiki page through web user interface.
Added: wiki/ExtendingGuice.wiki
==============================================================================
--- (empty file)
+++ wiki/ExtendingGuice.wiki Sun Nov 16 15:51:01 2008
@@ -0,0 +1,30 @@
+#summary Guice's SPI for authors of tools, extensions and plugins
+
+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 =
+
+||
[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 [EMAIL PROTECTED] 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. ||
+||
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/spi/Dependency.html
Dependency] || A key, optionally associated to an injection point. These
exist for injectable fields, and for the parameters of injectable methods
and constructors. Dependencies know whether they accept null values via an
[EMAIL PROTECTED] annotation. ||
+||
[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. ||
+
+= Examples =
+
+Log a warning for each static injection in your Modules:
+{{{
+ public void warnOfStaticInjections(Module... modules) {
+ for (Element element : Elements.getElements(modules)) {
+ element.acceptVisitor(new DefaultElementVisitor<Void>() {
+ @Override
+ public Void visitStaticInjectionRequest(StaticInjectionRequest
element) {
+ logger.warning("Static injection is fragile! Please fix "
+ + element.getType().getName() + " at " +
element.getSource());
+ return null;
+ }
+ });
+ }
+ }
+}}}
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---