wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r818312 - /incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
Date Wed, 23 Sep 2009 23:15:15 GMT
Author: bluk
Date: Wed Sep 23 23:15:15 2009
New Revision: 818312

URL: http://svn.apache.org/viewvc?rev=818312&view=rev
Log:
Always choose user providers over system

In cases where there is a user MessageBodyWriter<Object>
and a system MessageBodyWriter<String> and a String
is the response object, still check the user
provider before the system.

Modified:
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java?rev=818312&r1=818311&r2=818312&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ProvidersRegistry.java
Wed Sep 23 23:15:15 2009
@@ -631,7 +631,28 @@
                 return of.getInstanceClass();
             }
 
+            private static final double MAX_SYSTEM_PRIORITY = WinkApplication.SYSTEM_PRIORITY;
+
             public int compareTo(OFHolder<T> o) {
+                // check if this is a system provider
+                // system providers are less than
+                // WinkApplication.SYSTEM_PRIORITY + 0.1 (they start at
+                // WinkApplication.SYSTEM_PRIORITY and
+                // unless there are 10000000000, this shouldn't matter)
+                if (of.priority < MAX_SYSTEM_PRIORITY) {
+                    // this is a system provider
+                    if (o.of.priority > MAX_SYSTEM_PRIORITY) {
+                        // the other is a user provider so this is > 0.2
+                        return -1;
+                    }
+                } else if (o.of.priority < MAX_SYSTEM_PRIORITY) {
+                    // the other is a system provider
+                    if (of.priority > MAX_SYSTEM_PRIORITY) {
+                        // this is a user provider
+                        return 1;
+                    }
+                }
+
                 // first compare by media type
                 int compare = MediaTypeUtils.compareTo(mediaType, o.mediaType);
                 if (compare != 0) {



Mime
View raw message