Author: scottbw
Date: Mon Jul 18 13:13:54 2011
New Revision: 1147849
URL: http://svn.apache.org/viewvc?rev=1147849&view=rev
Log:
Split the Wookie-specific extensions to the Widget object from the
implementation of the W3C standard interface (see WOOKIE-225). This means that
any widgets that want to use the non-standard extensions must include the
wookie/ext feature in their config.xml. Note that the "setPreference..." method
is included in IWidgetAPI - this is because we still need some sort of "post"
mechanism in the Widget interface; this could be removed in future and replaced
with a basic XHR operation, which would remove the need for DWR libraries in
most widgets.
Added:
incubator/wookie/trunk/features/wookie-ext/
incubator/wookie/trunk/features/wookie-ext/feature.xml
incubator/wookie/trunk/features/wookie-ext/wookie.js
incubator/wookie/trunk/src/org/apache/wookie/feature/ext/
incubator/wookie/trunk/src/org/apache/wookie/feature/ext/IWookieExtensionAPI.java
- copied, changed from r1144035,
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWookieExtensionAPI.java
incubator/wookie/trunk/src/org/apache/wookie/feature/ext/WookieAPIImpl.java
Removed:
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWookieExtensionAPI.java
Modified:
incubator/wookie/trunk/WebContent/WEB-INF/dwr.xml
incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js
incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetAPI.java
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetRuntimeHelper.java
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java
incubator/wookie/trunk/widgets/natter/config.xml
incubator/wookie/trunk/widgets/simplechat/config.xml
incubator/wookie/trunk/widgets/youdecide/config.xml
Modified: incubator/wookie/trunk/WebContent/WEB-INF/dwr.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/WebContent/WEB-INF/dwr.xml?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/WebContent/WEB-INF/dwr.xml (original)
+++ incubator/wookie/trunk/WebContent/WEB-INF/dwr.xml Mon Jul 18 13:13:54 2011
@@ -35,11 +35,15 @@
<param name="class"
value="org.apache.wookie.ajaxmodel.impl.WidgetAPIImpl"/>
<include method="preferences"/>
<include method="metadata"/>
- <include method="preferenceForKey"/>
<include method="setPreferenceForKey"/>
+ </create>
+
+ <create creator="new" javascript="WookieImpl" scope="application">
+ <param name="class" value="org.apache.wookie.feature.ext.WookieAPIImpl"/>
+ <include method="appendSharedDataForKey"/>
+ <include method="preferenceForKey"/>
<include method="setSharedDataForKey"/>
<include method="sharedDataForKey"/>
- <include method="appendSharedDataForKey"/>
<include method="lock"/>
<include method="unlock"/>
<include method="system"/>
Modified: incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js (original)
+++ incubator/wookie/trunk/WebContent/shared/js/wookie-wrapper.js Mon Jul 18
13:13:54 2011
@@ -94,6 +94,8 @@ WidgetPreferences = new function WidgetP
delete this.prefs[key];
Widget.setPreferenceForKey(key,null);
this.calcLength();
+
+
}
}
}
@@ -116,10 +118,6 @@ var Widget = {
proxyUrl : null,
// this should be assigned by the calling JS app
onSharedUpdate : null,
- // this should be assigned by the calling JS app
- onLocked : null,
- // this should be assigned by the calling JS app
- onUnlocked : null,
// initialised below as a singleton
preferences: null,
@@ -210,42 +208,6 @@ var Widget = {
setPreferenceForKey : function(wName, wValue){
WidgetImpl.setPreferenceForKey(this.instanceid_key, wName,
wValue);
},
-
- preferenceForKey : function(wName, callBackFunction){
- WidgetImpl.preferenceForKey(this.instanceid_key, wName,
callBackFunction);
- },
-
- setSharedDataForKey : function(wName, wValue){
- WidgetImpl.setSharedDataForKey(this.instanceid_key, wName,
wValue);
- },
-
- sharedDataForKey : function(wName, callBackFunction){
- WidgetImpl.sharedDataForKey(this.instanceid_key, wName,
callBackFunction)
- },
-
- appendSharedDataForKey : function(wName, wValue){
- WidgetImpl.appendSharedDataForKey(this.instanceid_key, wName,
wValue)
- },
-
- lock : function(){
- WidgetImpl.lock(this.instanceid_key);
- },
-
- unlock : function(){
- WidgetImpl.unlock(this.instanceid_key);
- },
-
- hide : function(){
- WidgetImpl.hide(this.instanceid_key);
- },
-
- show : function(){
- WidgetImpl.show(this.instanceid_key);
- },
-
- openURL : function(url){
- window.open(url);
- },
getInstanceKey : function(){
return this.instanceid_key;
Added: incubator/wookie/trunk/features/wookie-ext/feature.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/features/wookie-ext/feature.xml?rev=1147849&view=auto
==============================================================================
--- incubator/wookie/trunk/features/wookie-ext/feature.xml (added)
+++ incubator/wookie/trunk/features/wookie-ext/feature.xml Mon Jul 18 13:13:54
2011
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<feature>
+ <!--
+ This is the Wookie Extensions API, and includes
+ a number of extra methods such as lock(), unlock(), show(),
hide()
+ as well as methods for working with shared data and
preferences.
+ Many of these are now deprecated as standards have matured.
+ For more information, see
org.apache.wookie.feature.ext.IWookieExntesionAPI.java
+ -->
+ <name>http://incubator.apache.org/wookie/ext</name>
+ <script src="/wookie/dwr/interface/WookieImpl.js"/>
+ <script src="wookie.js"/>
+</feature>
\ No newline at end of file
Added: incubator/wookie/trunk/features/wookie-ext/wookie.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/features/wookie-ext/wookie.js?rev=1147849&view=auto
==============================================================================
--- incubator/wookie/trunk/features/wookie-ext/wookie.js (added)
+++ incubator/wookie/trunk/features/wookie-ext/wookie.js Mon Jul 18 13:13:54
2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+window.widget.appendSharedDataForKey = function(wName, wValue){
+ WookieImpl.appendSharedDataForKey(widget.instanceid_key, wName, wValue);
+};
+
+window.widget.preferenceForKey = function(wName, callBackFunction){
+ WookieImpl.preferenceForKey(widget.instanceid_key, wName,
callBackFunction);
+};
+
+window.widget.setSharedDataForKey = function(wName, wValue){
+ WookieImpl.setSharedDataForKey(widget.instanceid_key, wName, wValue);
+};
+
+window.widget.sharedDataForKey = function(wName, callBackFunction){
+ WookieImpl.sharedDataForKey(widget.instanceid_key, wName, callBackFunction)
+};
+
+window.widget.lock = function(){
+ WookieImpl.lock(widget.instanceid_key);
+};
+
+window.widget.unlock = function(){
+ WookieImpl.unlock(widget.instanceid_key);
+};
+
+window.widget.hide = function(){
+ WookieImpl.hide(widget.instanceid_key);
+};
+
+window.widget.show = function(){
+ WookieImpl.show(this.instanceid_key);
+};
+
+window.widget.openURL = function(url){
+ window.open(url);
+};
+
Modified: incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml (original)
+++ incubator/wookie/trunk/scratchpad/widgets/blitz/config.xml Mon Jul 18
13:13:54 2011
@@ -24,4 +24,5 @@
<description>Preference and shared data test widget</description>
<content src="index.html"/>
<feature name="http://wave.google.com" required="true"/>
+ <feature name="http://incubator.apache.org/wookie/ext" required="true"/>
</widget>
\ No newline at end of file
Modified: incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetAPI.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetAPI.java?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetAPI.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetAPI.java Mon
Jul 18 13:13:54 2011
@@ -40,6 +40,14 @@ public interface IWidgetAPI {
*/
public Map<String, String> metadata(String id_key);
-
+ /**
+ * Sets a string preference value in the DB, obtained
+ * from the given "key"
+ * @param id_key - the unique instance id key for a widget instance
+ * @param key - key for the value to change
+ * @param key - the value to change to
+ * @return - a string value marking status or an error message
+ */
+ public String setPreferenceForKey(String id_key, String key, String value);
}
Modified:
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetRuntimeHelper.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetRuntimeHelper.java?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetRuntimeHelper.java
(original)
+++
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWidgetRuntimeHelper.java
Mon Jul 18 13:13:54 2011
@@ -23,6 +23,6 @@ public interface IWidgetRuntimeHelper {
static final String USE_PREFERENCE_INSTANCE_QUEUES =
"widget.preferences.useinstancequeues";
static final String USE_SHAREDDATA_INSTANCE_QUEUES =
"widget.shareddata.useinstancequeues";
static final String DWR_SET_PREFERENCE_CALL =
"/wookie/dwr/call/plaincall/WidgetImpl.setPreferenceForKey.dwr";
- static final String DWR_SET_SHAREDDATA_CALL =
"/wookie/dwr/call/plaincall/WidgetImpl.setSharedDataForKey.dwr";
- static final String DWR_APPEND_SHAREDDATA_CALL =
"/wookie/dwr/call/plaincall/WidgetImpl.appendSharedDataForKey.dwr";
+ static final String DWR_SET_SHAREDDATA_CALL =
"/wookie/dwr/call/plaincall/WookieImpl.setSharedDataForKey.dwr";
+ static final String DWR_APPEND_SHAREDDATA_CALL =
"/wookie/dwr/call/plaincall/WookieImpl.appendSharedDataForKey.dwr";
}
Modified:
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java
(original)
+++
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java
Mon Jul 18 13:13:54 2011
@@ -24,49 +24,27 @@ import javax.servlet.http.HttpServletReq
import org.apache.log4j.Logger;
import org.apache.wookie.Messages;
import org.apache.wookie.ajaxmodel.IWidgetAPI;
-import org.apache.wookie.ajaxmodel.IWookieExtensionAPI;
import org.apache.wookie.beans.IDescription;
import org.apache.wookie.beans.IName;
import org.apache.wookie.beans.IPreference;
-import org.apache.wookie.beans.ISharedData;
import org.apache.wookie.beans.IWidget;
import org.apache.wookie.beans.IWidgetInstance;
import org.apache.wookie.beans.util.IPersistenceManager;
import org.apache.wookie.beans.util.PersistenceManagerFactory;
import org.apache.wookie.controller.PropertiesController;
-import org.apache.wookie.controller.WidgetInstancesController;
-import org.apache.wookie.helpers.Notifier;
-import org.apache.wookie.helpers.SharedDataHelper;
import org.apache.wookie.queues.QueueManager;
import org.apache.wookie.server.ContextListener;
import org.apache.wookie.server.LocaleHandler;
import org.apache.wookie.util.WidgetFormattingUtils;
import org.apache.wookie.w3c.util.LocalizationUtils;
-import org.directwebremoting.ScriptBuffer;
-import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
/**
* Implementation of the widget API. This class models the the javascript
implementation of
- * the w3c widget API. Using DWR - a javascript/HTML client which has
included the correct js files...
- *
- * <script type='text/javascript'
src='/wookie/dwr/interface/WidgetImpl.js'></script>
- * <script type='text/javascript' src='/wookie/dwr/engine.js'></script>
- * <script type='text/javascript'
src='/wookie/shared/js/wookie-wrapper.js'></script>
- *
- * ...can then access this classes methods via a call for example like...
- *
- * Widget.preferenceForKey("Username", callbackFunctionName);
- *
- * and
- *
- * Widget.setSharedDataForKey("defaultChatPresence",stringWithUserRemoved);
- *
- * @author Paul Sharples
- * @version $Id: WidgetAPIImpl.java,v 1.3 2009-09-14 21:15:07 scottwilson Exp $
+ * the w3c widget API.
*
*/
-public class WidgetAPIImpl implements IWidgetAPI, IWookieExtensionAPI {
+public class WidgetAPIImpl implements IWidgetAPI {
static Logger _logger = Logger.getLogger(WidgetAPIImpl.class.getName());
@@ -148,205 +126,31 @@ public class WidgetAPIImpl implements IW
return map;
}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#setPreferenceForKey(java.lang.String,
java.lang.String, java.lang.String)
+ *
+ * DEPRECATED: This was replaced by the W3C Storage API. We do require a
method to respond to preference storage events on
+ * the client so this method will be retained unless/until an alternative is
implemented, but widget authors are strongly discouraged
+ * from invoking this method in client code.
+ */
+ @Deprecated
+ @SuppressWarnings("static-access")
+ public String setPreferenceForKey(String id_key, String key, String value) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ if(ContextListener.usePreferenceInstanceQueues){
+ QueueManager.getInstance().queueSetPreferenceRequest(id_key, key,
value);
+ }
+ else{
+ PropertiesController.updatePreference(widgetInstance, key, value);
+ }
+ return "okay"; //$NON-NLS-1$
+ }
- /*
- * (non-Javadoc)
- * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#preferenceForKey(java.lang.String,
java.lang.String)
- *
- * DEPRECATED: This was replaced by the W3C Storage API
- */
- @Deprecated
- public String preferenceForKey(String id_key, String key) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- if(id_key == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- if(key == null)return
localizedMessages.getString("WidgetAPIImpl.1");
- // check if instance is valid
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- //
- IPreference preference = widgetInstance.getPreference(key);
- if (preference == null) return
localizedMessages.getString("WidgetAPIImpl.1");
- return preference.getDvalue();
- }
-
- /*
- * (non-Javadoc)
- * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#sharedDataForKey(java.lang.String,
java.lang.String)
- *
- * DEPRECATED: This was replaced by the Wave Gadget API
- */
- @Deprecated
- public String sharedDataForKey(String id_key, String key) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- if(id_key==null) return
localizedMessages.getString("WidgetAPIImpl.0");
- if(key==null) return
localizedMessages.getString("WidgetAPIImpl.1");
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- ISharedData data =
SharedDataHelper.findSharedData(widgetInstance, key);
- if (data == null) return
localizedMessages.getString("WidgetAPIImpl.1");
- return data.getDvalue();
- }
-
- /*
- * (non-Javadoc)
- * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#setPreferenceForKey(java.lang.String,
java.lang.String, java.lang.String)
- *
- * DEPRECATED: This was replaced by the W3C Storage API. We do require
a method to respond to preference storage events on
- * the client so this method will be retained unless/until an
alternative is implemented, but widget authors are strongly discouraged
- * from invoking this method in client code.
- */
- @Deprecated
- @SuppressWarnings("static-access")
- public String setPreferenceForKey(String id_key, String key, String
value) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- if(ContextListener.usePreferenceInstanceQueues){
-
QueueManager.getInstance().queueSetPreferenceRequest(id_key, key, value);
- }
- else{
- PropertiesController.updatePreference(widgetInstance,
key, value);
- }
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#setSharedDataForKey(java.lang.String,
java.lang.String, java.lang.String)
- *
- * DEPRECATED: This was replaced by the Wave Gadget API
- */
- @Deprecated
- @SuppressWarnings("static-access")
- public String setSharedDataForKey(String id_key, String key, String
value) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance;//
- widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if(widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- if(widgetInstance.isLocked()) return
localizedMessages.getString("WidgetAPIImpl.2");
- if(ContextListener.useSharedDataInstanceQueues){//
-
QueueManager.getInstance().queueSetSharedDataRequest(id_key,
widgetInstance.getSharedDataKey(), key, value, false);
- }
- else{
-
PropertiesController.updateSharedDataEntry(widgetInstance, key, value, false);
- }
- Notifier.notifySiblings(widgetInstance);
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#appendSharedDataForKey(java.lang.String,
java.lang.String, java.lang.String)
- *
- * Note: this method may be deprecated in a future release
- */
- @SuppressWarnings("static-access")
- public String appendSharedDataForKey(String id_key, String key, String
value) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if(widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- if(widgetInstance.isLocked()) return
localizedMessages.getString("WidgetAPIImpl.2");
- if(ContextListener.useSharedDataInstanceQueues){//
-
QueueManager.getInstance().queueSetSharedDataRequest(id_key,
widgetInstance.getSharedDataKey(), key, value, true);
- }
- else{
-
PropertiesController.updateSharedDataEntry(widgetInstance, key, value, true);
- }
- Notifier.notifySiblings(widgetInstance);
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.wookie.ajaxmodel.IWidgetAPI#lock(java.lang.String)
- */
- public String lock(String id_key) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if(widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- //
- String sharedDataKey = widgetInstance.getSharedDataKey();
- WidgetInstancesController.lockWidgetInstance(widgetInstance);
-
Notifier.callSiblings(widgetInstance,"Widget.onLocked(\""+sharedDataKey+"\");");//$NON-NLS-1$
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.wookie.ajaxmodel.IWidgetAPI#unlock(java.lang.String)
- */
- public String unlock(String id_key) {
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if(widgetInstance==null) return
localizedMessages.getString("WidgetAPIImpl.0");
- //
- String sharedDataKey = widgetInstance.getSharedDataKey();
- WidgetInstancesController.unlockWidgetInstance(widgetInstance);
-
Notifier.callSiblings(widgetInstance,"Widget.onUnlocked(\""+sharedDataKey+"\");");//$NON-NLS-1$
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.wookie.ajaxmodel.IWidgetAPI#hide(java.lang.String)
- */
- public String hide(String id_key){
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
- //
-
Notifier.callSiblings(widgetInstance,"window.onHide()");//$NON-NLS-1$
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.wookie.ajaxmodel.IWidgetAPI#show(java.lang.String)
- */
- public String show(String id_key){
- HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
- Messages localizedMessages =
LocaleHandler.localizeMessages(request);
- IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
- IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
- if(widgetInstance==null) return
localizedMessages.getString("WidgetAPIImpl.0");
- Notifier.callSiblings(widgetInstance,"window.onShow()");
//$NON-NLS-1$
- return "okay"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.wookie.ajaxmodel.IWidgetAPI#openURL(java.lang.String)
- */
- // DEPRICATED - implemented in local js object instead
- // NOTE - might not need this - we can call window.open in a browser -
- // The only reason to send the call to this servlet is if we somehow
wish to
- // update other users.
- @Deprecated
- public String openURL(String url) {
- _logger.debug("openurl called with "+ url );
//$NON-NLS-1$
- WebContext wctx = WebContextFactory.get();
- ScriptBuffer script = new ScriptBuffer();
- script.appendScript("window.open(") //$NON-NLS-1$
- .appendData(url)
- .appendScript(");"); //$NON-NLS-1$
- wctx.getScriptSession().addScript(script);
- return ""; //$NON-NLS-1$
- }
}
\ No newline at end of file
Copied:
incubator/wookie/trunk/src/org/apache/wookie/feature/ext/IWookieExtensionAPI.java
(from r1144035,
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWookieExtensionAPI.java)
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/ext/IWookieExtensionAPI.java?p2=incubator/wookie/trunk/src/org/apache/wookie/feature/ext/IWookieExtensionAPI.java&p1=incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWookieExtensionAPI.java&r1=1144035&r2=1147849&rev=1147849&view=diff
==============================================================================
---
incubator/wookie/trunk/src/org/apache/wookie/ajaxmodel/IWookieExtensionAPI.java
(original)
+++
incubator/wookie/trunk/src/org/apache/wookie/feature/ext/IWookieExtensionAPI.java
Mon Jul 18 13:13:54 2011
@@ -15,27 +15,12 @@
*
*/
-package org.apache.wookie.ajaxmodel;
+package org.apache.wookie.feature.ext;
/**
* Wookie-specific runtime API extensions, including "private" support methods
*/
-public interface IWookieExtensionAPI {
-
-
- /**
- * Appends a string to the string contained in the shared data value in the
DB, obtained
- * from the given "key"
- *
- * Note that this method is retained only as a workaround for some issues in
the Wave Gadget API implementation
- * and is likely to be deprecated in the future.
- *
- * @param id_key - the unique instance id key for a widget instance
- * @param key - key for the value to change
- * @param key - the value to change to
- * @return - a string value marking status or an error message
- */
- public String appendSharedDataForKey(String id_key, String key, String
value);
+public interface IWookieExtensionAPI {
/**
* Call to hide a widget instance based on the instance_key
@@ -64,16 +49,6 @@ public interface IWookieExtensionAPI {
*/
@Deprecated
public String preferenceForKey(String id_key, String key);
-
- /**
- * Sets a string preference value in the DB, obtained
- * from the given "key"
- * @param id_key - the unique instance id key for a widget instance
- * @param key - key for the value to change
- * @param key - the value to change to
- * @return - a string value marking status or an error message
- */
- public String setPreferenceForKey(String id_key, String key, String value);
/**
* Sets a string shared data value in the DB, obtained
@@ -107,4 +82,19 @@ public interface IWookieExtensionAPI {
*/
public String show(String id_key);
+ /**
+ * Appends a string to the string contained in the shared data value in the
DB, obtained
+ * from the given "key"
+ *
+ * Note that this method is retained only as a workaround for some issues in
the Wave Gadget API implementation
+ * and is likely to be deprecated in the future.
+ *
+ * @param id_key - the unique instance id key for a widget instance
+ * @param key - key for the value to change
+ * @param key - the value to change to
+ * @return - a string value marking status or an error message
+ */
+ public String appendSharedDataForKey(String id_key, String key, String
value);
+
+
}
Added:
incubator/wookie/trunk/src/org/apache/wookie/feature/ext/WookieAPIImpl.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/feature/ext/WookieAPIImpl.java?rev=1147849&view=auto
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/feature/ext/WookieAPIImpl.java
(added)
+++ incubator/wookie/trunk/src/org/apache/wookie/feature/ext/WookieAPIImpl.java
Mon Jul 18 13:13:54 2011
@@ -0,0 +1,219 @@
+/*
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.wookie.feature.ext;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.log4j.Logger;
+import org.apache.wookie.Messages;
+import org.apache.wookie.beans.IPreference;
+import org.apache.wookie.beans.ISharedData;
+import org.apache.wookie.beans.IWidgetInstance;
+import org.apache.wookie.beans.util.IPersistenceManager;
+import org.apache.wookie.beans.util.PersistenceManagerFactory;
+import org.apache.wookie.controller.PropertiesController;
+import org.apache.wookie.controller.WidgetInstancesController;
+import org.apache.wookie.helpers.Notifier;
+import org.apache.wookie.helpers.SharedDataHelper;
+import org.apache.wookie.queues.QueueManager;
+import org.apache.wookie.server.ContextListener;
+import org.apache.wookie.server.LocaleHandler;
+import org.directwebremoting.ScriptBuffer;
+import org.directwebremoting.WebContext;
+import org.directwebremoting.WebContextFactory;
+
+/**
+ * Wookie Extensions API Implementation
+ */
+public class WookieAPIImpl implements IWookieExtensionAPI {
+
+ static Logger _logger = Logger.getLogger(WookieAPIImpl.class.getName());
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#preferenceForKey(java.lang.String,
java.lang.String)
+ *
+ * DEPRECATED: This was replaced by the W3C Storage API
+ */
+ @Deprecated
+ public String preferenceForKey(String id_key, String key) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ if(id_key == null) return localizedMessages.getString("WidgetAPIImpl.0");
+ if(key == null)return localizedMessages.getString("WidgetAPIImpl.1");
+ // check if instance is valid
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ //
+ IPreference preference = widgetInstance.getPreference(key);
+ if (preference == null) return
localizedMessages.getString("WidgetAPIImpl.1");
+ return preference.getDvalue();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#sharedDataForKey(java.lang.String,
java.lang.String)
+ *
+ * DEPRECATED: This was replaced by the Wave Gadget API
+ */
+ @Deprecated
+ public String sharedDataForKey(String id_key, String key) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ if(id_key==null) return localizedMessages.getString("WidgetAPIImpl.0");
+ if(key==null) return localizedMessages.getString("WidgetAPIImpl.1");
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ ISharedData data = SharedDataHelper.findSharedData(widgetInstance, key);
+ if (data == null) return localizedMessages.getString("WidgetAPIImpl.1");
+ return data.getDvalue();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.apache.wookie.ajaxmodel.IWidgetAPI#setSharedDataForKey(java.lang.String,
java.lang.String, java.lang.String)
+ *
+ * DEPRECATED: This was replaced by the Wave Gadget API
+ */
+ @Deprecated
+ @SuppressWarnings("static-access")
+ public String setSharedDataForKey(String id_key, String key, String value) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance;//
+ widgetInstance = persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if(widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ if(widgetInstance.isLocked()) return
localizedMessages.getString("WidgetAPIImpl.2");
+ if(ContextListener.useSharedDataInstanceQueues){//
+ QueueManager.getInstance().queueSetSharedDataRequest(id_key,
widgetInstance.getSharedDataKey(), key, value, false);
+ }
+ else{
+ PropertiesController.updateSharedDataEntry(widgetInstance, key, value,
false);
+ }
+ Notifier.notifySiblings(widgetInstance);
+ return "okay"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.wookie.ajaxmodel.IWidgetAPI#lock(java.lang.String)
+ */
+ public String lock(String id_key) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if(widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ //
+ String sharedDataKey = widgetInstance.getSharedDataKey();
+ WidgetInstancesController.lockWidgetInstance(widgetInstance);
+
Notifier.callSiblings(widgetInstance,"Widget.onLocked(\""+sharedDataKey+"\");");//$NON-NLS-1$
+ return "okay"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.wookie.ajaxmodel.IWidgetAPI#unlock(java.lang.String)
+ */
+ public String unlock(String id_key) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if(widgetInstance==null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ //
+ String sharedDataKey = widgetInstance.getSharedDataKey();
+ WidgetInstancesController.unlockWidgetInstance(widgetInstance);
+
Notifier.callSiblings(widgetInstance,"Widget.onUnlocked(\""+sharedDataKey+"\");");//$NON-NLS-1$
+ return "okay"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.wookie.ajaxmodel.IWidgetAPI#hide(java.lang.String)
+ */
+ public String hide(String id_key){
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if (widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ //
+ Notifier.callSiblings(widgetInstance,"window.onHide()");//$NON-NLS-1$
+ return "okay"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.wookie.ajaxmodel.IWidgetAPI#show(java.lang.String)
+ */
+ public String show(String id_key){
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if(widgetInstance==null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ Notifier.callSiblings(widgetInstance,"window.onShow()"); //$NON-NLS-1$
+ return "okay"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.wookie.ajaxmodel.IWidgetAPI#openURL(java.lang.String)
+ */
+ // DEPRICATED - implemented in local js object instead
+ // NOTE - might not need this - we can call window.open in a browser -
+ // The only reason to send the call to this servlet is if we somehow wish to
+ // update other users.
+ @Deprecated
+ public String openURL(String url) {
+ _logger.debug("openurl called with "+ url ); //$NON-NLS-1$
+ WebContext wctx = WebContextFactory.get();
+ ScriptBuffer script = new ScriptBuffer();
+ script.appendScript("window.open(") //$NON-NLS-1$
+ .appendData(url)
+ .appendScript(");"); //$NON-NLS-1$
+ wctx.getScriptSession().addScript(script);
+ return ""; //$NON-NLS-1$
+ }
+
+ /*
+ * Note: this method may be deprecated in a future release
+ */
+ @SuppressWarnings("static-access")
+ public String appendSharedDataForKey(String id_key, String key, String
value) {
+ HttpServletRequest request =
WebContextFactory.get().getHttpServletRequest();
+ Messages localizedMessages = LocaleHandler.localizeMessages(request);
+ IPersistenceManager persistenceManager =
PersistenceManagerFactory.getPersistenceManager();
+ IWidgetInstance widgetInstance =
persistenceManager.findWidgetInstanceByIdKey(id_key);
+ if(widgetInstance == null) return
localizedMessages.getString("WidgetAPIImpl.0");
+ if(widgetInstance.isLocked()) return
localizedMessages.getString("WidgetAPIImpl.2");
+ if(ContextListener.useSharedDataInstanceQueues){//
+ QueueManager.getInstance().queueSetSharedDataRequest(id_key,
widgetInstance.getSharedDataKey(), key, value, true);
+ }
+ else{
+ PropertiesController.updateSharedDataEntry(widgetInstance, key, value,
true);
+ }
+ Notifier.notifySiblings(widgetInstance);
+ return "okay"; //$NON-NLS-1$
+ }
+
+}
Modified: incubator/wookie/trunk/widgets/natter/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/natter/config.xml?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/natter/config.xml (original)
+++ incubator/wookie/trunk/widgets/natter/config.xml Mon Jul 18 13:13:54 2011
@@ -24,5 +24,6 @@
<author>Scott Wilson</author>
<license>Licensed under the Apache 2.0 License (see
http://www.apache.org/licenses/LICENSE-2.0). Smileys created by macpoupou and
licensed under Creative Commons Attribution License 3.0. See
http://ismileys.free.fr/smileys/ for more information. </license>
<feature name="http://wave.google.com" required="true"/>
+ <feature name="http://incubator.apache.org/wookie/ext" required="true"/>
<preference name="moderator" value="false"/>
</widget>
Modified: incubator/wookie/trunk/widgets/simplechat/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/simplechat/config.xml?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/simplechat/config.xml (original)
+++ incubator/wookie/trunk/widgets/simplechat/config.xml Mon Jul 18 13:13:54
2011
@@ -22,5 +22,6 @@
<author>Apache Wookie (Incubating) Team</author>
<license>Licensed under the Apache 2.0 License (see
http://www.apache.org/licenses/LICENSE-2.0). Smileys created by macpoupou and
licensed under Creative Commons Attribution License 3.0. See
http://ismileys.free.fr/smileys/ for more information. </license>
<feature name="http://wave.google.com" required="true"/>
+ <feature name="http://incubator.apache.org/wookie/ext" required="true"/>
<preference name="moderator" value="false"/>
</widget>
Modified: incubator/wookie/trunk/widgets/youdecide/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/youdecide/config.xml?rev=1147849&r1=1147848&r2=1147849&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/youdecide/config.xml (original)
+++ incubator/wookie/trunk/widgets/youdecide/config.xml Mon Jul 18 13:13:54 2011
@@ -24,5 +24,6 @@
<access network="true"/>
<author>Scott Wilson</author>
<feature name="http://wave.google.com" required="true"/>
+ <feature name="http://incubator.apache.org/wookie/ext" required="true"/>
<preference name="moderator" value="false"/>
</widget>