Hello Jim,
I couldn't really explain. :)
The "handle" method of the Application class already detect if the
Appplication is started or not.
As Irfan provides this sample code from a real application, he may have
forgotten to remove this method that can be usefull for some
initializations stuff. .
best regards,
Thierry Boileau
Irfan/Thierry,
I was just wondering whether you could explain why start() is always
called in the RestApplication.handle method, which is shown below.
try {
start();
} catch (Exception ee) {
ee.printStackTrace();
}
super.handle(request, response);
cheers
</jima>
Jim Alateras wrote:
This is much cleaner than what I have done, which was simply to
create an instance of an Application class in the
FrameworkServletinitFrameworkServlet method and then to set the
application as the target of the converter in the doService method.
init
=====
application = new MyApplication(
getWebApplicationContext());
doService
=========
ServletConverter converter = new ServletConverter(getServletContext());
converter.setTarget(application);
converter.service(request, response);
cheers
</jima>
Thierry Boileau wrote:
Hello Matthew,
you can find a sample application that provides integration of
Spring into a servlet container at this URL:
http://wiki.restlet.org
See the "sample code" section.
Best regards,
Thierry Boileau
Thanks for the clear explanation. Yes I would like to use Application.
We are using spring and at present our servlet extends the spring
FrameworkServlet
Any other pointers for good approaches here will be much appreciated
Thanks,
Matthew
On 24/05/2007, at 2:41 AM, Thierry Boileau wrote:
Hi Matthew,
The TunnelFilter worls correctly only in the context of a Restlet
application. We kindly encourage you to use application wich
provides some built-in services such as filtering.
However, if you don't want to be in such case, you can create your
own filter with the code of the "beforeHandle" method.
Having done that, you can add your filter in front of your Router:
**********
// create the converter
this.converter = new ServletConverter(getServletContext());
//create the filter
MyFilter myFilter = new MyFilter();
// create the router and attach a default router
Router router = new Router();
myFilter.setNext(router);
this.converter.setTarget(myFilter);
***********
This way, all requests will transit by your filter that will
update the request object.
I hope it wil help you. Feel free to ask any question.
Best regards,
Thierry Boileau
ps: are you working with Spring?
Thanks for all that. It doesn't seem to work using the
ServletConverter though. I can't work out how I am supposed to
hook it up, my servlet init code looks pretty much like this:
// create the converter
this.converter = new ServletConverter(getServletContext());
// create the router and attach a default router
Router router = new Router();
this.converter.setTarget(router);
I have no Application and so nohting to associate the
TunnelFilter with?
As you can see my knowledge is very limited, any help appreciated
Matthew
On 23/05/2007, at 11:48 PM, Thierry Boileau wrote:
Hello Matthew,
I suppose you think about this issue [1] and this discussion [2].
So, these web pages [3], [4] wait for you!
>Also does this work with the ServletConverter style of Restlet ?
It should, I think, because this had been implemented at the
application level, in the TunnelFilter class.
Best regards,
Thierry Boileau
[1] http://restlet.tigris.org/issues/show_bug.cgi?id=147
[2]
http://restlet.tigris.org/servlets/ReadMsg?list=discuss&msgNo=559
[3]
http://www.restlet.org/documentation/1.0/api/org/restlet/service/TunnelService.html
[4]
http://www.restlet.org/documentation/1.0/nre/com/noelios/restlet/application/TunnelFilter.html
In previous discussions I had sen somethign about being able to
"coerce" particular content type by specifying a parameter in
the incoming URL, something like
http://host.com/resource?media=json
But I can't turn up anything in the documenation. Can someone
please point me in the right place. Also does this work with
the ServletConverter style of reslet ?
Thanks,
Matthew