简体   繁体   中英

In Restlet, how can I get the Router instance from a ServerResource?

How can I get access to the Application's Router instance from my ServerResource class? Is it even possible?

Thanks in advance.

I'm not sure how I didn't find the answer to this when I asked the question... but it's pretty straightforward. In your "doInit" method you can do something like this:

Router myRouter = (Router)this.getApplication.getRoot();

Very simple!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM