Revision: 1120
Author: dhanji
Date: Tue Oct 20 01:02:21 2009
Log: fix for locking problem in old assisted inject.
http://code.google.com/p/google-guice/source/detail?r=1120
Modified:
/trunk/build.properties
/trunk/build.xml
/trunk/extensions/assistedinject/src/com/google/inject/assistedinject/Parameter.java
/trunk/src/com/google/inject/Injector.java
=======================================
--- /trunk/build.properties Mon May 18 17:58:48 2009
+++ /trunk/build.properties Tue Oct 20 01:02:21 2009
@@ -9,6 +9,7 @@
throwingproviders.src.dir=extensions/throwingproviders/src
multibindings.src.dir=extensions/multibindings/src
privatemodules.src.dir=extensions/privatemodules/src
+lifecycle.src.dir=lifecycle/src
build.dir=build
javadoc.packagenames=com.google.inject,com.google.inject.spi,\
com.google.inject.matcher,\
=======================================
--- /trunk/build.xml Sun Sep 27 19:51:24 2009
+++ /trunk/build.xml Tue Oct 20 01:02:21 2009
@@ -88,6 +88,8 @@
<pathelement location="lib/build/junit.jar"/>
<pathelement location="lib/build/servlet-api-2.5.jar"/>
<pathelement location="lib/build/easymock.jar"/>
+ <pathelement location="lib/javax.inject.jar"/>
+ <pathelement location="lib/build/javax.inject-tck.jar"/>
</classpath>
<arg value="com.google.inject.AllTests"/>
<syspropertyset>
@@ -113,6 +115,7 @@
<pathelement location="${jndi.src.dir}"/>
<pathelement location="${throwingproviders.src.dir}"/>
<pathelement location="${multibindings.src.dir}"/>
+ <pathelement location="${lifecycle.src.dir}"/>
</sourcepath>
<classpath refid="compile.classpath"/>
<classpath>
=======================================
---
/trunk/extensions/assistedinject/src/com/google/inject/assistedinject/Parameter.java
Mon Sep 7 14:00:57 2009
+++
/trunk/extensions/assistedinject/src/com/google/inject/assistedinject/Parameter.java
Tue Oct 20 01:02:21 2009
@@ -39,6 +39,8 @@
private final Annotation bindingAnnotation;
private final boolean isProvider;
+ private volatile Provider<? extends Object> provider;
+
public Parameter(Type type, Annotation[] annotations) {
this.type = type;
this.bindingAnnotation = getBindingAnnotation(annotations);
@@ -82,9 +84,17 @@
* Returns the Guice {...@link Key} for this parameter.
*/
public Object getValue(Injector injector) {
- return isProvider
- ? injector.getProvider(getBindingForType(getProvidedType(type)))
- : injector.getInstance(getPrimaryBindingKey());
+ if (null == provider) {
+ synchronized (this) {
+ if (null == provider) {
+ provider = isProvider
+ ?
injector.getProvider(getBindingForType(getProvidedType(type)))
+ : injector.getProvider(getPrimaryBindingKey());
+ }
+ }
+ }
+
+ return provider.get();
}
public boolean isBound(Injector injector) {
=======================================
--- /trunk/src/com/google/inject/Injector.java Thu Jul 23 17:48:12 2009
+++ /trunk/src/com/google/inject/Injector.java Tue Oct 20 01:02:21 2009
@@ -227,7 +227,7 @@
/**
* Returns a map containing all scopes in the injector. The maps keys
are scoping annotations
* like {...@code Singleton.class}, and the values are scope instances,
such as {...@code
- * Scopes.SINGLETON. The returned map is immutable.
+ * Scopes.SINGLETON}. The returned map is immutable.
*
* <p>This method is part of the Guice SPI and is intended for use by
tools and extensions.
*/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---