Re: [Simpleweb-Support] Tutorial example out of date?
Brought to you by:
niallg
From: Toby <tob...@gm...> - 2010-10-15 10:19:16
|
Great thanks. I was looking at AsyncWeb which talks about "asynchronous throughout" and was interested in the difference (having not really understood AsyncWebs description). The (Simple) asynchronous stuff were discussing is the thread per request model I guess and we can avoid running out using the queue (as in the example) so I was curious about an alternative that AsyncWeb tries to describe... ...bit random I know, but if you have any comments I'd be interested :) Cheers Toby On 15 Oct 2010, at 10:39, Niall Gallagher <gal...@ya...> wrote: > Hi, > > Thats pretty much the idea. For instance if your service needs to do something that requires some time to complete, for example waiting for a JMS message, then asynchronous behaviour here becomes a real advantage. As it allow many connections to be open servicing requests without then need for a separate thread for each. > > Similar to whats been proposed for Servlet 3.0 spec, but done in a much more straight forward manner. > > Niall > > --- On Thu, 14/10/10, Toby <tob...@gm...> wrote: > > From: Toby <tob...@gm...> > Subject: Re: [Simpleweb-Support] Tutorial example out of date? > To: "Simple support and user issues" <sim...@li...> > Received: Thursday, 14 October, 2010, 10:35 PM > > Thanks, > > Are the other dice kicking around? I was running some tests to try and better understand the difference between a regular container servicing requests and the example that delegates to a Executor. Is it the simple case blocking? Clients will wait for a request to complete and in the mean time, the server won't accept new connections? > > Thanks > > Toby > > > On 15 Oct 2010, at 00:32, Niall Gallagher <gal...@ya...> wrote: > >> Hi, >> >> Yes the tutorial is out of date, I really must update it. Thanks for the feedback. >> >> Regards, >> Niall >> >> --- On Thu, 14/10/10, Toby <tob...@gm...> wrote: >> >> From: Toby <tob...@gm...> >> Subject: [Simpleweb-Support] Tutorial example out of date? >> To: sim...@li... >> Received: Thursday, 14 October, 2010, 12:41 PM >> >> Hello, >> >> I was just looking through the tutorial on the main Simple site, am I correct in thinking the example for aysnc stuff (http://www.simpleframework.org/doc/tutorial/tutorial.php#async) is out of date? It doesn't want to compile, shouldn't it look like the example below instead? >> >> Thanks in advance, >> Toby >> >> >> package com.ubs.apman.transport; >> >> import org.simpleframework.http.Request; >> import org.simpleframework.http.Response; >> import org.simpleframework.http.core.Container; >> import org.simpleframework.transport.connect.Connection; >> import org.simpleframework.transport.connect.SocketConnection; >> import org.simpleframework.util.thread.Scheduler; >> >> import java.io.IOException; >> import java.io.PrintStream; >> import java.net.InetSocketAddress; >> import java.net.SocketAddress; >> >> public class FooTest { >> >> >> public static class AsynchronousService implements Container { >> private Scheduler queue; >> >> public class Task implements Runnable { >> >> private final Response response; >> private final Request request; >> >> public Task(Request request, Response response) { >> this.response = response; >> this.request = request; >> } >> >> public void run() { >> PrintStream body = null; >> try { >> body = response.getPrintStream(); >> long time = System.currentTimeMillis(); >> >> response.set("Content-Type", "text/plain"); >> response.set("Server", "HelloWorld/1.0 (Simple 4.0)"); >> response.setDate("Date", time); >> response.setDate("Last-Modified", time); >> >> body.println("Hello World"); >> } catch (IOException e) { >> throw new RuntimeException(e); >> } finally { >> if (body != null) body.close(); >> } >> } >> } >> >> public AsynchronousService(Scheduler queue) { >> this.queue = queue; >> } >> >> public void handle(Request request, Response response) { >> Task task = new Task(request, response); >> queue.execute(task); >> } >> >> } >> >> public static void main(String[] list) throws Exception { >> Scheduler scheduler = new Scheduler(5); >> Container container = new AsynchronousService(scheduler); >> Connection connection = new SocketConnection(container); >> SocketAddress address = new InetSocketAddress(8080); >> connection.connect(address); >> } >> >> } >> >> >> -----Inline Attachment Follows----- >> >> ------------------------------------------------------------------------------ >> Beautiful is writing same markup. Internet Explorer 9 supports >> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. >> Spend less time writing and rewriting code and more time creating great >> experiences on the web. Be a part of the beta today. >> http://p.sf.net/sfu/beautyoftheweb >> >> -----Inline Attachment Follows----- >> >> _______________________________________________ >> Simpleweb-Support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simpleweb-support >> >> > >> ------------------------------------------------------------------------------ >> Download new Adobe(R) Flash(R) Builder(TM) 4 >> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly >> Flex(R) Builder(TM)) enable the development of rich applications that run >> across multiple browsers and platforms. Download your free trials today! >> http://p.sf.net/sfu/adobe-dev2dev > >> _______________________________________________ >> Simpleweb-Support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev > > -----Inline Attachment Follows----- > > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > ------------------------------------------------------------------------------ > Download new Adobe(R) Flash(R) Builder(TM) 4 > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly > Flex(R) Builder(TM)) enable the development of rich applications that run > across multiple browsers and platforms. Download your free trials today! > http://p.sf.net/sfu/adobe-dev2dev > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support |