Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7712231

Browse files
author
zhourenjian
committed
Support IE subdomain query mode
Detect multiple queries are being sent to server, and avoid sending more queries before earlier requests get responses.Add thread name to Java threadsFixing Pipe swt requesting bug on OK responseOther bug fixing
1 parent081b840 commit7712231

File tree

10 files changed

+288
-145
lines changed

10 files changed

+288
-145
lines changed

‎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
@@ -374,7 +374,7 @@ public void send() {
374374
publicvoidsend(Stringstr) {
375375
content =str;
376376
if (asynchronous) {
377-
(newThread() {
377+
(newThread("Java2Script HTTP Request") {
378378
publicvoidrun() {
379379
if (!toAbort) {
380380
request();

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/CompoundPipeRunnable.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ protected long pipeMonitoringInterval() {
312312
}
313313

314314
@Override
315-
protectedlongpipeWaitClosingInterval() {
315+
publiclongpipeWaitClosingInterval() {
316316
longclosingInterval =super.pipeWaitClosingInterval();
317317
for (inti =0;i <pipes.length;i++) {
318318
if (pipes[i] !=null) {

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeHelper.java‎

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
*/
2828
publicclassSimplePipeHelper {
2929

30-
staticinterfaceIPipeThrough {
30+
publicstaticinterfaceIPipeThrough {
3131
publicvoidhelpThrough(SimplePipeRunnablepipe,SimpleSerializable[]objs);
3232
}
3333

34-
staticinterfaceIPipeClosing {
34+
publicstaticinterfaceIPipeClosing {
3535
publicvoidhelpClosing(SimplePipeRunnablepipe);
3636
}
3737

@@ -123,7 +123,7 @@ static String nextPipeKey() {
123123
@J2SNative({
124124
"delete net.sf.j2s.ajax.SimplePipeHelper.pipes[key];"
125125
})
126-
staticvoidremovePipe(Stringkey) {
126+
publicstaticvoidremovePipe(Stringkey) {
127127
if (key ==null) {
128128
System.out.println("Removing pipe for null key???");
129129
return;
@@ -155,15 +155,15 @@ public static SimplePipeRunnable getPipe(String key) {
155155
}
156156

157157
@J2SIgnore
158-
staticList<SimpleSerializable>getPipeDataList(Stringkey) {
158+
publicstaticList<SimpleSerializable>getPipeDataList(Stringkey) {
159159
if (pipeMap ==null) {
160160
returnnull;
161161
}
162162
returnpipeMap.get(key);
163163
}
164164

165165
@J2SIgnore
166-
staticvoidpipeIn(Stringkey,SimpleSerializable[]ss) {
166+
publicstaticvoidpipeIn(Stringkey,SimpleSerializable[]ss) {
167167
SimplePipeRunnablepipe =getPipe(key);
168168
List<SimpleSerializable>list =getPipeDataList(key);
169169
if (pipe ==null ||list ==null) {
@@ -180,7 +180,7 @@ static void pipeIn(String key, SimpleSerializable[] ss) {
180180
}
181181

182182
@J2SIgnore
183-
staticbooleanisPipeLive(Stringkey) {
183+
publicstaticbooleanisPipeLive(Stringkey) {
184184
SimplePipeRunnablepipe =getPipe(key);
185185
if (pipe !=null) {
186186
returnpipe.isPipeLive();
@@ -189,7 +189,7 @@ static boolean isPipeLive(String key) {
189189
}
190190

191191
@J2SIgnore
192-
staticbooleannotifyPipeStatus(Stringkey,booleanlive) {
192+
publicstaticbooleannotifyPipeStatus(Stringkey,booleanlive) {
193193
SimplePipeRunnablepipe =getPipe(key);
194194
if (pipe !=null &&pipe.isPipeLive()) {
195195
pipe.updateStatus(live);
@@ -199,7 +199,7 @@ static boolean notifyPipeStatus(String key, boolean live) {
199199
}
200200

201201
@J2SIgnore
202-
publicstaticvoidhelpClosing(SimplePipeRunnablepipe) {
202+
staticvoidhelpClosing(SimplePipeRunnablepipe) {
203203
if (pipe.closer !=null) {
204204
pipe.closer.helpClosing(pipe);
205205
}else {
@@ -208,37 +208,79 @@ public static void helpClosing(SimplePipeRunnable pipe) {
208208
}
209209

210210
@J2SIgnore
211-
publicstaticvoidprintStatistics() {
211+
publicstaticStringprintStatistics2() {
212+
StringBufferbuffer =newStringBuffer();
213+
buffer.append("Pipe monitor<br />\r\n");
212214
if (pipes !=null) {
213-
System.out.println("Totoal pipe count: " +pipes.size());
214-
System.out.println("Totoal pipe map count: " +pipeMap.size());
215+
buffer.append("Totoal pipe count: " +pipes.size() +"<br />\r\n");
216+
buffer.append("Totoal pipe map count: " +pipeMap.size() +"<br />\r\n");
215217
Object[]keys =pipeMap.keySet().toArray();
216218
for (inti =0;i <keys.length;i++) {
217219
Stringkey = (String)keys[i];
218220
List<SimpleSerializable>list =pipeMap.get(key);
219221
SimplePipeRunnablep =pipes.get(key);
220222
if (pinstanceofCompoundPipeRunnable) {
221223
CompoundPipeRunnablecp = (CompoundPipeRunnable)p;
222-
System.out.println(i +"Pipe " +cp.pipeKey +" status=" +cp.status +" pipeAlive=" +cp.isPipeLive() +" created=" +newDate(cp.lastSetup));
224+
intactiveCount =0;
225+
for (intj =0;j <cp.pipes.length;j++) {
226+
if (cp.pipes[j] !=null) {
227+
activeCount++;
228+
}
229+
}
230+
if (activeCount >2) {
231+
buffer.append(i +" Pipe (active=" +activeCount +") " +cp.pipeKey +" status=" +cp.status +" pipeAlive=" +cp.isPipeLive() +" created=" +newDate(cp.lastSetup) +"<br />\r\n");
232+
}
233+
}
234+
if (list !=null) {
235+
intsize =list.size();
236+
if (size >20) {
237+
if (p !=null) {
238+
buffer.append(i +"::: pipe " +p.pipeKey +" size : " +size +" / " +p.pipeAlive +"<br />\r\n");
239+
}else {
240+
buffer.append("Error pipe " +key +" with size : " +size +"<br />\r\n");
241+
}
242+
}
243+
}
244+
}
245+
}
246+
returnbuffer.toString();
247+
}
248+
249+
@J2SIgnore
250+
publicstaticStringprintStatistics() {
251+
StringBufferbuffer =newStringBuffer();
252+
buffer.append("Pipe monitor<br />\r\n");
253+
if (pipes !=null) {
254+
buffer.append("Totoal pipe count: " +pipes.size() +"<br />\r\n");
255+
buffer.append("Totoal pipe map count: " +pipeMap.size() +"<br />\r\n");
256+
Object[]keys =pipeMap.keySet().toArray();
257+
for (inti =0;i <keys.length;i++) {
258+
Stringkey = (String)keys[i];
259+
List<SimpleSerializable>list =pipeMap.get(key);
260+
SimplePipeRunnablep =pipes.get(key);
261+
if (pinstanceofCompoundPipeRunnable) {
262+
CompoundPipeRunnablecp = (CompoundPipeRunnable)p;
263+
buffer.append(i +"Pipe " +cp.pipeKey +" status=" +cp.status +" pipeAlive=" +cp.isPipeLive() +" created=" +newDate(cp.lastSetup) +"<br />\r\n");
223264
for (intj =0;j <cp.pipes.length;j++) {
224265
CompoundPipeSessionps =cp.pipes[j];
225266
if (ps !=null) {
226-
System.out.println(j +" : " +ps.session +" / " +ps.isPipeLive() +" pipeAlive=" +ps.pipeAlive);
267+
buffer.append(j +" : " +ps.session +" / " +ps.isPipeLive() +" pipeAlive=" +ps.pipeAlive +"<br />\r\n");
227268
}
228269
}
229270
}
230271
if (list !=null) {
231272
intsize =list.size();
232273
//if (size > 5) {
233274
if (p !=null) {
234-
System.out.println("::: pipe " +p.pipeKey +" size : " +size +" / " +p.pipeAlive);
275+
buffer.append("::: pipe " +p.pipeKey +" size : " +size +" / " +p.pipeAlive +"<br />\r\n");
235276
}else {
236-
System.out.println("Error pipe " +key +" with size : " +size);
277+
buffer.append("Error pipe " +key +" with size : " +size +"<br />\r\n");
237278
}
238279
//}
239280
}
240281
}
241282
}
283+
returnbuffer.toString();
242284
}
243285

244286
@J2SIgnore
@@ -255,7 +297,7 @@ public static void setMonitoringInterval(long monitoringInterval) {
255297
privatestaticvoidmonitoringAllPipes() {
256298
while (true) {
257299
try {
258-
Thread.sleep(getMonitoringInterval());
300+
Thread.sleep(monitoringInterval);
259301
}catch (InterruptedExceptione) {
260302
}
261303
if (pipes ==null) {
@@ -289,7 +331,7 @@ private static void monitoringAllPipes() {
289331
}
290332
if (ps.isPipeLive()) {
291333
ps.lastLiveDetected =now;
292-
}elseif (now -ps.lastLiveDetected >30000 +ps.pipeWaitClosingInterval()) {
334+
}elseif (now -ps.lastLiveDetected >SimplePipeRequest.pipeLiveNotifyInterval *3 +monitoringInterval +ps.pipeWaitClosingInterval()) {
293335
asyncDestroyPipe(ps);
294336
}
295337
}

‎sources/net.sf.j2s.ajax/ajaxpipe/net/sf/j2s/ajax/SimplePipeHttpServlet.java‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,23 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
167167
buffer.append("<html><head><title></title></head><body>\r\n");
168168
buffer.append("<script type=\"text/javascript\">");
169169
buffer.append("p = new Object ();\r\n");
170-
buffer.append("window.onload =function () {\r\n");
170+
buffer.append("p.key =\"" +key +"\";\r\n");
171171
buffer.append("p.originalDomain = document.domain;\r\n");
172172
buffer.append("document.domain =\"" +domain +"\";\r\n");
173-
buffer.append("p.key =\"" +key +"\";\r\n");
173+
buffer.append("var securityErrors = 0\r\n");
174+
buffer.append("var lazyOnload = function () {\r\n");
175+
buffer.append("try {\r\n");
174176
buffer.append("var spr = window.parent.net.sf.j2s.ajax.SimplePipeRequest;\r\n");
175177
buffer.append("eval (\"(\" + spr.subdomainInit +\") (p);\");\r\n");
176178
buffer.append("eval (\"((\" + spr.subdomainLoopQuery +\") (p)) ();\");\r\n");
177-
buffer.append("};\r\n");
179+
buffer.append("} catch (e) {\r\n");
180+
buffer.append("securityErrors++;\r\n");
181+
buffer.append("if (securityErrors < 100) {\r\n");// 10s
182+
buffer.append("window.setTimeout (lazyOnload, 100);\r\n");
183+
buffer.append("};\r\n");// end of if
184+
buffer.append("};\r\n");// end of catch
185+
buffer.append("};\r\n");// end of function
186+
buffer.append("window.onload = lazyOnload;\r\n");
178187
buffer.append("</script>\r\n");
179188
buffer.append("</body></html>\r\n");
180189
writer.write(buffer.toString());
@@ -191,6 +200,8 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
191200
buffer.append("<script type=\"text/javascript\">");
192201
if (domain !=null) {
193202
buffer.append("document.domain =\"" +domain +"\";\r\n");
203+
}else {
204+
buffer.append("document.domain = document.domain;\r\n");
194205
}
195206
buffer.append("function $ (s) { if (window.parent) window.parent.net.sf.j2s.ajax.SimplePipeRequest.parseReceived (s); }");
196207
buffer.append("if (window.parent) eval (\"(\" + window.parent.net.sf.j2s.ajax.SimplePipeRequest.checkIFrameSrc +\") ();\");\r\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp