Skip to content

Commit be1b6d9

Browse files
author
zhourenjian
committed
Add Simple Pipe into j2slib core
1 parent 938b872 commit be1b6d9

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

sources/net.sf.j2s.ajax/.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<classpathentry kind="src" path="ajaxcore"/>
77
<classpathentry kind="src" path="ajaxswt"/>
88
<classpathentry kind="src" path="ajaxrpc"/>
9+
<classpathentry kind="src" path="ajaxpipe"/>
910
<classpathentry kind="var" path="JAVAX_SERVLET"/>
1011
<classpathentry kind="output" path="bin"/>
1112
</classpath>

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,15 @@ protected void doPipe(final HttpServletResponse resp, String key, String type)
141141
int size = vector.size();
142142
if (size > 0) {
143143
for (int i = size - 1; i >= 0; i--) {
144+
SimpleSerializable ss = null;
144145
/*
145146
* Still need to check vector size!
146147
* Maybe multiple pipe servlets!
147148
*/
148-
if (vector.size() <= 0) break;
149-
SimpleSerializable ss = vector.remove(0);
149+
synchronized (vector) {
150+
if (vector.size() <= 0) break;
151+
ss = vector.remove(0);
152+
}
150153
if (ss == null) break; // terminating signal
151154
output(writer, type, key, ss.serialize());
152155
writer.flush();

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,24 @@ protected static String adjustRequestURL(String method, String url, String seria
165165
port = 443;
166166
} else {
167167
port = window.location.port;
168+
if (port != "") {
169+
port = parseInt (port);
170+
}
168171
}
169172
}
170173
var loc = window.location;
174+
var locPort = loc.port;
175+
if (locPort == "") {
176+
if ("http:" == loc.protocol) {
177+
locPort = 80;
178+
} else if ("https:" == loc.protocol) {
179+
locPort = 443;
180+
}
181+
} else {
182+
locPort = parseInt (locPort);
183+
}
171184
return (loc.host != host || loc.protocol != protocol
172-
|| loc.port != port
185+
|| locPort != port
173186
|| loc.protocol == "file:");
174187
}
175188
return false; // ftp ...

sources/net.sf.j2s.ajax/plugin.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<classpathVariableInitializer
1313
class="net.sf.j2s.ajax.AJAXVariableInitializer"
1414
variable="AJAX_RPC"/>
15+
<classpathVariableInitializer
16+
class="net.sf.j2s.ajax.AJAXVariableInitializer"
17+
variable="AJAX_PIPE"/>
1518
<classpathVariableInitializer
1619
class="net.sf.j2s.ajax.AJAXVariableInitializer"
1720
variable="AJAX_CORE_SRC"/>
@@ -21,6 +24,9 @@
2124
<classpathVariableInitializer
2225
class="net.sf.j2s.ajax.AJAXVariableInitializer"
2326
variable="AJAX_RPC_SRC"/>
27+
<classpathVariableInitializer
28+
class="net.sf.j2s.ajax.AJAXVariableInitializer"
29+
variable="AJAX_PIPE_SRC"/>
2430
</extension>
2531

2632
</plugin>

0 commit comments

Comments
 (0)