ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1732297 - in /ace/trunk/org.apache.ace.webui.vaadin: bnd.bnd src/org/apache/ace/webui/vaadin/Activator.java src/org/apache/ace/webui/vaadin/VaadinServlet.java
Date Thu, 25 Feb 2016 13:22:27 GMT
Author: jawi
Date: Thu Feb 25 13:22:27 2016
New Revision: 1732297

URL: http://svn.apache.org/viewvc?rev=1732297&view=rev
Log:
Some minor fixes:

- restore the productionMode functionality of Vaadin: this time, you can simply
  configure whether or not production mode should be used (instead of
  hardcoded to 'yes');
- suppress a couple of unnessary imports that are caused by the inlining of Bnd
  for accessing the OBR/repositories.


Modified:
    ace/trunk/org.apache.ace.webui.vaadin/bnd.bnd
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
    ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java

Modified: ace/trunk/org.apache.ace.webui.vaadin/bnd.bnd
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/bnd.bnd?rev=1732297&r1=1732296&r2=1732297&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/bnd.bnd (original)
+++ ace/trunk/org.apache.ace.webui.vaadin/bnd.bnd Thu Feb 25 13:22:27 2016
@@ -41,3 +41,8 @@ Bundle-Description: Provides the base AC
 Conditional-Package: \
 	biz.aQute*,\
 	aQute.*,\
+
+Import-Package: \
+	!org.osgi.service.component.annotations,\
+	!org.osgi.service.coordinator,\
+	*

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java?rev=1732297&r1=1732296&r2=1732297&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java (original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java Thu
Feb 25 13:22:27 2016
@@ -69,8 +69,6 @@ public class Activator extends Dependenc
             .setImplementation(new Object()));
 
         Properties props = new Properties();
-        // ACE-472 - put Vaadin in production mode...
-        props.put("init.productionMode", "true");
         props.put(HTTP_WHITEBOARD_SERVLET_PATTERN, VaadinServlet.DEFAULT_SERVLET_ENDPOINT.concat("/*"));
         props.put(HTTP_WHITEBOARD_CONTEXT_SELECT, ACE_WEBUI_WHITEBOARD_CONTEXT_SELECT_FILTER);
 

Modified: ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
URL: http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java?rev=1732297&r1=1732296&r2=1732297&view=diff
==============================================================================
--- ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
(original)
+++ ace/trunk/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
Thu Feb 25 13:22:27 2016
@@ -20,8 +20,14 @@ package org.apache.ace.webui.vaadin;
 
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Collections;
 import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
 
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
@@ -34,6 +40,7 @@ import com.vaadin.Application;
 import com.vaadin.Application.CustomizedSystemMessages;
 import com.vaadin.Application.SystemMessages;
 import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
+import com.vaadin.terminal.gwt.server.Constants;
 import com.vaadin.terminal.gwt.server.WebApplicationContext;
 
 public class VaadinServlet extends AbstractApplicationServlet implements ManagedService {
@@ -41,6 +48,10 @@ public class VaadinServlet extends Abstr
 
     private static final long serialVersionUID = 1L;
 
+    /** A boolean denoting whether or not to use production mode in Vaadin. */
+    private static final String KEY_USE_PRODUCTION_MODE = "vaadin.productionMode";
+    /** An int denoting the timeout in seconds to cache resources. */
+    private static final String KEY_RESOURCE_CACHE_TIME = "vaadin.cache.time";
     /** A boolean denoting whether or not authentication is enabled. */
     private static final String KEY_USE_AUTHENTICATION = "ui.authentication.enabled";
     /** Name of the user to log in as. */
@@ -59,6 +70,8 @@ public class VaadinServlet extends Abstr
     private static final String KEY_PAGE_LENGTH = "artifacts.page.length";
 
     private static final boolean DEFAULT_USE_AUTHENTICATION = false;
+    private static final int DEFAULT_RESOURCE_CACHE_TIME = 3600;
+    private static final boolean DEFAULT_USE_PRODUCTION_MODE = true;
     private static final String DEFAULT_USER_NAME = "";
     private static final String DEFAULT_PASSWORD = "";
     private static final URL DEFAULT_ACE_HOST;
@@ -79,6 +92,8 @@ public class VaadinServlet extends Abstr
     }
 
     private volatile DependencyManager m_manager;
+    private volatile boolean m_useProductionMode;
+    private volatile int m_resourceCacheTime;
     private volatile boolean m_useAuth;
     private volatile String m_userName;
     private volatile String m_password;
