commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joc...@apache.org
Subject svn commit: r1637905 - in /commons/sandbox/commons-inject/trunk: ./ .settings/ src/main/java/org/apache/commons/inject/api/ src/main/java/org/apache/commons/inject/impl/
Date Mon, 10 Nov 2014 16:11:01 GMT
Author: jochen
Date: Mon Nov 10 16:11:00 2014
New Revision: 1637905

URL: http://svn.apache.org/r1637905
Log:
Fixed a bug when a point/provider wasn't initialized.

Modified:
    commons/sandbox/commons-inject/trunk/.settings/org.eclipse.core.resources.prefs
    commons/sandbox/commons-inject/trunk/pom.xml
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/InjLogger.java
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractScopedProvider.java
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultProvider.java
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/FieldPoint.java
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/ListPoint.java
    commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/MethodPoint.java

Modified: commons/sandbox/commons-inject/trunk/.settings/org.eclipse.core.resources.prefs
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/.settings/org.eclipse.core.resources.prefs?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/.settings/org.eclipse.core.resources.prefs (original)
+++ commons/sandbox/commons-inject/trunk/.settings/org.eclipse.core.resources.prefs Mon Nov
10 16:11:00 2014
@@ -1,6 +1,6 @@
 eclipse.preferences.version=1
 encoding//src/main/java=iso-8859-1
-encoding//src/main/resources=1.6
+encoding//src/main/resources=UTF-8
 encoding//src/test/java=iso-8859-1
-encoding//src/test/resources=1.6
+encoding//src/test/resources=UTF-8
 encoding/<project>=UTF-8

Modified: commons/sandbox/commons-inject/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/pom.xml?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/pom.xml (original)
+++ commons/sandbox/commons-inject/trunk/pom.xml Mon Nov 10 16:11:00 2014
@@ -88,6 +88,24 @@
   			</plugin>
   		</plugins>
   	</pluginManagement>
+  	<plugins>
+	  <plugin>
+  		<groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>2.4</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar-no-fork</goal>
+            </goals>
+            <configuration>
+              <attach>true</attach>
+            </configuration>
+          </execution>
+        </executions>
+       </plugin>
+  	</plugins>
   </build>
   <properties>
   	<maven.compile.target>1.6</maven.compile.target>

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/InjLogger.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/InjLogger.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/InjLogger.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/InjLogger.java
Mon Nov 10 16:11:00 2014
@@ -21,5 +21,5 @@ import java.lang.annotation.RetentionPol
 
 @Retention(RetentionPolicy.RUNTIME)
 public @interface InjLogger {
-	String id();
+	String id() default "";
 }

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
Mon Nov 10 16:11:00 2014
@@ -20,7 +20,7 @@ import org.apache.commons.inject.api.IIn
 import org.apache.commons.inject.api.IPoint;
 import org.apache.commons.inject.api.IProvider;
 
