You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2009/11/26 17:37:25 UTC

svn commit: r884632 - /cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ConstructorInjectingProvider.java

Author: aadamchik
Date: Thu Nov 26 16:37:25 2009
New Revision: 884632

URL: http://svn.apache.org/viewvc?rev=884632&view=rev
Log:
CAY-1319 Switch Cayenne configuration loading to cayenne-di container

* java 6 build failures

Modified:
    cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ConstructorInjectingProvider.java

Modified: cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ConstructorInjectingProvider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ConstructorInjectingProvider.java?rev=884632&r1=884631&r2=884632&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ConstructorInjectingProvider.java (original)
+++ cayenne/main/trunk/framework/cayenne-di-unpublished/src/main/java/org/apache/cayenne/di/spi/ConstructorInjectingProvider.java Thu Nov 26 16:37:25 2009
@@ -37,8 +37,8 @@
     private Constructor<? extends T> constructor;
     private DefaultInjector injector;
 
-    ConstructorInjectingProvider(Class<T> interfaceType, Class<? extends T> implementation,
-            DefaultInjector injector) {
+    ConstructorInjectingProvider(Class<T> interfaceType,
+            Class<? extends T> implementation, DefaultInjector injector) {
 
         initConstructor(implementation);
 
@@ -55,16 +55,14 @@
 
     private void initConstructor(Class<? extends T> implementation) {
 
-        Constructor<? extends T>[] constructors = implementation
-                .getDeclaredConstructors();
-
-        Constructor<? extends T> lastMatch = null;
+        Constructor<?>[] constructors = implementation.getDeclaredConstructors();
+        Constructor<?> lastMatch = null;
         int lastSize = -1;
 
         // pick the first constructor with all injection-annotated parameters, or the
         // default constructor; constructor with the longest parameter list is preferred
         // if multiple matches are found
-        for (Constructor<? extends T> constructor : constructors) {
+        for (Constructor<?> constructor : constructors) {
 
             int size = constructor.getParameterTypes().length;
             if (size <= lastSize) {
@@ -100,7 +98,9 @@
             }
         }
 
-        this.constructor = lastMatch;
+        // the cast is lame, but Class.getDeclaredConstructors() is not using proper
+        // generics
+        this.constructor = (Constructor<? extends T>) lastMatch;
     }
 
     public T get() {