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.
git-svn-id: https://svn.apache.org/repos/asf/ace/trunk@1732297 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.ace.webui.vaadin/bnd.bnd b/org.apache.ace.webui.vaadin/bnd.bnd
index 2e2dbe0..ec2e0c5 100644
--- a/org.apache.ace.webui.vaadin/bnd.bnd
+++ b/org.apache.ace.webui.vaadin/bnd.bnd
@@ -41,3 +41,8 @@
Conditional-Package: \
biz.aQute*,\
aQute.*,\
+
+Import-Package: \
+ !org.osgi.service.component.annotations,\
+ !org.osgi.service.coordinator,\
+ *
diff --git a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
index cf4404a..76aca9e 100644
--- a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
+++ b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/Activator.java
@@ -69,8 +69,6 @@
.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);
diff --git a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
index 0c27a07..ea74e4a 100644
--- a/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
+++ b/org.apache.ace.webui.vaadin/src/org/apache/ace/webui/vaadin/VaadinServlet.java
@@ -20,8 +20,14 @@
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.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 @@
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 @@
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 @@
}
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 @@
* 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 @@
@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 @@
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 @@
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 @@
}
m_useAuth = useAuth;
+ m_useProductionMode = useProductionMode;
+ m_resourceCacheTime = resourceCacheTime;
m_userName = userName;
m_password = password;
m_aceHost = aceHost;
@@ -156,6 +180,12 @@
}
@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 @@
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";
+ }
+ }
}