Hi all,
another issue with GWS is that, when i enable the ASynC stuff,
after 2-3 req on firefox4 it just stop to work :)
i can reproduce this
issue not only with ff4 but even with other webbrowser.
the issue is
for sure related to the usage of async stuff, and probably related to
http1.1 (keepalive) stuff.
i have see some similar problem in one past
version of gws, unfortunatly i can't remember which one :)
*
package
test;
import com.sun.grizzly.arp.AsyncExecutor;
import com.sun.grizzly.
arp.AsyncFilter;
import com.sun.grizzly.http.embed.GrizzlyWebServer;
import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
import com.sun.
grizzly.tcp.http11.GrizzlyRequest;
import com.sun.grizzly.tcp.http11.
GrizzlyResponse;
import com.sun.grizzly.util.http.MimeType;
import
java.io.IOException;
import java.util.concurrent.Callable;
import java.
util.concurrent.ScheduledThreadPoolExecutor;
import java.util.
concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Created by IntelliJ IDEA.
* User: Rama
* Date: 30-ott-2009
*
Time: 11.49.46
*/
public class DemoWebServer {
static final
AtomicInteger req = new AtomicInteger();
public static void main
(String args[]) {
GrizzlyWebServer test = new GrizzlyWebServer
(7777, "/Users/ramarama/IdeaProject/c2w_test/c2w/cert/");
test.
addGrizzlyAdapter(new MyGrizzlyAdapter(), new String[]{"/"});
test.getSelectorThread().setDisplayConfiguration(true);
test.
getSelectorThread().setCompression("on");
test.addAsyncFilter
(new MyAsyncFilter());
try {
test.start();
} catch (IOException e) {
e.printStackTrace(); //To change
body of catch statement use File | Settings | File Templates.
}
while (true) {
try {
Thread.sleep
(20500);
} catch (Exception e) {
}
}
}
static class MyAsyncFilter implements AsyncFilter {
private final ScheduledThreadPoolExecutor scheduler =
new ScheduledThreadPoolExecutor(1);
public Result doFilter
(final AsyncExecutor asyncExecutor) {
scheduler.schedule
(new Callable() {
public Object call() throws Exception
{
asyncExecutor.execute();
asyncExecutor.postExecute();
return Result.FINISH;
}
}, 10, TimeUnit.MILLISECONDS);
return Result.INTERRUPT;
}
}
static class
MyGrizzlyAdapter extends GrizzlyAdapter {
public
MyGrizzlyAdapter() {
this.setHandleStaticResources(false);
}
public void service(GrizzlyRequest grizzlyRequest,
GrizzlyResponse grizzlyResponse) {
try {
StringBuilder someJunk = new StringBuilder();
grizzlyResponse.setContentType(MimeType.get("html"));
someJunk.append("junk<br>");
for (int i = 0; i < 10;
i++) someJunk.append(someJunk);
grizzlyResponse.
getWriter().print(someJunk);
req.incrementAndGet();
} catch (IOException e) {
}
}
}
}
Non temiamo alcun confronto: Tiscali ha l'Adsl più veloce d'Italia! Risparmia con Tutto Incluso Light: Voce + Adsl 20 mega a soli 17,95 € al mese per 12 mesi.
http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso_light/?WT.mc_id=01fw