You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pm...@apache.org on 2012/01/03 19:39:31 UTC
[14/27] git commit: fixes for #38
fixes for #38
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/commit/f85a7e2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/tree/f85a7e2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/diff/f85a7e2f
Branch: refs/heads/master
Commit: f85a7e2f1f1152fd2e7a9d2ba77de46411ec7a9a
Parents: b2ad995
Author: Patrick Mueller <pm...@yahoo.com>
Authored: Thu Oct 13 10:33:18 2011 -0400
Committer: Patrick Mueller <pm...@yahoo.com>
Committed: Thu Oct 13 10:33:18 2011 -0400
----------------------------------------------------------------------
weinre.build/debug.sh | 2 -
weinre.server/src/weinre/server/Channel.java | 70 +++++++-------
weinre.web/demo/weinre-demo-pieces.html | 20 +++--
.../modules/weinre/target/WiDOMStorageImpl.coffee | 6 +-
4 files changed, 49 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/f85a7e2f/weinre.build/debug.sh
----------------------------------------------------------------------
diff --git a/weinre.build/debug.sh b/weinre.build/debug.sh
index 48774e1..3542f2d 100755
--- a/weinre.build/debug.sh
+++ b/weinre.build/debug.sh
@@ -10,6 +10,4 @@ java \
-Dfile.encoding=UTF-8 \
-classpath $CP \
weinre.server.Main \
- --verbose true \
--deathTimeout 120
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/f85a7e2f/weinre.server/src/weinre/server/Channel.java
----------------------------------------------------------------------
diff --git a/weinre.server/src/weinre/server/Channel.java b/weinre.server/src/weinre/server/Channel.java
index 11889b2..dbf073b 100644
--- a/weinre.server/src/weinre/server/Channel.java
+++ b/weinre.server/src/weinre/server/Channel.java
@@ -1,7 +1,7 @@
/*
* weinre is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
+ *
* Copyright (c) 2010, 2011 IBM Corporation
*/
@@ -22,9 +22,9 @@ import org.apache.wink.json4j.JSONObject;
//-------------------------------------------------------------------
public class Channel {
-
+
static public final String AnonymousId = "anonymous";
-
+
private String pathPrefix;
private String name;
private String id;
@@ -37,7 +37,7 @@ public class Channel {
private String remoteHost;
private String remoteAddress;
private PrintWriter messageLog;
-
+
//---------------------------------------------------------------
public Channel(String pathPrefix, String name, String id, String remoteHost, String remoteAddress) {
this.pathPrefix = pathPrefix;
@@ -58,46 +58,46 @@ public class Channel {
public Connector getConnector() {
return connector;
}
-
+
//---------------------------------------------------------------
public String getRemoteHost() {
return remoteHost;
}
-
+
//---------------------------------------------------------------
public String getRemoteAddress() {
return remoteAddress;
}
-
+
//---------------------------------------------------------------
protected void _setConnector(Connector connector) {
this.connector = connector;
}
-
+
//---------------------------------------------------------------
public void sendCallback(String intfName, String callbackId, Object... args) throws IOException {
if (callbackId == null) return;
-
+
List<Object> innerArgs = new ArrayList<Object>();
innerArgs.add(callbackId);
innerArgs.add(Arrays.asList(args));
-
+
sendEvent(intfName, "sendCallback", innerArgs.toArray());
}
-
+
//---------------------------------------------------------------
public void sendEvent(String intfName, String methodName, Object... args) {
Main.debug(getName() + ": send " + intfName + "." + methodName + "()");
-
+
JSONObject response = new JSONObject();
-
+
String responseString;
try {
response.put("interface", intfName);
response.put("method", methodName);
-
+
List<Object> passedArgs = new ArrayList<Object>(Arrays.asList(args));
-
+
response.put("args", passedArgs);
responseString = response.toString();
@@ -106,10 +106,10 @@ public class Channel {
Main.warn("IOException serializing message for " + intfName + "." + methodName);
return;
}
-
+
this.postResponse(responseString);
}
-
+
//---------------------------------------------------------------
public Object getService(String name) {
try {
@@ -122,12 +122,12 @@ public class Channel {
throw new RuntimeException(e);
}
}
-
+
//---------------------------------------------------------------
@SuppressWarnings("rawtypes")
private Object getService_(String name) throws InstantiationException, IllegalAccessException {
if (serviceMap.containsKey(name)) return serviceMap.get(name);
-
+
String klassName = "weinre.server.service." + name;
Class klass = null;
try {
@@ -138,56 +138,56 @@ public class Channel {
serviceMap.put(name, null);
return null;
}
-
+
Object result = klass.newInstance();
serviceMap.put(name, result);
Main.debug("loaded service class: " + klassName);
return result;
}
-
+
//---------------------------------------------------------------
public void close() {
isClosed = true;
requestQueue.shutdown();
responseQueue.shutdown();
-
+
ChannelManager.$.deregisterChannel(name);
}
-
+
//---------------------------------------------------------------
public boolean isClosed() {
return isClosed;
}
-
+
//---------------------------------------------------------------
public String getPathPrefix() {
return pathPrefix;
}
-
+
//---------------------------------------------------------------
public String getName() {
return name;
}
-
+
//---------------------------------------------------------------
public String getId() {
return id;
}
-
+
//---------------------------------------------------------------
public long getLastRead() {
return lastRead;
}
-
+
//---------------------------------------------------------------
public void updateLastRead() {
lastRead = System.currentTimeMillis();
}
-
+
//---------------------------------------------------------------
public void postRequest(String json) {
if (isClosed()) return;
-
+
requestQueue.add(json);
log(json);
}
@@ -195,7 +195,7 @@ public class Channel {
//---------------------------------------------------------------
public void postResponse(String json) {
if (isClosed()) return;
-
+
responseQueue.add(json);
log(json);
}
@@ -203,7 +203,7 @@ public class Channel {
//---------------------------------------------------------------
private void log(String json) {
if (null == messageLog) return;
-
+
JSONObject jObject;
try {
jObject = new JSONObject(json);
@@ -212,7 +212,7 @@ public class Channel {
catch (JSONException e) {
return;
}
-
+
messageLog.print(jObject.toString(true));
messageLog.println(",");
}
@@ -220,7 +220,7 @@ public class Channel {
//---------------------------------------------------------------
public List<String> getRequests(int timeoutSeconds) throws InterruptedException {
if (isClosed()) return new LinkedList<String>();
-
+
List<String> result = requestQueue.getAll(timeoutSeconds, TimeUnit.SECONDS);
return result;
@@ -229,7 +229,7 @@ public class Channel {
//---------------------------------------------------------------
public List<String> getResponses(int timeoutSeconds) throws InterruptedException {
if (isClosed()) return new LinkedList<String>();
-
+
List<String> result = responseQueue.getAll(timeoutSeconds, TimeUnit.SECONDS);
return result;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/f85a7e2f/weinre.web/demo/weinre-demo-pieces.html
----------------------------------------------------------------------
diff --git a/weinre.web/demo/weinre-demo-pieces.html b/weinre.web/demo/weinre-demo-pieces.html
index 04d87d9..496790c 100644
--- a/weinre.web/demo/weinre-demo-pieces.html
+++ b/weinre.web/demo/weinre-demo-pieces.html
@@ -60,21 +60,23 @@
<body onload="onLoad()">
<input id="button-start-stuff" type="button" value="start stuff">
-<p>exceptions in callbacks<p>
-<input id="button-error-DOM-event" type="button" value="DOM addEventHandler">
-<input id="button-error-window-event" type="button" value="window addEventHandler">
-<input id="button-error-XHR-event" type="button" value="XHR addEventHandler">
-<input id="button-error-setTimeout" type="button" value="setTimeout()">
-<input id="button-error-setInterval" type="button" value="setInterval()">
-
<h1>this is a green h1</h1>
<h1 class="blue">this is a blue h1</h1>
<h1 style="color:red">this is a red h1</h1>
<p>Some text, <i>some italic text</i>, and <b>some bold text</b>.
-<div id="metrics">a div</div>
+<hr>
+<p>test exceptions in callbacks:
+<div style="margin-left:1em">
+ <input id="button-error-DOM-event" type="button" value="DOM addEventHandler">
+<br><input id="button-error-window-event" type="button" value="window addEventHandler">
+<br><input id="button-error-XHR-event" type="button" value="XHR addEventHandler">
+<br><input id="button-error-setTimeout" type="button" value="setTimeout()">
+<br><input id="button-error-setInterval" type="button" value="setInterval()">
+</div>
-<input id="button-clear-output" type="button" value="clear output">
+<hr>
+<p><input id="button-clear-output" type="button" value="clear output">
<div id="output"></div>
</body>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/f85a7e2f/weinre.web/modules/weinre/target/WiDOMStorageImpl.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/WiDOMStorageImpl.coffee b/weinre.web/modules/weinre/target/WiDOMStorageImpl.coffee
index 536a181..b52e9c0 100644
--- a/weinre.web/modules/weinre/target/WiDOMStorageImpl.coffee
+++ b/weinre.web/modules/weinre/target/WiDOMStorageImpl.coffee
@@ -99,13 +99,13 @@ module.exports = class WiDOMStorageImpl
host: window.location.host
isLocalStorage: false
- HookSites.SeesionStorage_setItem.addHooks
+ HookSites.SessionStorage_setItem.addHooks
after: -> _storageEventHandler storageArea: window.sessionStorage
- HookSites.SeesionStorage_removeItem.addHooks
+ HookSites.SessionStorage_removeItem.addHooks
after: -> _storageEventHandler storageArea: window.sessionStorage
- HookSites.SeesionStorage_clear.addHooks
+ HookSites.SessionStorage_clear.addHooks
after: -> _storageEventHandler storageArea: window.sessionStorage
document.addEventListener "storage", _storageEventHandler, false