18
18
import java .io .IOException ;
19
19
import java .net .URL ;
20
20
import java .util .ArrayList ;
21
- import java .util .Arrays ;
22
21
import java .util .List ;
23
22
24
23
import net .sf .j2s .ajax .AjaxPlugin ;
28
27
import net .sf .j2s .ui .launching .JavaRuntime ;
29
28
import net .sf .j2s .ui .property .FileUtil ;
30
29
import net .sf .j2s .ui .property .J2SClasspathModel ;
30
+
31
31
import org .eclipse .core .runtime .IPath ;
32
32
import org .eclipse .core .runtime .Path ;
33
33
import org .eclipse .core .runtime .Platform ;
34
34
import org .eclipse .jdt .core .IClasspathEntry ;
35
35
import org .eclipse .jdt .core .JavaCore ;
36
- import org .eclipse .jdt .internal .ui .wizards .buildpaths .CPVariableElement ;
37
36
38
37
/**
39
38
* @author zhou renjian
@@ -66,6 +65,7 @@ protected IClasspathEntry[] updateJavaLibraries(
66
65
list .add (JavaCore .newVariableEntry (new Path ("ECLIPSE_SWT" ), null , null ));
67
66
list .add (JavaCore .newVariableEntry (new Path ("AJAX_SWT" ), new Path ("AJAX_SWT_SRC" ), null ));
68
67
list .add (JavaCore .newVariableEntry (new Path ("AJAX_RPC" ), new Path ("AJAX_RPC_SRC" ), null ));
68
+ list .add (JavaCore .newVariableEntry (new Path ("AJAX_PIPE" ), new Path ("AJAX_PIPE_SRC" ), null ));
69
69
return super .updateJavaLibraries ((IClasspathEntry []) list .toArray (new IClasspathEntry [list .size ()]));
70
70
}
71
71
@@ -98,6 +98,13 @@ protected void updateJava2ScriptProject(String prjFolder, String binRelative) {
98
98
+ classpath .substring (idx );
99
99
needUpdate = true ;
100
100
}
101
+ if (classpath .indexOf ("AJAX_PIPE" ) == -1 && classpath .indexOf ("ajaxpipe.jar" ) == -1 ) {
102
+ int idx = classpath .lastIndexOf ("<" );
103
+ classpath = classpath .substring (0 , idx )
104
+ + "\t <classpathentry sourcepath=\" AJAX_PIPE_SRC\" kind=\" var\" path=\" AJAX_PIPE\" />\r \n "
105
+ + classpath .substring (idx );
106
+ needUpdate = true ;
107
+ }
101
108
if (needUpdate ) {
102
109
try {
103
110
FileOutputStream fos = new FileOutputStream (cpFile );
@@ -143,6 +150,22 @@ protected void updateJava2ScriptProject(String prjFolder, String binRelative) {
143
150
e1 .printStackTrace ();
144
151
}
145
152
153
+ newPath = Path .fromPortableString (root + "/ajaxpipe.jar" );
154
+ File pipeFile = new File (newPath .toOSString ());
155
+
156
+ try {
157
+ FileInputStream is = new FileInputStream (pipeFile );
158
+ FileOutputStream os = new FileOutputStream (new File (lib , "ajaxpipe.jar" ));
159
+ byte [] buf = new byte [1024 ];
160
+ int read = -1 ;
161
+ while ((read = is .read (buf )) != -1 ) {
162
+ os .write (buf , 0 , read );
163
+ }
164
+ os .close ();
165
+ is .close ();
166
+ } catch (IOException e1 ) {
167
+ e1 .printStackTrace ();
168
+ }
146
169
StringBuffer buildxml = new StringBuffer ();
147
170
buildxml .append ("<?xml version=\" 1.0\" ?>\r \n " );
148
171
buildxml .append ("<project name=\" java2script.servlet.pack\" default=\" pack.war\" basedir=\" .\" >\r \n " );
@@ -269,41 +292,34 @@ protected void updateJava2ScriptProject(String prjFolder, String binRelative) {
269
292
webxml .append ("<web-app>\r \n " );
270
293
webxml .append (" <display-name>Java2Script</display-name>\r \n " );
271
294
webxml .append (" <description>Java2Script application</description>\r \n " );
295
+
296
+ webxml .append (genereateServlet ("simplerpc" , "net.sf.j2s.ajax.SimpleRPCHttpServlet" ));
297
+ //webxml.append(genereateServlet("simplepiperpc", "net.sf.j2s.ajax.SimplePipeRPCHttpServlet"));
298
+ webxml .append (genereateServlet ("piperpc" , "net.sf.j2s.ajax.CompoundPipeRPCHttpServlet" ));
299
+
272
300
webxml .append (" <servlet>\r \n " );
273
- webxml .append (" <servlet-name>simplerpc</servlet-name>\r \n " );
274
- webxml .append (" <servlet-class>net.sf.j2s.ajax.SimpleRPCHttpServlet</servlet-class>\r \n " );
275
- webxml .append (" <init-param>\r \n " );
276
- webxml .append (" <param-name>simple.rpc.runnables</param-name>\r \n " );
277
- webxml .append (" <!--\r \n " );
278
- webxml .append (" Qualified names of inherited net.sf.j2s.ajax.SimpleRPCRunnable\r \n " );
279
- webxml .append (" classes, seperated by \" ;\" .\r \n " );
280
- webxml .append (" -->\r \n " );
281
- webxml .append (" <param-value>\r \n " );
282
- webxml .append (" </param-value>\r \n " );
283
- webxml .append (" </init-param>\r \n " );
284
- webxml .append (" <init-param>\r \n " );
285
- webxml .append (" <param-name>simple.rpc.xss.support</param-name>\r \n " );
286
- webxml .append (" <param-value>true</param-value>\r \n " );
287
- webxml .append (" </init-param>\r \n " );
288
- webxml .append (" <!--\r \n " );
289
- webxml .append (" <init-param>\r \n " );
290
- webxml .append (" <param-name>simple.rpc.post.limit</param-name>\r \n " );
291
- webxml .append (" <param-value>16777216</param-value>\r \n " );
292
- webxml .append (" </init-param>\r \n " );
293
- webxml .append (" <init-param>\r \n " );
294
- webxml .append (" <param-name>simple.rpc.xss.max.parts</param-name>\r \n " );
295
- webxml .append (" <param-value>8</param-value>\r \n " );
296
- webxml .append (" </init-param>\r \n " );
301
+ webxml .append (" <servlet-name>simplepipe</servlet-name>\r \n " );
302
+ webxml .append (" <servlet-class>net.sf.j2s.ajax.SimplePipeHttpServlet</servlet-class>\r \n " );
297
303
webxml .append (" <init-param>\r \n " );
298
- webxml .append (" <param-name>simple.rpc.xss.max.latency </param-name>\r \n " );
299
- webxml .append (" <param-value>6000 </param-value>\r \n " );
304
+ webxml .append (" <param-name>simple.pipe.query.timeout </param-name>\r \n " );
305
+ webxml .append (" <param-value>20000 </param-value>\r \n " );
300
306
webxml .append (" </init-param>\r \n " );
301
- webxml .append (" -->\r \n " );
302
307
webxml .append (" </servlet>\r \n " );
308
+
303
309
webxml .append (" <servlet-mapping>\r \n " );
304
310
webxml .append (" <servlet-name>simplerpc</servlet-name>\r \n " );
305
311
webxml .append (" <url-pattern>/simplerpc</url-pattern>\r \n " );
306
312
webxml .append (" </servlet-mapping>\r \n " );
313
+
314
+ webxml .append (" <servlet-mapping>\r \n " );
315
+ webxml .append (" <servlet-name>piperpc</servlet-name>\r \n " );
316
+ webxml .append (" <url-pattern>/piperpc</url-pattern>\r \n " );
317
+ webxml .append (" </servlet-mapping>\r \n " );
318
+
319
+ webxml .append (" <servlet-mapping>\r \n " );
320
+ webxml .append (" <servlet-name>simplepipe</servlet-name>\r \n " );
321
+ webxml .append (" <url-pattern>/simplepipe</url-pattern>\r \n " );
322
+ webxml .append (" </servlet-mapping>\r \n " );
307
323
webxml .append ("</web-app>\r \n " );
308
324
try {
309
325
FileOutputStream fos = new FileOutputStream (new File (webinf , "web.xml" ));
@@ -319,4 +335,40 @@ protected void updateJava2ScriptProject(String prjFolder, String binRelative) {
319
335
e1 .printStackTrace ();
320
336
}
321
337
}
338
+
339
+ private String genereateServlet (String name , String clazz ) {
340
+ StringBuffer webxml = new StringBuffer ();
341
+ webxml .append (" <servlet>\r \n " );
342
+ webxml .append (" <servlet-name>" + name + "</servlet-name>\r \n " );
343
+ webxml .append (" <servlet-class>" + clazz + "</servlet-class>\r \n " );
344
+ webxml .append (" <init-param>\r \n " );
345
+ webxml .append (" <param-name>simple.rpc.runnables</param-name>\r \n " );
346
+ webxml .append (" <!--\r \n " );
347
+ webxml .append (" Qualified names of inherited net.sf.j2s.ajax.SimpleRPCRunnable\r \n " );
348
+ webxml .append (" classes, seperated by \" ;\" .\r \n " );
349
+ webxml .append (" -->\r \n " );
350
+ webxml .append (" <param-value>\r \n " );
351
+ webxml .append (" </param-value>\r \n " );
352
+ webxml .append (" </init-param>\r \n " );
353
+ webxml .append (" <init-param>\r \n " );
354
+ webxml .append (" <param-name>simple.rpc.xss.support</param-name>\r \n " );
355
+ webxml .append (" <param-value>true</param-value>\r \n " );
356
+ webxml .append (" </init-param>\r \n " );
357
+ webxml .append (" <!--\r \n " );
358
+ webxml .append (" <init-param>\r \n " );
359
+ webxml .append (" <param-name>simple.rpc.post.limit</param-name>\r \n " );
360
+ webxml .append (" <param-value>16777216</param-value>\r \n " );
361
+ webxml .append (" </init-param>\r \n " );
362
+ webxml .append (" <init-param>\r \n " );
363
+ webxml .append (" <param-name>simple.rpc.xss.max.parts</param-name>\r \n " );
364
+ webxml .append (" <param-value>8</param-value>\r \n " );
365
+ webxml .append (" </init-param>\r \n " );
366
+ webxml .append (" <init-param>\r \n " );
367
+ webxml .append (" <param-name>simple.rpc.xss.max.latency</param-name>\r \n " );
368
+ webxml .append (" <param-value>6000</param-value>\r \n " );
369
+ webxml .append (" </init-param>\r \n " );
370
+ webxml .append (" -->\r \n " );
371
+ webxml .append (" </servlet>\r \n " );
372
+ return webxml .toString ();
373
+ }
322
374
}
0 commit comments