Hello, I'm trying to do something similar, parsing the path-components
of an URI to create a kind of query. I dont know the count,type or order
of the parameters (the path-components) of this query at compile-time so
I thought about creating the query on the fly with chained routers and
extending the query at each step.
Anyway, I have my reasons not to use query-parameters for this (because
theres hypermedia with info/links to further application states involved
at each resource-step) and want to dynamically collect the semantic of
the query at each path-step.
Could you please provide me with a code-snippet how you did it Sanjay,
because I think thats very close to the thing I would need ....
Ralf
Sanjay Acharya schrieb:
Hi Jerome,
Thanks for the suggestion. I have actually subclassed the Router class and
overriden the getNext() method to provide me the URI. I am storing the partial
uri in the case of router chaining to and finally aggregating the same.
Thanks again.
Sanjay
----------------------------------------
From: [EMAIL PROTECTED]
To: discuss@restlet.tigris.org
Date: Fri, 11 Apr 2008 18:38:19 +0200
Subject: RE: Tracking Request and Patterns
Hi Sanjay,
Here is another idea:
1) Create a subclass of the Route class (which is a Filter) and add the
logic to save the URI template in each request handled. You have access to
the template via the Route.getTemplate() method.
2) Create a subclass the Router class and override the createRoute(String
uriTemplate, Restlet target) to return instances of your Route subclass.
3) Use your Router subclass instead of normal Router instances.
That's all you should need! :)
Best regards,
Jerome
-----Message d'origine-----
De : Sanjay Acharya [mailto:[EMAIL PROTECTED]
Envoyé : mardi 8 avril 2008 17:43
À : discuss@restlet.tigris.org
Objet : Tracking Request and Patterns
Hi,
I am trying to develop a tracker to determine which pattern
uri of a restlet service has been invoked. For example, an
OrderApplication may support:
/order
/order/{orderId}
/order/lineItem/{lineItemId}
I would like to be able to intercept a request and place the
pattern uri (example:/order/{orderId}) into the request
object so that I might be able to use it later for tracking
purpose. For example,
being able to use the the result that I place in the request
within a Tomcat Valve or Filter:
I am searching for the best place to handle this. My first
thought was to extend the Application class by providing a
custom AbstractApplication that would do the following:
public abstract class MyApplication extends Application {
public void handle(Request request, Response response) {
super.handle(request, response);
Restlet root = super.getRoot();
if (! (root instanceof Router)) {
return;
}
Router router = (Router) root;
RouteList rlist = router.getRoutes();
Route route = rlist.getBest(request, response,
router.getRequiredScore());
Template t = route.getTemplate();
String servicedPattern = t.getPattern();
Map attributes = new HashMap();
attribues.put("SERVICED_PATTERN", servicedPattern);
// Place the pattern serviced in the request so that it
may be extracted later.
request.setAttributes(attributes);
}
}
I however do not believe the above is the correct place for
this sort of tracking as the above code assumes that the
routers are not chained. Further placing I am not sure whether
placing objects in org.restlet.data.Request will be available
after the restlet finishes the processing, something I have
yet to try.
Any suggestions/thoughts/experiences with where the best
place to plugin this tracking information would be appreciated.
Regards,
Sanjay
_________________________________________________________________
Pack up or back up–use SkyDrive to transfer files or keep
extra copies. Learn how.
hthttp://www.windowslive.com/skydrive/overview.html?ocid=TXT_T
AGLM_WL_Refresh_skydrive_packup_042008=
_________________________________________________________________
Going green? See the top 12 foods to eat organic.
http://green.msn.com/galleries/photos/photos.aspx?gid=164&ocid=T003MSN51N1653A