You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2010/01/08 23:24:28 UTC

svn commit: r897336 - in /incubator/wookie/trunk/src/org/apache/wookie: feature/ feature/conformance/ feature/polling/ feature/polling/impl/ feature/wave/ util/

Author: scottbw
Date: Fri Jan  8 22:24:27 2010
New Revision: 897336

URL: http://svn.apache.org/viewvc?rev=897336&view=rev
Log:
Altered the IFeature interface to be a bit more flexible and less tied into DWR - now just returns the feature IRI, array of scripts to include and array of stylesheets to include when processing using the StartPageJSParser.

Added:
    incubator/wookie/trunk/src/org/apache/wookie/feature/polling/Polling.java
      - copied, changed from r887150, incubator/wookie/trunk/src/org/apache/wookie/feature/polling/impl/WookiePollingImpl.java
Removed:
    incubator/wookie/trunk/src/org/apache/wookie/feature/polling/IWookiePolling.java
    incubator/wookie/trunk/src/org/apache/wookie/feature/polling/impl/
Modified:
    incubator/wookie/trunk/src/org/apache/wookie/feature/IFeature.java
    incubator/wookie/trunk/src/org/apache/wookie/feature/conformance/Test.java
    incubator/wookie/trunk/src/org/apache/wookie/feature/wave/IWaveAPI.java
    incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java
    incubator/wookie/trunk/src/org/apache/wookie/util/IStartPageConfiguration.java
    incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java

