Hi Brian,
Brian McCallister wrote:
> I grabbed the HTTP part of grizzly today and pulled out what I had done
> previously against the 1.0 version to port to 1.5-SNAPSHOT. Where before
> I had:
>
> public static void main(String[] args) throws IOException,
> InstantiationException
> {
> SelectorThread sel = new SelectorThread();
> sel.setPort(8002);
>
> sel.setAdapter(new MyAdapter());
>
> final AsyncHandler handler = new DefaultAsyncHandler();
> handler.addAsyncFilter(new AsyncFilter()
> {
> public boolean doFilter(final AsyncExecutor executor)
> {
> final AsyncTask asyncTask = executor.getAsyncTask();
> final AsyncHandler asyncHandler =
> executor.getAsyncHandler();
>
> final DefaultProcessorTask processorTask =
> (DefaultProcessorTask)
> executor.getAsyncTask().getProcessorTask();
> processorTask.getRequest().setAttribute(CALLBACK_KEY,
> new Runnable() {
> public void run()
> {
> asyncHandler.handle(asyncTask);
> }
> });
> processorTask.invokeAdapter();
> return false;
> }
> });
> sel.setAsyncHandler(handler);
> sel.setEnableAsyncExecution(true);
> sel.setDisplayConfiguration(true);
> sel.initEndpoint();
> sel.startEndpoint();
> }
>
> and an adaptor:
>
> class MyAdapter implements Adapter
> {
> static byte[] CONTENT;
> {
> CONTENT = ByteChunk.convertToBytes("hello world!\n");
> }
>
> private static final ScheduledExecutorService exec =
> Executors.newScheduledThreadPool(2);
>
> public void service(final Request req, final Response res)
> throws Exception
> {
> System.out.println("got request");
> exec.schedule(new Callable<Void>() {
> public Void call() throws Exception
> {
> res.setStatus(200);
>
> byte[] bytes = CONTENT;
> ByteChunk chunk = new ByteChunk();
> res.setContentLength(bytes.length);
> res.setContentType("text/plain");
> chunk.append(bytes, 0, bytes.length);
> res.doWrite(chunk);
> System.out.println("sending resposne!");
> Async.commit(req);
> return null;
> }
> }, 10, TimeUnit.SECONDS);
> }
>
> public void afterService(Request req, Response res) throws
> Exception
> {
> req.action( ActionCode.ACTION_POST_REQUEST , null);
> }
>
> public void fireAdapterEvent(String type, Object data)
> {
> }
> }
>
> Which would correctly respond in 10 seconds, now it responds with
> nothing immediately, and 10 seconds later attempts to respond but
> doesn't actually do anything (also logging no error).
yes I didn't yet have a chance to properly test the Grizzly ARP support
from 1.0 to 1.5. I will take a look and fix it as soon as possible.
>
> Any guidelines on how to do ARP with the new code?
The goal is to not have anything to change, hence I've filled:
https://grizzly.dev.java.net/issues/show_bug.cgi?id=1
Will take a look as soon as possible.
Thanks!
-- Jeanfrancois
>
> -Brian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>