-public abstract class AbstractBaseProvider<T> implements IProvider<T> {
+public abstract class AbstractBaseProvider<T> implements IProvider<T>, IInjectorAware
{
 	private final Class<T> type;
 	private final IPoint<T> point;
 
@@ -40,4 +40,13 @@ public abstract class AbstractBaseProvid
 	public Class<T> getType() {
 		return type;
 	}
+
+	@Override
+	public void init(IInjector pInjector) {
+		if (point instanceof IInjectorAware) {
+			((IInjectorAware) point).init(pInjector);
+		}
+	}
+
+
 }

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractScopedProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractScopedProvider.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractScopedProvider.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractScopedProvider.java
Mon Nov 10 16:11:00 2014
@@ -22,6 +22,7 @@ import org.apache.commons.inject.api.IPr
 public abstract class AbstractScopedProvider<T> implements IProvider<T>, IInjectorAware
{
 	private final IProvider<T> baseProvider;
 	private IInjector injector;
+	protected boolean initialized;
 
 	public AbstractScopedProvider(IProvider<T> pBaseProvider) {
 		baseProvider = pBaseProvider;
@@ -56,5 +57,6 @@ public abstract class AbstractScopedProv
 		if (baseProvider instanceof IInjectorAware) {
 			((IInjectorAware) baseProvider).init(pInjector);
 		}
+		initialized = true;
 	}
 }

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultProvider.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultProvider.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultProvider.java
Mon Nov 10 16:11:00 2014
@@ -27,7 +27,8 @@ public class DefaultProvider<T> extends 
 	@Override
 	public T get() {
 		try {
-			return getType().newInstance();
+			final T t = getType().newInstance();
+			return t;
 		} catch (Throwable t) {
 			throw Exceptions.show(t);
 		}

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/FieldPoint.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/FieldPoint.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/FieldPoint.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/FieldPoint.java
Mon Nov 10 16:11:00 2014
@@ -23,7 +23,7 @@ import org.apache.commons.inject.api.IIn
 import org.apache.commons.inject.api.IPoint;
 import org.apache.commons.inject.util.Exceptions;
 
-public class FieldPoint<T> implements IPoint<T> {
+public class FieldPoint<T> implements IPoint<T>, IInjectorAware {
 	private final IBinding<Object> binding;
 	private final Field f;
 
@@ -38,9 +38,17 @@ public class FieldPoint<T> implements IP
 			if (!f.isAccessible()) {
 				f.setAccessible(true);
 			}
-			f.set(pInstance, binding.getProvider().get());
+			final Object value = binding.getProvider().get();
+			f.set(pInstance, value);
 		} catch (Throwable t) {
 			throw Exceptions.show(t);
 		}
 	}
+
+	@Override
+	public void init(IInjector pInjector) {
+		if (binding instanceof IInjectorAware) {
+			((IInjectorAware) binding).init(pInjector);
+		}
+	}
 }
\ No newline at end of file

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/ListPoint.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/ListPoint.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/ListPoint.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/ListPoint.java
Mon Nov 10 16:11:00 2014
@@ -21,7 +21,7 @@ import java.util.List;
 import org.apache.commons.inject.api.IInjector;
 import org.apache.commons.inject.api.IPoint;
 
-public class ListPoint<T> implements IPoint<T> {
+public class ListPoint<T> implements IPoint<T>, IInjectorAware {
 	private final List<IPoint<T>> list;
 	
 	public ListPoint(List<IPoint<T>> pPoints) {
@@ -40,4 +40,13 @@ public class ListPoint<T> implements IPo
 		}
 	}
 
+	@Override
+	public void init(IInjector pInjector) {
+		for (IPoint<T> point : list) {
+			if (point instanceof IInjectorAware) {
+				((IInjectorAware) point).init(pInjector);
+			}
+		}
+	}
+
 }

Modified: commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/MethodPoint.java
URL: http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/MethodPoint.java?rev=1637905&r1=1637904&r2=1637905&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/MethodPoint.java
(original)
+++ commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/MethodPoint.java
Mon Nov 10 16:11:00 2014
@@ -23,7 +23,7 @@ import org.apache.commons.inject.api.IIn
 import org.apache.commons.inject.api.IPoint;
 import org.apache.commons.inject.util.Exceptions;
 
-public class MethodPoint<T> implements IPoint<T> {
+public class MethodPoint<T> implements IPoint<T>, IInjectorAware {
 	private final IBinding<Object>[] bindings;
 	private final Method method;
 
@@ -47,4 +47,13 @@ public class MethodPoint<T> implements I
 			throw Exceptions.show(t);
 		}
 	}
+
+	@Override
+	public void init(IInjector pInjector) {
+		for (IBinding<Object> binding : bindings) {
+			if (binding instanceof IInjectorAware) {
+				((IInjectorAware) binding).init(pInjector);
+			}
+		}
+	}
 }



Mime
View raw message