wink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jra...@apache.org
Subject svn commit: r1028032 - in /incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal: DeploymentConfiguration.java contexts/UriInfoImpl.java handlers/ServerMessageContext.java registry/ResourceRegistry.java
Date Wed, 27 Oct 2010 16:53:54 GMT
Author: jramos
Date: Wed Oct 27 16:53:54 2010
New Revision: 1028032

URL: http://svn.apache.org/viewvc?rev=1028032&view=rev
Log:
A few performance related changes

Modified:
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/UriInfoImpl.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/ServerMessageContext.java
    incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java?rev=1028032&r1=1028031&r2=1028032&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
Wed Oct 27 16:53:54 2010
@@ -138,6 +138,10 @@ public class DeploymentConfiguration imp
 
     private Set<ObjectFactory<?>>     appObjectFactories;
 
+    private boolean                   isUseAcceptCharset                  = false;
+
+    private boolean                   isDefaultResponseCharset            = false;
+
     /**
      * Makes sure that the object was properly initialized. Should be invoked
      * AFTER all the setters were invoked.
@@ -274,6 +278,10 @@ public class DeploymentConfiguration imp
 
     public void setProperties(Properties properties) {
         this.properties = properties;
+        String val = properties.getProperty(USE_ACCEPT_CHARSET);
+        isUseAcceptCharset = Boolean.valueOf(val).booleanValue();
+        val = properties.getProperty(DEFAULT_RESPONSE_CHARSET);
+        isDefaultResponseCharset = Boolean.valueOf(val).booleanValue();
     }
 
     public ServletConfig getServletConfig() {
@@ -399,11 +407,10 @@ public class DeploymentConfiguration imp
     @SuppressWarnings("unchecked")
     protected void initMediaTypeMapper() {
         if (mediaTypeMapper == null) {
-            mediaTypeMapper = new MediaTypeMapper();
-
             String mediaTypeMapperFactoryClassName =
                 properties.getProperty(MEDIATYPE_MAPPER_FACTORY_CLASS_PROP);
             if (mediaTypeMapperFactoryClassName != null) {
+                mediaTypeMapper = new MediaTypeMapper();
                 try {
                     logger.trace("MediaTypeMappingFactory Class is: {}", //$NON-NLS-1$
                                  mediaTypeMapperFactoryClassName);
@@ -652,12 +659,12 @@ public class DeploymentConfiguration imp
      * @return boolean
      */
     public boolean isDefaultResponseCharset() {
-        String val = properties.getProperty(DEFAULT_RESPONSE_CHARSET);
-        return Boolean.valueOf(val).booleanValue();
+        return isDefaultResponseCharset;
     }
 
     public void setDefaultResponseCharset(boolean val) {
         properties.setProperty(DEFAULT_RESPONSE_CHARSET, Boolean.toString(val));
+        isDefaultResponseCharset = val;
     }
 
     /**
@@ -670,12 +677,12 @@ public class DeploymentConfiguration imp
      * @return
      */
     public boolean isUseAcceptCharset() {
-        String val = properties.getProperty(USE_ACCEPT_CHARSET);
-        return Boolean.valueOf(val).booleanValue();
+        return isUseAcceptCharset;
     }
 
     public void setUseAcceptCharset(boolean val) {
         properties.setProperty(USE_ACCEPT_CHARSET, Boolean.toString(val));
+        isUseAcceptCharset = val;
     }
 
     public void addApplicationObjectFactory(ObjectFactory<?> of) {

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/UriInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/UriInfoImpl.java?rev=1028032&r1=1028031&r2=1028032&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/UriInfoImpl.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/UriInfoImpl.java
Wed Oct 27 16:53:54 2010
@@ -271,7 +271,14 @@ public class UriInfoImpl implements UriI
         MultivaluedMap<String, String> map = queryParameters;
         if (decode) {
             if (decodedQueryParameters == null) {
-                decodedQueryParameters = UriEncoder.decodeMultivaluedMapValues(queryParameters);
+                if (queryParameters.size() == 0) {
+                    /*
+                     * shortcut here if the query parameters don't exist
+                     */
+                    decodedQueryParameters = queryParameters;
+                } else {
+                    decodedQueryParameters = UriEncoder.decodeMultivaluedMapValues(queryParameters);
+                }
             }
             map = decodedQueryParameters;
         }

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/ServerMessageContext.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/ServerMessageContext.java?rev=1028032&r1=1028031&r2=1028032&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/ServerMessageContext.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/ServerMessageContext.java
Wed Oct 27 16:53:54 2010
@@ -89,7 +89,9 @@ public class ServerMessageContext extend
         setAttribute(DeploymentConfiguration.class, configuration);  // legacy
         setAttribute(ResourceRegistry.class, configuration.getResourceRegistry());
         setAttribute(ProvidersRegistry.class, configuration.getProvidersRegistry());
-        setAttribute(MediaTypeCharsetAdjuster.class, ServerMediaTypeCharsetAdjuster.getInstance());
+        if (configuration.isDefaultResponseCharset() || configuration.isUseAcceptCharset())
{
+            setAttribute(MediaTypeCharsetAdjuster.class, ServerMediaTypeCharsetAdjuster.getInstance());
+        }
 
         initContexts();
         List<Application> apps = configuration.getApplications();

Modified: incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java?rev=1028032&r1=1028031&r2=1028032&view=diff
==============================================================================
--- incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java
(original)
+++ incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java
Wed Oct 27 16:53:54 2010
@@ -560,8 +560,8 @@ public class ResourceRegistry {
         if (receivedMediaTypes.size() == 0) {
             return false;
         }
-        List<MediaType> deniableMediaTypes = new ArrayList<MediaType>();
-        List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
+        List<MediaType> deniableMediaTypes = new LinkedList<MediaType>();
+        List<MediaType> acceptableMediaTypes = new LinkedList<MediaType>();
 
         for (MediaType received : receivedMediaTypes) {
             String q = received.getParameters().get("q"); //$NON-NLS-1$



Mime
View raw message