Skip to content

Commit e9a82bf

Browse files
author
zhourenjian
committed
1. Now SimpleRPCRunnable class is not implementing interface of Runnable.
2. Only wrap SimpleRPCRunnable#ajaxRun in Thread instead of Display#asyncRun 3. Update author name in comments.
1 parent 19a2208 commit e9a82bf

File tree

12 files changed

+52
-31
lines changed

12 files changed

+52
-31
lines changed

sources/net.sf.j2s.ajax/ajaxcore/net/sf/j2s/ajax/AClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* A callback object is provided for action to be executed after the class is
2121
* loaded.
2222
*
23-
* @author josson smith
23+
* @author zhou renjian
2424
*
2525
* 2006-8-4
2626
*/

sources/net.sf.j2s.ajax/ajaxcore/net/sf/j2s/ajax/ARunnable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* give convenience for <code>AClass</code> or <code>ASWTClass</code>
1919
* to set and to get the class that is loaded.
2020
*
21-
* @author josson smith
21+
* @author zhou renjian
2222
*
2323
* 2006-8-4
2424
*/

sources/net.sf.j2s.ajax/ajaxcore/net/sf/j2s/ajax/HttpRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* This class can be considered as a bridge of Java's AJAX programming and
3939
* JavaScript/Browser's AJAX programming.
4040
*
41-
* @author josson smith
41+
* @author zhou renjian
4242
*
4343
* 2006-2-11
4444
*/

sources/net.sf.j2s.ajax/ajaxcore/net/sf/j2s/ajax/IXHRCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* 4 Loaded<br>
3131
* The data transfer has been completed.<br>
3232
*
33-
* @author josson smith
33+
* @author zhou renjian
3434
*
3535
* 2006-2-11
3636
*/

sources/net.sf.j2s.ajax/ajaxcore/net/sf/j2s/ajax/XHRCallbackAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* This adapter provides a default implementation of IXHRCallback.
1818
*
19-
* @author josson smith
19+
* @author zhou renjian
2020
*
2121
* 2006-2-11
2222
*/

sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleRPCRequest.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.net.URLEncoder;
1818

1919
/**
20-
* @author josson smith
20+
* @author zhou renjian
2121
*
2222
* 2006-10-10
2323
*/
@@ -47,10 +47,21 @@ public static void switchToLocalJavaThreadMode() {
4747
* runnable.ajaxIn ();
4848
* net.sf.j2s.ajax.SimpleRPCRequest.ajaxRequest (runnable);
4949
*/
50-
public static void request(SimpleRPCRunnable runnable) {
50+
public static void request(final SimpleRPCRunnable runnable) {
5151
runnable.ajaxIn();
5252
if (runningMode == MODE_LOCAL_JAVA_THREAD) {
53-
new Thread(runnable).start();
53+
new Thread(new Runnable() {
54+
public void run() {
55+
try {
56+
runnable.ajaxRun();
57+
} catch (RuntimeException e) {
58+
e.printStackTrace(); // should never fail in Java thread mode!
59+
runnable.ajaxFail();
60+
return;
61+
}
62+
runnable.ajaxOut();
63+
}
64+
}).start();
5465
} else {
5566
ajaxRequest(runnable);
5667
}

sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleRPCRunnable.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
* 2006-10-10
2121
*/
22-
public abstract class SimpleRPCRunnable extends SimpleSerializable implements Runnable {
22+
public abstract class SimpleRPCRunnable extends SimpleSerializable {
2323

2424
public String getHttpURL() {
2525
return "simplerpc"; // url is relative to the servlet!
@@ -51,19 +51,4 @@ public String getHttpMethod() {
5151
*/
5252
public void ajaxFail() {};
5353

54-
/**
55-
* @j2sNative
56-
* net.sf.j2s.ajax.ServletThread.call(this);
57-
*/
58-
public void run() {
59-
// ajaxIn(); // ajaxIn should be run outside of #run directly
60-
try {
61-
ajaxRun();
62-
} catch (RuntimeException e) {
63-
e.printStackTrace(); // should never fail in Java thread mode!
64-
ajaxFail();
65-
return;
66-
}
67-
ajaxOut();
68-
}
6954
}

sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleRPCSWTRequest.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.eclipse.swt.widgets.Display;
1919

2020
/**
21-
* @author josson smith
21+
* @author zhou renjian
2222
*
2323
* 2006-10-10
2424
*/
@@ -29,10 +29,35 @@ public class SimpleRPCSWTRequest extends SimpleRPCRequest {
2929
* runnable.ajaxIn ();
3030
* net.sf.j2s.ajax.SimpleRPCRequest.ajaxRequest (runnable);
3131
*/
32-
public static void swtRequest(SimpleRPCRunnable runnable) {
32+
public static void swtRequest(final SimpleRPCRunnable runnable) {
3333
runnable.ajaxIn();
3434
if (runningMode == MODE_LOCAL_JAVA_THREAD) {
35-
Display.getDefault().asyncExec(runnable);
35+
new Thread(new Runnable(){
36+
public void run() {
37+
try {
38+
runnable.ajaxRun();
39+
} catch (RuntimeException e) {
40+
e.printStackTrace(); // should never fail in Java thread mode!
41+
Display disp = Display.getDefault();
42+
if (disp != null) {
43+
disp.syncExec(new Runnable() {
44+
public void run() {
45+
runnable.ajaxFail();
46+
}
47+
});
48+
}
49+
return;
50+
}
51+
Display disp = Display.getDefault();
52+
if (disp != null) {
53+
disp.syncExec(new Runnable() {
54+
public void run() {
55+
runnable.ajaxOut();
56+
}
57+
});
58+
}
59+
}
60+
}).start();
3661
} else {
3762
swtAJAXRequest(runnable);
3863
}

sources/net.sf.j2s.ajax/ajaxrpc/net/sf/j2s/ajax/SimpleSerializable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import java.util.Set;
2323

2424
/**
25-
* @author josson smith
25+
* @author zhou renjian
2626
*
2727
* 2006-10-11
2828
*/

sources/net.sf.j2s.ajax/ajaxswt/net/sf/j2s/ajax/ASWTClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void run() {
3333
* parameter as <code>AClass#load</code>. Or call <code>ASWTClass#shellLoad</code>
3434
* or <code>ASWTClass#displayLoad</code> with extra Shell/Display argument.
3535
*
36-
* @author josson smith
36+
* @author zhou renjian
3737
*
3838
* 2006-8-4
3939
*/

0 commit comments

Comments
 (0)