On Wed, Aug 26, 2009 at 4:09 AM, William Tam<[email protected]> wrote: > Hi Todd and Willem, > > Willem's suggestion would work. We do support multiple URI templates > on a same route. > > So, you could do something like: (also see > http://cwiki.apache.org/confluence/display/CAMEL/Restlet) > > <bean id="uriTemplates"> > <list> > <value>/blah.com/people/{id}</value> > <value>/blah.com/people/{id}.json</value> > </list> > </bean> > > from("restlet:http://localhost:9080?restletUriPatterns=#uriTemplates") > .process(new Processor() { > ... > } > > Or, you can split them into two routes: > > from("restlet:http://localhost:9080/blah.com/people/{id").process(" ... ") > from("restlet:http://localhost:9080/blah.com/people/{id}.json").process(" > ...") > > The latter approach creates one camel endpoint per template. So, if > you have a lot of templates, you may prefer the first approach. Other > than that, the two approaches are equivalent (in terms of > performance/scalability) and it comes down to your style and design > pattern. Both approaches require only one org.restlet.Component > object instance in RestletComponent to support all the URI templates. > > Hope this help. >
Cool reply. I think you should add a FAQ entry about it. And maybe a little link/note on the camel restlet page to this FAQ. > - William > > > On Tue, Aug 25, 2009 at 8:52 PM, Willem Jiang<[email protected]> wrote: >> Hi, >> >> I don't think current camel supports two froms within a single route. >> But you can use the direct endpoint to reuse the route like this >> >> from("restlet:blah.com/people/{id}").to("direct://myRoute"); >> from("restlet:blah.com/people/{id}.json").to("direct://myRoute"); >> >> from("direct://myRoute")... >> >> Since the direct endpoint just copy the message exchange , it will not slow >> down your application. >> >> Willem >> >> >> tfredrich wrote: >>> >>> When using the Restlet component to expose tidy URIs, what would you >>> recommend regarding exposing routes as multiple endpoints? For instance, >>> a >>> single endpoint returns JSON (e.g. /people/toddf returns a JSON object >>> describing person ID 'toddf'). Now suppose I want to expose the same >>> endpoint with an explicit format URI (e.g. /people/toddf.json) that >>> returns >>> the same data. >>> >>> Is it better to have two routes exposed or two 'from()s' in the same >>> route? >>> >>> In other words, which is better: >>> >>> *Two froms within a single route: >>> >>> from("restlet:blah.com/people/{id}").from("restlet:blah.com/people/{id}.json")... >>> >>> or >>> >>> * Two separate routes: >>> >>> from("restlet:blah.com/people/{id}")... >>> >>> from("restlet:blah.com/people/{id}.json")... >>> >>> >>> Does it make a difference from a scalability, performance, and/or heap >>> consumption standpoint? Thanks in advance for your advice. >>> >>> --Todd >> >> > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