@@ -93,6 +108,8 @@ public class VaadinServlet extends Abstr
      * Creates a new {@link VaadinServlet} instance.
      */
     public VaadinServlet() {
+        m_useProductionMode = DEFAULT_USE_PRODUCTION_MODE;
+        m_resourceCacheTime = DEFAULT_RESOURCE_CACHE_TIME;
         m_useAuth = DEFAULT_USE_AUTHENTICATION;
         m_userName = DEFAULT_USER_NAME;
         m_password = DEFAULT_PASSWORD;
@@ -106,6 +123,8 @@ public class VaadinServlet extends Abstr
 
     @Override
     public void updated(Dictionary<String, ?> dictionary) throws ConfigurationException
{
+        boolean useProductionMode = DEFAULT_USE_PRODUCTION_MODE;
+        int resourceCacheTime = DEFAULT_RESOURCE_CACHE_TIME;
         boolean useAuth = DEFAULT_USE_AUTHENTICATION;
         String userName = DEFAULT_USER_NAME;
         String password = DEFAULT_PASSWORD;
@@ -117,6 +136,9 @@ public class VaadinServlet extends Abstr
         int pageLength = DEFAULT_PAGE_LENGTH;
 
         if (dictionary != null) {
+            useProductionMode = getBoolean(dictionary, KEY_USE_PRODUCTION_MODE);
+            resourceCacheTime = getInteger(dictionary, KEY_RESOURCE_CACHE_TIME);
+
             useAuth = getBoolean(dictionary, KEY_USE_AUTHENTICATION);
             userName = getOptionalString(dictionary, KEY_USER_NAME);
             password = getOptionalString(dictionary, KEY_USER_PASSWORD);
@@ -124,15 +146,15 @@ public class VaadinServlet extends Abstr
             obrUrl = getURL(dictionary, KEY_OBR_URL);
             repositoryXML = getOptionalString(dictionary, KEY_OBR_XML);
             sessionTimeout = getInteger(dictionary, KEY_SESSION_TIMEOUT);
-            
+
             Double doubleValue = getOptionalDouble(dictionary, KEY_CACHE_RATE);
             if (doubleValue != null) {
-                cacheRate = doubleValue.doubleValue(); 
+                cacheRate = doubleValue.doubleValue();
             }
 
             Integer intValue = getOptionalInteger(dictionary, KEY_PAGE_LENGTH);
             if (intValue != null) {
-                pageLength = intValue.intValue(); 
+                pageLength = intValue.intValue();
             }
         }
 
@@ -145,6 +167,8 @@ public class VaadinServlet extends Abstr
         }
 
         m_useAuth = useAuth;
+        m_useProductionMode = useProductionMode;
+        m_resourceCacheTime = resourceCacheTime;
         m_userName = userName;
         m_password = password;
         m_aceHost = aceHost;
@@ -156,6 +180,12 @@ public class VaadinServlet extends Abstr
     }
 
     @Override
+    public void init(ServletConfig servletConfig) throws ServletException {
+        // ACE-472 - allow Vaadin to be put in production mode by means of configuration...
+        super.init(new VaadinServletConfig(servletConfig));
+    }
+
+    @Override
     protected Class<? extends Application> getApplicationClass() {
         return VaadinClient.class;
     }
@@ -271,4 +301,41 @@ public class VaadinServlet extends Abstr
             throw new ConfigurationException(key, "Is not a valid URL", e);
         }
     }
+
+    private class VaadinServletConfig implements ServletConfig {
+        private final ServletConfig m_delegate;
+
+        public VaadinServletConfig(ServletConfig delegate) {
+            m_delegate = delegate;
+        }
+
+        @Override
+        public String getInitParameter(String name) {
+            if (Constants.SERVLET_PARAMETER_PRODUCTION_MODE.equals(name)) {
+                return Boolean.toString(m_useProductionMode);
+            }
+            else if (Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME.equals(name)) {
+                return Integer.toString(m_resourceCacheTime);
+            }
+            return m_delegate.getInitParameter(name);
+        }
+
+        @Override
+        public Enumeration<String> getInitParameterNames() {
+            Set<String> names = new HashSet<>(Collections.list(m_delegate.getInitParameterNames()));
+            names.add(Constants.SERVLET_PARAMETER_PRODUCTION_MODE);
+            names.add(Constants.SERVLET_PARAMETER_RESOURCE_CACHE_TIME);
+            return Collections.enumeration(names);
+        }
+
+        @Override
+        public ServletContext getServletContext() {
+            return m_delegate.getServletContext();
+        }
+
+        @Override
+        public String getServletName() {
+            return "Apache Ace Vaadin Web UI";
+        }
+    }
 }



Mime
View raw message