Modified: incubator/wookie/trunk/src/org/apache/wookie/feature/IFeature.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/IFeature.java?rev=897336&r1=897335&r2=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/IFeature.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/IFeature.java Fri Jan  8 22:24:27 2010
@@ -16,12 +16,23 @@
 
 /**
  * Interface supported by features
- * @author scott
- *
  */
 public interface IFeature {
 	
-	public String getJavaScriptWrapper();
-	public String getJavaScriptImpl();
+	/**
+	 * The name (IRI) of the feature
+	 * @return
+	 */
+	public String getName();
+	/**
+	 * An array of Strings representing the path to each script required by the feature
+	 * @return
+	 */
+	public String[] scripts();
+	/**
+	 * An array of Strings representing the path to each stylesheet required by the feature
+	 * @return
+	 */
+	public String[] stylesheets();
 
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/feature/conformance/Test.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/conformance/Test.java?rev=897336&r1=897335&r2=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/conformance/Test.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/conformance/Test.java Fri Jan  8 22:24:27 2010
@@ -22,12 +22,16 @@
  *
  */
 public class Test implements IFeature {
+	
+	public String getName() {
+		return "feature:a9bb79c1";
+	}
 
-	public String getJavaScriptImpl() {
+	public String[] scripts() {
 		return null;
 	}
 
-	public String getJavaScriptWrapper() {
+	public String[] stylesheets() {
 		return null;
 	}
 

Copied: incubator/wookie/trunk/src/org/apache/wookie/feature/polling/Polling.java (from r887150, incubator/wookie/trunk/src/org/apache/wookie/feature/polling/impl/WookiePollingImpl.java)
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/polling/Polling.java?p2=incubator/wookie/trunk/src/org/apache/wookie/feature/polling/Polling.java&p1=incubator/wookie/trunk/src/org/apache/wookie/feature/polling/impl/WookiePollingImpl.java&r1=887150&r2=897336&rev=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/polling/impl/WookiePollingImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/polling/Polling.java Fri Jan  8 22:24:27 2010
@@ -12,9 +12,10 @@
  * limitations under the License.
  */
 
-package org.apache.wookie.feature.polling.impl;
+package org.apache.wookie.feature.polling;
+
+import org.apache.wookie.feature.IFeature;
 
-import org.apache.wookie.feature.polling.IWookiePolling;
 /**
  * Polling Support - turned on by using a 
  * <feature name="http://www.getwookie.org/usefeature/polling"> tag in the manifest file
@@ -22,14 +23,17 @@
  * @author Paul Sharples
  * @version $Id: WookiePollingImpl.java,v 1.2 2009-07-28 16:05:23 scottwilson Exp $ 
  */
-public class WookiePollingImpl implements IWookiePolling {
-
-	public String getJavaScriptImpl() {		
-		return null;
+public class Polling implements IFeature{
+	
+	public String getName() {
+		return "http://www.getwookie.org/usefeature/polling";
 	}
 
-	public String getJavaScriptWrapper() {
-		return "/wookie/shared/js/wookie-polling-feature.js";
+	public String[] scripts() {
+		return new String[]{"/wookie/shared/js/wookie-polling-feature.js"};
 	}
 
+	public String[] stylesheets() {
+		return null;
+	}
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/feature/wave/IWaveAPI.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/wave/IWaveAPI.java?rev=897336&r1=897335&r2=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/wave/IWaveAPI.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/wave/IWaveAPI.java Fri Jan  8 22:24:27 2010
@@ -16,13 +16,10 @@
 
 import java.util.Map;
 
-import org.apache.wookie.feature.IFeature;
-
 /**
- * @author scott
- *
+ * Wave API - see http://code.google.com/apis/wave/extensions/gadgets/reference.html
  */
-public interface IWaveAPI extends IFeature{
+public interface IWaveAPI{
 	
 	/**
 	 * Submits a map of key/value pairs for shared state
@@ -38,11 +35,26 @@
 	 */
 	public Map<String, String> state(String id_key);
 	
-	
+	/**
+	 * Returns the viewer (current user) of the widget
+	 * @param id_key
+	 * @return
+	 */
 	public String getViewer(String id_key);
 	
+	/**
+	 * Returns all participants of the widget and its siblings
+	 * @param id_key
+	 * @return
+	 */
 	public String getParticipants(String id_key);
 	
+	/**
+	 * Returns the host (owner) of the widget, typically the
+	 * owner of the context in which it has been instantiated
+	 * @param id_key
+	 * @return
+	 */
 	public String getHost(String id_key);
 
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java?rev=897336&r1=897335&r2=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/wave/WaveAPIImpl.java Fri Jan  8 22:24:27 2010
@@ -26,6 +26,7 @@
 import org.apache.wookie.beans.SharedData;
 import org.apache.wookie.beans.WidgetInstance;
 import org.apache.wookie.controller.PropertiesController;
+import org.apache.wookie.feature.IFeature;
 import org.apache.wookie.helpers.ParticipantHelper;
 import org.apache.wookie.server.LocaleHandler;
 import org.directwebremoting.ScriptBuffer;
@@ -37,33 +38,22 @@
  * @author scott
  *
  */
-public class WaveAPIImpl implements IWaveAPI{
+public class WaveAPIImpl implements IFeature, IWaveAPI{
 
-	/**
-	 * 
-	 */
 	public WaveAPIImpl() {
 	}
 	
-	
-
-	/* (non-Javadoc)
-	 * @see org.apache.wookie.feature.IFeature#getJavaScriptImpl()
-	 */
-	public String getJavaScriptImpl() {
-		return "/wookie/dwr/interface/WaveImpl.js";
+	public String getName() {
+		return "http://wave.google.com";
 	}
 
-
-
-	/* (non-Javadoc)
-	 * @see org.apache.wookie.feature.IFeature#getJavaScriptWrapper()
-	 */
-	public String getJavaScriptWrapper() {
-		return "/wookie/shared/js/wave.js";
+	public String[] scripts() {
+		return new String[]{"/wookie/dwr/interface/WaveImpl.js", "/wookie/shared/js/wave.js"};
 	}
 
-
+	public String[] stylesheets() {
+		return null;
+	}
 
 	/* (non-Javadoc)
 	 * @see org.apache.wookie.feature.wave.IWaveAPI#getHost(java.lang.String)

Modified: incubator/wookie/trunk/src/org/apache/wookie/util/IStartPageConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/IStartPageConfiguration.java?rev=897336&r1=897335&r2=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/IStartPageConfiguration.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/IStartPageConfiguration.java Fri Jan  8 22:24:27 2010
@@ -23,9 +23,14 @@
 public interface IStartPageConfiguration {
 	final String HEAD_TAG = "head";
 	final String SCRIPT_TAG = "script";	
+	final String LINK_TAG = "link";	
 	final String TYPE_ATTRIBUTE = "type";
 	final String TYPE_ATTRIBUTE_VALUE = "text/javascript";	
+	final String CSS_TYPE_ATTRIBUTE_VALUE = "text/css";	
+	final String REL_ATTRIBUTE = "rel";		
+	final String CSS_REL_ATTRIBUTE_VALUE = "stylesheet";	
 	final String SRC_ATTRIBUTE = "src";	
+	final String HREF_ATTRIBUTE = "href";	
 	final String DWR_UTIL_SRC_VALUE = "/wookie/dwr/util.js";
 	final String DWR_ENGINE_SRC_VALUE = "/wookie/dwr/engine.js";
 	final String WIDGET_IMPL_SRC_VALUE = "/wookie/dwr/interface/WidgetImpl.js";

Modified: incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java?rev=897336&r1=897335&r2=897336&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java Fri Jan  8 22:24:27 2010
@@ -74,6 +74,14 @@
 		return js;
 	}
 	
+	private TagNode createStylesheetTag(String srcAttribute){
+		TagNode js = new TagNode(LINK_TAG);
+		js.addAttribute(TYPE_ATTRIBUTE, CSS_TYPE_ATTRIBUTE_VALUE);
+		js.addAttribute(REL_ATTRIBUTE, CSS_REL_ATTRIBUTE_VALUE);
+		js.addAttribute(HREF_ATTRIBUTE, srcAttribute);
+		return js;
+	}
+	
 	@SuppressWarnings("unchecked")
 	private void findNonWookieScriptTags(TagNode headNode){		
 		List<TagNode> children = headNode.getChildren();		
@@ -143,16 +151,20 @@
 						try {
 							klass = (Class<? extends IFeature>) Class.forName(sf.getClassName());
 							IFeature theFeature = (IFeature) klass.newInstance();
-							if(theFeature.getJavaScriptImpl() != null){
-								if(!doesAttributeValueExistsInNode(headNode, SRC_ATTRIBUTE, theFeature.getJavaScriptImpl())){
-									TagNode jsTag = createScriptTag(theFeature.getJavaScriptImpl());
-									headNode.addChild(jsTag);
+							if (theFeature.scripts() != null){
+								for (String script: theFeature.scripts()){
+									if(!doesAttributeValueExistsInNode(headNode, SRC_ATTRIBUTE, script)){
+										TagNode jsTag = createScriptTag(script);
+										headNode.addChild(jsTag);
+									}
 								}
 							}
-							if(theFeature.getJavaScriptWrapper() != null){
-								if(!doesAttributeValueExistsInNode(headNode, SRC_ATTRIBUTE, theFeature.getJavaScriptWrapper())){
-									TagNode jsTag = createScriptTag(theFeature.getJavaScriptWrapper());
-									headNode.addChild(jsTag);
+							if (theFeature.stylesheets() != null){
+								for (String style: theFeature.stylesheets()){
+									if(!doesAttributeValueExistsInNode(headNode, HREF_ATTRIBUTE, style)){
+										TagNode cssTag = createStylesheetTag(style);
+										headNode.addChild(cssTag);
+									}
 								}
 							}
 						} catch (Exception e) {