Author: limpbizkit
Date: Thu Jan 1 21:41:06 2009
New Revision: 790
Modified:
wiki/Changes20.wiki
Log:
Edited wiki page through web user interface.
Modified: wiki/Changes20.wiki
==============================================================================
--- wiki/Changes20.wiki (original)
+++ wiki/Changes20.wiki Thu Jan 1 21:41:06 2009
@@ -1,8 +1,11 @@
#summary Significant changes in Guice 2.0
+#labels Featured
=Changes in Guice 2=
-We intend to release during December 2008.
+Intended for release in January 2009.
-==Small Features==
+==New Features==
+
+===Small Features===
* `Binder.getProvider` and `AbstractModule.requireBinding` allow modules
to declare and use dependencies.
* `Binder.requestInjection` allows modules to register instances for
injection at Injector-creation time.
* `Providers.of()` always provides the same instance, useful for testing.
@@ -11,7 +14,7 @@
* `Types` utility class for creating implementations of generic types.
* `AbstractModule.requireBinding` allows modules to document
dependencies programatically
-==Provider Methods==
+===Provider Methods===
Creating custom providers without all of the boilerplate. In any module,
annotate a method with `...@provides` to define logic that will be used to
provide that type:
{{{
class PaymentsModule extends AbstractModule {
@@ -29,14 +32,14 @@
}}}
Parameters to the @Provides method will be injected. It can optionally be
annotated with a scoping annotation (like `...@singleton`). The method's
returned type is the bound type. Annotate the method with a binding
annotation (like `...@named("replicated")`) to create a binding for the
annotated type.
-==Binding Overrides==
+===Binding Overrides===
[http://publicobject.com/2008/05/overriding-bindings-in-guice.html
Override] the bindings from one module with another:
{{{
Module functionalTestModule
= Modules.override(new ProductionModule()).with(new
OverridesModule());
}}}
-==Multibindings, !MapBindings==
+===Multibindings, !MapBindings===
Bind elements of
[http://publicobject.com/2008/05/guice-multibindings-extension-checked.html
Sets] and [http://publicobject.com/2008/05/mapbinder-checked-in.html Maps],
then inject the full collection. Bindings are aggregated from all modules.
{{{
public class SnacksModule extends AbstractModule {
@@ -50,37 +53,36 @@
}
}}}
-==Private Modules==
+===Private Modules===
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/privatemodules/PrivateModule.html
PrivateModules] can be used to create bindings that are not externally
visible. This makes it easier to encapsulate dependencies and to avoid bind
conflicts.
-==Servlets==
+===Servlets===
`ServletModule` now supports programmatic configuration of servlets and
filters. These servlets may be injected directly.
`GuiceServletContextListener` can be used to help bootstrap a Guice
application in a servlet container.
-==Child Injectors==
+===Child Injectors===
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/Injector.html#createChildInjector(java.lang.Iterable)
Injector.createChildInjector] allows you to create child injectors that
inherit the bindings, scopes, interceptors and converters of their parent.
This API is primarily intended for extensions and tools.
-==Even Better Error Reporting==
+===Even Better Error Reporting===
Exceptions in Guice 1.0 tend to include long chains of 'caused by'
exceptions. We've tidied this up! Now a single exception describes
concisely what Guice was doing when the problem occurred.
-==Introspection API==
+===Introspection API===
Like `java.lang.reflect`, but for Guice. It lets you rewrite a Module,
tweaking bindings programatically. It also lets you inspect a created
injector, and examine its bindings. This is intended to enable simpler,
more powerful extensions and tools for Guice.
-==Pluggable Type Converters==
+===Pluggable Type Converters===
Constant String bindings can be converted to arbitrary types (such as
dates, URLs, or colours) using pluggable type converters.
-==OSGi-friendly AOP==
+===OSGi-friendly AOP===
Guice does bytecode generation internally to implement AOP. In version
2.0, generated classes are loaded by a bridge classloader that works in
managed environments such as OSGi.
-==Type Resolution==
+===Type Resolution===
[http://groups.google.com/group/google-guice/browse_thread/thread/1355313a074d8094/88270edbbeae2df8
Parameterized injection points] allow you to inject types like `Reducer<T>`
or `Converter<A, B>`. Guice will figure out what `T` is and find the
binding for that type.
[http://publicobject.com/2008/11/guice-punches-erasure-in-face.html
TypeLiteral injection] means you can inject a `TypeLiteral<T>` into your
classes. Use this to reify
[http://java.sun.com/docs/books/tutorial/java/generics/erasure.html Java 5
type erasure]. The `TypeLiteral` class now includes library methods for
manual type resolution.
-=Changes since 1.0=
-
-[http://google-guice.googlecode.com/svn/trunk/latest-api-diffs/changes.html
JDiff
change report]
+==Migrating from Guice 1.0==
+Guice 2.0 breaks compatibility with Guice 1.0 as described below. See the
[http://google-guice.googlecode.com/svn/trunk/latest-api-diffs/changes.html
JDiff change report] for complete details.
-==Exception Types==
+===Exception Types===
In Guice 1.0, when a custom provider throws an unchecked exception,
sometimes Guice wraps the exception and sometimes it doesn't. This depends
on whether the provider is being called directly (via Provider.get()) or
indirectly (such as for injecting into another type).
In Guice 2.0, any time a provider or injection throws, Guice wraps it in
a !ProvisionException.
[http://publicobject.com/2008/04/future-guice-providers-that-throw.html
This rule is simpler], and it makes it easier to write fault-tolerant code
with Guice.
@@ -89,10 +91,10 @@
!ProvisionException, !ConfigurationException and !OutOfScopeException are
now public.
-==Abstract Types==
+===Abstract Types===
Guice doesn't support injecting into abstract types. The messaging around
this has been improved since 1.0, and some code that was silently failing
now throws exceptions.
-==Inner Classes==
+===Inner Classes===
Guice used to support constructor injection of nonstatic inner classes. So
this used to work, but it won't anymore:
{{{
public class FooTest extends TestCase {
@@ -106,14 +108,14 @@
}
}}}
-==Keys==
+===Keys===
Guice now
[http://publicobject.com/2008/06/integerclass-and-intclass-as-guice-keys.html
canonicalizes] primitive types (like `int.class`) and array types (like
`Integer[].class`) when they're used in Keys. It now supports wildcards
like `List<?>` in keys - use `...@provides` to bind these.
-==Annotation Implementations==
+===Annotation Implementations===
Guice 2.0 fixes the treatment of equals() and hashCode() for fieldless
annotations. Annotation implementations that don't implement equals() and
hashCode() may have worked in 1.0 but will be broken in 2.0.
-==Injector.getBinding==
+===Injector.getBinding===
Guice 2.0 throws an exception if the binding cannot be resolved. The old
version used to return null. To get the old behaviour, use
`injector.getBindings().get(key)`.
-==SPI Changes==
+===SPI Changes===
!SourceProviders have been replaced with `Binder.withSource` and
`Binder.skipSources`. These new methods are easier to call and test. They
don't require static initialization or static dependencies.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---