In the Java, you're making an anonymous class that defines your GrizzlyAdapter, which you aren't doing in the Ruby. I'm not sure how/if JRuby lets you define anonymous classes, but if you made a separate Ruby class that extended GrizzlyAdapter (and implemented service()), you should be able to pass that in to start your web server.

Paul Fraser wrote:
|From Jean-Farncois Arcand's Blog and Grizzly API examples.
How would the service method in this java code be handled in JRuby?
Not being a java genius, it has me bewildered!

GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
 try{
ws.addGrizzlyAdapter(new GrizzlyAdapter(){ public void service(GrizzlyRequest request, GrizzlyResponse response){
          try {
              response.getWriter().println("Grizzly is soo cool..but you request 
cannot be found!");
} catch (IOException ex) { }
        }
      });
    ws.start();
  } catch (IOException ex){
   // Something when wrong.
  }

JRuby Version-------

class GrizzlyHttpServer
attr_accessor :ws
def initialize(static_dir)
  @ws = ||GrizzlyWebServer.new(||static_dir||)      ### works well if the 
adapter stuff commented out
  begin
    @ws.addGrizzlyAdapter(GrizzlyAdapter.new) ### fails "can't make instance of 
GrizzlyAdapter (TypeError)
|  rescue

  end
end
end

server = |GrizzlyHttpServer.new("/var/www")
server.ws.start
server.ws.stop
|--------------------

Thanks
Paul Fraser


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to