Author: lindner
Date: Fri Aug 27 20:50:34 2010
New Revision: 990263
URL: http://svn.apache.org/viewvc?rev=990263&view=rev
Log:
Patch from Han Nguyen | Convenient way to set shindig.host and shindig.port in
web.xm
Modified:
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/GuiceServletContextListener.java
shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
Modified:
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/GuiceServletContextListener.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/GuiceServletContextListener.java?rev=990263&r1=990262&r2=990263&view=diff
==============================================================================
---
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/GuiceServletContextListener.java
(original)
+++
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/servlet/GuiceServletContextListener.java
Fri Aug 27 20:50:34 2010
@@ -43,11 +43,15 @@ public class GuiceServletContextListener
// From guice-servlet-2.0
public static final String INJECTOR_NAME = Injector.class.getName();
-
+
+ //HNN- constant name matched system.properties <contextparam> specified in
the web.xml
+ private static final String SYSTEM_PROPERTIES = "system.properties";
private boolean jmxInitialized = false;
public void contextInitialized(ServletContextEvent event) {
ServletContext context = event.getServletContext();
+ //HNN setting all system.properties specified in the web.xml
+ setSystemProperties(context);
String moduleNames = context.getInitParameter(MODULES_ATTRIBUTE);
List<Module> modules = Lists.newLinkedList();
if (moduleNames != null) {
@@ -83,5 +87,29 @@ public class GuiceServletContextListener
ServletContext context = event.getServletContext();
context.removeAttribute(INJECTOR_ATTRIBUTE);
}
+
+ /**
+ * This method sets all the (key,value) properties specified in the web.xml
<contextparam> system.properties element
+ * if they are not empty.
+ * @param context
+ */
+ private void setSystemProperties(ServletContext context){
+ String systemProperties = context.getInitParameter(SYSTEM_PROPERTIES);
+ String key=null;
+ String value=null;
+ if(systemProperties!=null && systemProperties.trim().length()>0){
+ for (String aProperty : StringUtils.split(systemProperties, '\n')){
+ String[] keyAndvalue = StringUtils.split(aProperty.trim(), "=",2);
+ if(keyAndvalue.length==2){
+ key=keyAndvalue[0];
+ value=keyAndvalue[1];
+ //set the system property if they are not empty
+ if(key!=null && key.trim().length()>0 && value!=null &&
value.trim().length()>0){
+ System.setProperty(key,value);
+ }
+ }
+ }
+ }
+ }
}
Modified: shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml?rev=990263&r1=990262&r2=990263&view=diff
==============================================================================
--- shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml (original)
+++ shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml Fri Aug 27
20:50:34 2010
@@ -43,6 +43,30 @@
</param-value>
</context-param>
+ <!--
+ Syntax: <key>=<value> separated by a newline
+
+ system.properties specifies the environmental variables that will be set to
the JVM System Properties at server startup time.
+ Alternatively, you may add these values in your app server (ex: Tomcat) as
+ VM arguments like this: -Dshindig.host="my.production.shindig.server.com".
+
+ Here are a few properties that can be set for Shindig:
+ shindig.host: the server name that Shindig is deployed and running on
+ shindig.port: the port number of shindig.host server
+
+ Make sure you escape all HTML values for the web.xml to be parsed correctly.
+ -->
+ <context-param>
+ <param-name>system.properties</param-name>
+ <param-value>
+ shindig.host=localhost
+
+ aKey=/shindig/gadgets/proxy?container=default&url=
+ shindig.port=
+
+ </param-value>
+ </context-param>
+
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>