wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r818311 - in /incubator/wink/trunk: wink-client/src/main/java/org/apache/wink/client/ wink-common/src/main/java/org/apache/wink/common/ wink-server/src/main/java/org/apache/wink/server/internal/ wink-server/src/main/java/org/apache/wink/ser...
Date Wed, 23 Sep 2009 23:14:49 GMT
Author: bluk
Date: Wed Sep 23 23:14:49 2009
New Revision: 818311

URL: http://svn.apache.org/viewvc?rev=818311&view=rev
Log:
Make the system priority explicit when adding

Explicit when loading system providers

Modified:
    incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java
    incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/WinkApplication.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java

Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java?rev=818311&r1=818310&r2=818311&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java
(original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java
Wed Sep 23 23:14:49 2009
@@ -93,7 +93,7 @@
 
                 @Override
                 public double getPriority() {
-                    return 0.1;
+                    return WinkApplication.SYSTEM_PRIORITY;
                 }
             });
         } catch (FileNotFoundException e) {

Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/WinkApplication.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/WinkApplication.java?rev=818311&r1=818310&r2=818311&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/WinkApplication.java
(original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/WinkApplication.java
Wed Sep 23 23:14:49 2009
@@ -32,6 +32,8 @@
 
     public static final double DEFAULT_PRIORITY = 0.5;
 
+    public static final double SYSTEM_PRIORITY  = 0.1;
+
     @Override
     public Set<Class<?>> getClasses() {
         return Collections.emptySet();

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java?rev=818311&r1=818310&r2=818311&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
Wed Sep 23 23:14:49 2009
@@ -33,6 +33,7 @@
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
+import org.apache.wink.common.WinkApplication;
 import org.apache.wink.common.internal.i18n.Messages;
 import org.apache.wink.common.internal.runtime.RuntimeContextTLS;
 import org.apache.wink.server.internal.application.ServletApplicationFileLoader;
@@ -78,7 +79,10 @@
             final Set<Class<?>> classes =
                 new ServletApplicationFileLoader(Boolean.parseBoolean(loadWinkApplicationsProperty))
                     .getClasses();
-            configuration.addApplication(new RegistrationUtils.InnerApplication(classes));
+            RegistrationUtils.InnerApplication application =
+                new RegistrationUtils.InnerApplication(classes);
+            application.setPriority(WinkApplication.SYSTEM_PRIORITY);
+            configuration.addApplication(application);
         } catch (FileNotFoundException e) {
             throw new WebApplicationException(e);
         }
@@ -91,7 +95,7 @@
         if (registerRootResource.equals(PROPERTY_ROOT_RESOURCE_ATOM)) {
             RegistrationUtils.InnerApplication application =
                 new RegistrationUtils.InnerApplication(RootResource.class);
-            application.setPriority(0.1);
+            application.setPriority(WinkApplication.SYSTEM_PRIORITY);
             configuration.addApplication(application);
         } else if (registerRootResource.equals(PROPERTY_ROOT_RESOURCE_NONE)) {
             // do nothing
@@ -103,7 +107,7 @@
             }
             RegistrationUtils.InnerApplication application =
                 new RegistrationUtils.InnerApplication(instance);
-            application.setPriority(0.1);
+            application.setPriority(WinkApplication.SYSTEM_PRIORITY);
             configuration.addApplication(application);
         }
     }

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java?rev=818311&r1=818310&r2=818311&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
Wed Sep 23 23:14:49 2009
@@ -64,16 +64,21 @@
     public void process() {
         logger.debug("Processing Application:");
 
+        double priority = WinkApplication.DEFAULT_PRIORITY;
+        if (application instanceof WinkApplication) {
+            priority = ((WinkApplication)application).getPriority();
+        }
+
         // process singletons
         Set<Object> singletons = application.getSingletons();
         if (singletons != null && singletons.size() > 0) {
-            processSingletons(singletons);
+            processSingletons(singletons, priority);
         }
 
         // process classes
         Set<Class<?>> classes = application.getClasses();
         if (classes != null && classes.size() > 0) {
-            processClasses(classes);
+            processClasses(classes, priority);
         }
 
         if (application instanceof WinkApplication) {
@@ -117,7 +122,7 @@
         }
     }
 
-    private void processClasses(Set<Class<?>> classes) {
+    private void processClasses(Set<Class<?>> classes, double priority) {
 
         for (Class<?> cls : classes) {
             try {
@@ -126,9 +131,9 @@
                 // the validations were moved to registry
 
                 if (ResourceMetadataCollector.isStaticResource(cls)) {
-                    resourceRegistry.addResource(cls);
+                    resourceRegistry.addResource(cls, priority);
                 } else if (ProviderMetadataCollector.isProvider(cls)) {
-                    providersRegistry.addProvider(cls);
+                    providersRegistry.addProvider(cls, priority);
                 } else {
                     logger.warn(Messages.getMessage("classNotAResourceNorProvider"), cls);
                 }
@@ -139,7 +144,7 @@
         }
     }
 
-    private void processSingletons(Set<Object> singletons) {
+    private void processSingletons(Set<Object> singletons, double priority) {
 
         // add singletons
         for (Object obj : singletons) {
@@ -149,9 +154,9 @@
                 Class<?> cls = obj.getClass();
 
                 if (ResourceMetadataCollector.isStaticResource(cls)) {
-                    resourceRegistry.addResource(obj);
+                    resourceRegistry.addResource(obj, priority);
                 } else if (ProviderMetadataCollector.isProvider(cls)) {
-                    providersRegistry.addProvider(obj);
+                    providersRegistry.addProvider(obj, priority);
                 } else {
                     logger.warn(Messages.getMessage("classNotAResourceNorProvider"), obj);
                 }



Mime
View raw message