Salut,
falcon wrote:
> Hi,
> I need to embed a web/comet server inside another server. Whenever the main
> server is updated, I need to send out these updates to client's browsers
> using comet. Since I need to embed the server, I am using some examples
> from Jean-Francois's blog in the following manner:
>
> public static void main(String[] args) throws IOException {
> GrizzlyWebServer ws = new GrizzlyWebServer(8080,"./web/");
> ws.addGrizzlyAdapter(new GrizzlyAdapter(){
>
> @Override
> public void service(GrizzlyRequest arg0, GrizzlyResponse arg1) {
> //for some reason, if I don't add this dummy adapter, I get a 404 error
> //with this, I get the index.html correctly...but this is not the issue
>
> }});
> ws.addAsyncFilter(new CometAsyncFilter());
> ws.addGrizzlyAdapter(new CometdAdapter());
>
> ws.start();
> }
>
> The problem is, I don't really understand where my cometd logic goes.
As soon as you add the CometdAdapter, you have installed bayeux support.
Hence you are ready to start the Grizzly WS and listen to "bayeux" request.
>
> Do I need to create a servlet (as in this document:
> http://docs.sun.com/app/docs/doc/820-4496/ghgxk?a=view)? That would mean
> that I have to add a servlet adapter. I have no problem adding a servlet
> adapter, but then what is the purpose of CometdAdapter?
No, with Bayeux/Cometd, you don't need to add anything. If you want to
see an example, take a look at:
> https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/standalone/cometd/Cometd.html#139
It not exactly what you are looking at, but it gives you an idea of how
internally, when using:
java -jar grizzly-cometd-webserver.jar -p 8080
>
> I actually expected that I would pass in some sort of handler to the
> CometdAdapter.
>
> Can someone please help me out of this confusion?
Does the above help? Let me know if not and I will try to write a code
snippet that can help you. What do you want to do with Cometd? Are you
planning to do update using Java or using Javascript?
Thanks
-- Jeanfrancois
>
> Thanks