uriPattern exactness

2008-10-15 Thread Cliff Binstock
I was wondering if there is some trick way to find the exact matched
pattern.  Specifically, I am seeing this (somewhat logical) behavior.

If the uriPattern is "/foos/{foo}/bar"

This of course matches something like "/foos/myFoo/barlksjfljj.xml"
 
What I want is:  If I type in "/foos/myFoo/barlksjfljj.xml", I could
determine that "/foos/myFoo/bar" was the actual match.

Maybe I just missed an existing API call?  :)

Thanks much in advance,

Cliff Binstock



Re: uriPattern exactness

2008-10-16 Thread Thierry Boileau

Hi Cliff,

I'm sorry, but I think I miss your question. ;)
What do you want to do? What kind of entity will handle the data: "the 
exact matched pattern for "/foos/myFoo/barlksjfljj.xml" "?



Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org 
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 




I was wondering if there is some trick way to find the exact matched
pattern.  Specifically, I am seeing this (somewhat logical) behavior.

If the uriPattern is "/foos/{foo}/bar"

This of course matches something like "/foos/myFoo/barlksjfljj.xml"
 
What I want is:  If I type in "/foos/myFoo/barlksjfljj.xml", I could

determine that "/foos/myFoo/bar" was the actual match.

Maybe I just missed an existing API call?  :)

Thanks much in advance,

Cliff Binstock

  


RE: uriPattern exactness

2008-10-16 Thread Cliff Binstock
Thierry,

 

Actually what I want to do, sometimes, is abort the processing.(and probably
return a "Not Found" error).

 

Right now, the caller can use a somewhat "garbage" uri, and the uriPattern
will match.  Note that I want to be very selective, because I want to match,
for example "./bar.xml", but probably not "./barlksjfljj.xml".

 

 

Thanks.

 

Cliff Binstock
Coyote Reporting

  _  

From: Thierry Boileau [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 16, 2008 2:27 AM
To: discuss@restlet.tigris.org
Subject: Re: uriPattern exactness

 

Hi Cliff,

I'm sorry, but I think I miss your question. ;)
What do you want to do? What kind of entity will handle the data: "the exact
matched pattern for "/foos/myFoo/barlksjfljj.xml" "?


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/> 
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
<http://www.noelios.com/> 




I was wondering if there is some trick way to find the exact matched
pattern.  Specifically, I am seeing this (somewhat logical) behavior.
 
If the uriPattern is "/foos/{foo}/bar"
 
This of course matches something like "/foos/myFoo/barlksjfljj.xml"
 
What I want is:  If I type in "/foos/myFoo/barlksjfljj.xml", I could
determine that "/foos/myFoo/bar" was the actual match.
 
Maybe I just missed an existing API call?  :)
 
Thanks much in advance,
 
Cliff Binstock
 
  


RE: uriPattern exactness

2008-10-16 Thread Cliff Binstock
P.S.  What is worse (maybe very confusing) is that this might match too:

 

/foo/myFoo/bar/baz/bletch/fred.xml

 

Again, I would like to forcefully ensure that this doesn't end up matching.

 

Cliff Binstock
Coyote Reporting

  _  

From: Cliff Binstock [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 16, 2008 8:54 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness

 

Thierry,

 

Actually what I want to do, sometimes, is abort the processing.(and probably
return a "Not Found" error).

 

Right now, the caller can use a somewhat "garbage" uri, and the uriPattern
will match.  Note that I want to be very selective, because I want to match,
for example "./bar.xml", but probably not "./barlksjfljj.xml".

 

 

Thanks.

 

Cliff Binstock
Coyote Reporting

  _  

From: Thierry Boileau [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 16, 2008 2:27 AM
To: discuss@restlet.tigris.org
Subject: Re: uriPattern exactness

 

Hi Cliff,

I'm sorry, but I think I miss your question. ;)
What do you want to do? What kind of entity will handle the data: "the exact
matched pattern for "/foos/myFoo/barlksjfljj.xml" "?


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/> 
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
<http://www.noelios.com/> 



I was wondering if there is some trick way to find the exact matched
pattern.  Specifically, I am seeing this (somewhat logical) behavior.
 
If the uriPattern is "/foos/{foo}/bar"
 
This of course matches something like "/foos/myFoo/barlksjfljj.xml"
 
What I want is:  If I type in "/foos/myFoo/barlksjfljj.xml", I could
determine that "/foos/myFoo/bar" was the actual match.
 
Maybe I just missed an existing API call?  :)
 
Thanks much in advance,
 
Cliff Binstock
 
  


RE: uriPattern exactness

2008-10-16 Thread Aron Roberts
In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff 
Binstock wrote:



P.S.  What is worse (maybe very confusing) is that this might match too:
/foo/myFoo/bar/baz/bletch/fred.xml
Again, I would like to forcefully ensure that this doesn't end up matching.


  From memory - by default, the mode for matching incoming URIs to 
your URI templates is 'starts with' rather than 'equals'.


As Jerome wrote back in February 2008:

In some cases, you might want to change this default mode, and this
is easy to do via the "defaultMatchingMode" property on Router, or by
modifying the "matchingMode" property of the template associated with
the route created by the Router.attach() methods. For the modes, you can
use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."


  Here's one example of the latter:

router.getTemplate().setMatchingMode(Template.MODE_EQUALS)

  Hope this is germane to your needs.

Aron


RE: uriPattern exactness

2008-10-16 Thread Cliff Binstock
Aron,

Thanks, I didn't realize this was here.  This would potentially work, and I
may end up using it.

Frankly, I want to be able to "have my cake and eat it too".  An exact match
using this construct would work, but would also force me to itemize every
possible variation of a path via router.attach().  I was hoping to do some
"fuzzy" enforcement in a base "Resource" class.

Cliff Binstock
Coyote Reporting




> -Original Message-
> From: Aron Roberts [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 16, 2008 11:37 AM
> To: discuss@restlet.tigris.org
> Subject: RE: uriPattern exactness
> 
> In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
> Binstock wrote:
> 
> >P.S.  What is worse (maybe very confusing) is that this might match too:
> >/foo/myFoo/bar/baz/bletch/fred.xml
> >Again, I would like to forcefully ensure that this doesn't end up
> matching.
> 
>From memory - by default, the mode for matching incoming URIs to
> your URI templates is 'starts with' rather than 'equals'.
> 
> As Jerome wrote back in February 2008:
> >In some cases, you might want to change this default mode, and this
> >is easy to do via the "defaultMatchingMode" property on Router, or by
> >modifying the "matchingMode" property of the template associated with
> >the route created by the Router.attach() methods. For the modes, you can
> >use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
> 
>Here's one example of the latter:
> 
> router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
> 
>Hope this is germane to your needs.
> 
> Aron



Re: uriPattern exactness

2008-10-16 Thread Thierry Boileau

Hi Cliff,

you can also update the type of the declared variable in your URI template:

Route route = router.attach("/foos/{foo}/bar", sth);
Template template = 
route.getTemplate().setMatchingMode(Template.MODE_EQUALS);

template.getVariables().put("foo", new Variable(Variable.TYPE_WORD));

You can find the list of all variable types in the Variable class.

Otherwise, the routing process is based on URI template. If you want one 
based on regexp, I send you a sample template class based on regexp 
pattern and a server/client test code.



Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/>
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
<http://www.noelios.com/>



Aron,

Thanks, I didn't realize this was here.  This would potentially work, and I
may end up using it.

Frankly, I want to be able to "have my cake and eat it too".  An exact match
using this construct would work, but would also force me to itemize every
possible variation of a path via router.attach().  I was hoping to do some
"fuzzy" enforcement in a base "Resource" class.

Cliff Binstock
Coyote Reporting




  

-Original Message-
From: Aron Roberts [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2008 11:37 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness

In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
Binstock wrote:



P.S.  What is worse (maybe very confusing) is that this might match too:
/foo/myFoo/bar/baz/bletch/fred.xml
Again, I would like to forcefully ensure that this doesn't end up
  

matching.

   From memory - by default, the mode for matching incoming URIs to
your URI templates is 'starts with' rather than 'equals'.

As Jerome wrote back in February 2008:


In some cases, you might want to change this default mode, and this
is easy to do via the "defaultMatchingMode" property on Router, or by
modifying the "matchingMode" property of the template associated with
the route created by the Router.attach() methods. For the modes, you can
use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
  

   Here's one example of the latter:

router.getTemplate().setMatchingMode(Template.MODE_EQUALS)

   Hope this is germane to your needs.

Aron


testTemplateCustomized.jar
Description: application/java-archive


RE: uriPattern exactness

2008-10-17 Thread Jerome Louvel

Hi Cliff,

In combination with MODE_EQUALS, you could also add a variable for your
extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
alternative routes you would have to attach.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-Message d'origine-
De : Cliff Binstock [mailto:[EMAIL PROTECTED] 
Envoye : vendredi 17 octobre 2008 01:28
A : discuss@restlet.tigris.org
Objet : RE: uriPattern exactness

Aron,

Thanks, I didn't realize this was here.  This would potentially work, and I
may end up using it.

Frankly, I want to be able to "have my cake and eat it too".  An exact match
using this construct would work, but would also force me to itemize every
possible variation of a path via router.attach().  I was hoping to do some
"fuzzy" enforcement in a base "Resource" class.

Cliff Binstock
Coyote Reporting




> -Original Message-
> From: Aron Roberts [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 16, 2008 11:37 AM
> To: discuss@restlet.tigris.org
> Subject: RE: uriPattern exactness
> 
> In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
> Binstock wrote:
> 
> >P.S.  What is worse (maybe very confusing) is that this might match too:
> >/foo/myFoo/bar/baz/bletch/fred.xml
> >Again, I would like to forcefully ensure that this doesn't end up
> matching.
> 
>From memory - by default, the mode for matching incoming URIs to
> your URI templates is 'starts with' rather than 'equals'.
> 
> As Jerome wrote back in February 2008:
> >In some cases, you might want to change this default mode, and this
> >is easy to do via the "defaultMatchingMode" property on Router, or by
> >modifying the "matchingMode" property of the template associated with
> >the route created by the Router.attach() methods. For the modes, you can
> >use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
> 
>Here's one example of the latter:
> 
> router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
> 
>Hope this is germane to your needs.
> 
> Aron



Re: uriPattern exactness

2008-10-17 Thread John D. Mitchell

On Friday 2008.10.17, at 04:01 , Jerome Louvel wrote:
[...]
In combination with MODE_EQUALS, you could also add a variable for  
your
extensions like: "/foos/{foo}/bar.{ext}". That could reduce the  
number of

alternative routes you would have to attach.


Yes and no.  I use that trick but I still have to also have e.g.:
/foos/{foo}/bar
as well since the dot shouldn't be there if there's no extension. When  
I last looked, I couldn't find any way to make things optional (so if  
it's still not possible to do that in the latest versions, I'd suggest  
looking into it -- something like /bar(.{ext})? so that it hangs  
together properly).


FWIW, I do send both to the same resource and just have the resource  
look for the optional parts. e.g.:

ext = (String) request.getAttributes().get("ext");
if (null == ext)
ext = "";

I've also used a combination of EQUALS and the default STARTS_WITH to  
keep the numbers of routes a bit more manageable.


Take care,
John



RE: uriPattern exactness

2008-10-17 Thread Cliff Binstock
John and Jérôme,

Thanks much, this is *exactly* what I need!

Cliff



> -Original Message-
> From: John D. Mitchell [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 17, 2008 7:54 AM
> To: discuss@restlet.tigris.org
> Subject: Re: uriPattern exactness
> 
> On Friday 2008.10.17, at 04:01 , Jerome Louvel wrote:
> [...]
> > In combination with MODE_EQUALS, you could also add a variable for
> > your
> > extensions like: "/foos/{foo}/bar.{ext}". That could reduce the
> > number of
> > alternative routes you would have to attach.
> 
> Yes and no.  I use that trick but I still have to also have e.g.:
> /foos/{foo}/bar
> as well since the dot shouldn't be there if there's no extension. When
> I last looked, I couldn't find any way to make things optional (so if
> it's still not possible to do that in the latest versions, I'd suggest
> looking into it -- something like /bar(.{ext})? so that it hangs
> together properly).
> 
> FWIW, I do send both to the same resource and just have the resource
> look for the optional parts. e.g.:
>  ext = (String) request.getAttributes().get("ext");
>  if (null == ext)
>  ext = "";
> 
> I've also used a combination of EQUALS and the default STARTS_WITH to
> keep the numbers of routes a bit more manageable.
> 
> Take care,
> John



RE: uriPattern exactness

2008-10-18 Thread Jerome Louvel

Hi John,

We have an RFE to improve our support for URI Template. I've added a comment
in it to attempt to cover your use case better:

"Update the URI template support"
http://restlet.tigris.org/issues/show_bug.cgi?id=476

This would result in this pattern: 
"/foos/{foo}/bar{-prefix|.|ext}"

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

-Message d'origine-
De : John D. Mitchell [mailto:[EMAIL PROTECTED] 
Envoye : vendredi 17 octobre 2008 16:54
A : discuss@restlet.tigris.org
Objet : Re: uriPattern exactness

On Friday 2008.10.17, at 04:01 , Jerome Louvel wrote:
[...]
> In combination with MODE_EQUALS, you could also add a variable for  
> your
> extensions like: "/foos/{foo}/bar.{ext}". That could reduce the  
> number of
> alternative routes you would have to attach.

Yes and no.  I use that trick but I still have to also have e.g.:
/foos/{foo}/bar
as well since the dot shouldn't be there if there's no extension. When  
I last looked, I couldn't find any way to make things optional (so if  
it's still not possible to do that in the latest versions, I'd suggest  
looking into it -- something like /bar(.{ext})? so that it hangs  
together properly).

FWIW, I do send both to the same resource and just have the resource  
look for the optional parts. e.g.:
 ext = (String) request.getAttributes().get("ext");
 if (null == ext)
 ext = "";

I've also used a combination of EQUALS and the default STARTS_WITH to  
keep the numbers of routes a bit more manageable.

Take care,
John



RE: uriPattern exactness

2008-10-20 Thread Cliff Binstock
Jérôme,

I thought of another reason why it would be *really nice* to know the
matching URI pattern:  I would like to be able to dynamically determine how
to handle a resource request from a configuration.  To simplify my actual
use case, suppose for example that I implemented a default resource, and the
default resource could look at, say, an external XML configuration file to
determine which class to really call (dynamically).  This external
configuration might look like:


   /foo/{foos}/bar
   com.coyotereporting.foo.Bar


Right now, I can see how to use the above to dynamically define *resources*
once on startup, but not how to "abstract" this one level to have the
default resource call different handlers on the fly.

So, if I can add to the long term request list:
   1) Get back the original URI (e.g., /foo/{foos}/bar)
   2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).

Note that #1 above (original URI Pattern), would enable a very flexible
default handler.

Cliff Binstock
Coyote Reporting



> -Original Message-
> From: Jerome Louvel [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 17, 2008 4:02 AM
> To: discuss@restlet.tigris.org
> Subject: RE: uriPattern exactness
> 
> 
> Hi Cliff,
> 
> In combination with MODE_EQUALS, you could also add a variable for your
> extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
> alternative routes you would have to attach.
> 
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
> 
> 
> -Message d'origine-
> De : Cliff Binstock [mailto:[EMAIL PROTECTED]
> Envoye : vendredi 17 octobre 2008 01:28
> A : discuss@restlet.tigris.org
> Objet : RE: uriPattern exactness
> 
> Aron,
> 
> Thanks, I didn't realize this was here.  This would potentially work, and
> I
> may end up using it.
> 
> Frankly, I want to be able to "have my cake and eat it too".  An exact
> match
> using this construct would work, but would also force me to itemize every
> possible variation of a path via router.attach().  I was hoping to do some
> "fuzzy" enforcement in a base "Resource" class.
> 
> Cliff Binstock
> Coyote Reporting
> 
> 
> 
> 
> > -Original Message-
> > From: Aron Roberts [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, October 16, 2008 11:37 AM
> > To: discuss@restlet.tigris.org
> > Subject: RE: uriPattern exactness
> >
> > In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
> > Binstock wrote:
> >
> > >P.S.  What is worse (maybe very confusing) is that this might match
> too:
> > >/foo/myFoo/bar/baz/bletch/fred.xml
> > >Again, I would like to forcefully ensure that this doesn't end up
> > matching.
> >
> >From memory - by default, the mode for matching incoming URIs to
> > your URI templates is 'starts with' rather than 'equals'.
> >
> > As Jerome wrote back in February 2008:
> > >In some cases, you might want to change this default mode, and this
> > >is easy to do via the "defaultMatchingMode" property on Router, or by
> > >modifying the "matchingMode" property of the template associated with
> > >the route created by the Router.attach() methods. For the modes, you
> can
> > >use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
> >
> >Here's one example of the latter:
> >
> > router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
> >
> >Hope this is germane to your needs.
> >
> > Aron



Re: uriPattern exactness

2008-10-20 Thread Erik Beeson
In what scenario (other than maybe development) do your routes change at
runtime?
--Erik


On Mon, Oct 20, 2008 at 2:44 PM, Cliff Binstock <
[EMAIL PROTECTED]> wrote:

> Jérôme,
>
> I thought of another reason why it would be *really nice* to know the
> matching URI pattern:  I would like to be able to dynamically determine how
> to handle a resource request from a configuration.  To simplify my actual
> use case, suppose for example that I implemented a default resource, and
> the
> default resource could look at, say, an external XML configuration file to
> determine which class to really call (dynamically).  This external
> configuration might look like:
>
> 
>   /foo/{foos}/bar
>   com.coyotereporting.foo.Bar
> 
>
> Right now, I can see how to use the above to dynamically define *resources*
> once on startup, but not how to "abstract" this one level to have the
> default resource call different handlers on the fly.
>
> So, if I can add to the long term request list:
>   1) Get back the original URI (e.g., /foo/{foos}/bar)
>   2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).
>
> Note that #1 above (original URI Pattern), would enable a very flexible
> default handler.
>
> Cliff Binstock
> Coyote Reporting
>
>
>
> > -Original Message-
> > From: Jerome Louvel [mailto:[EMAIL PROTECTED]
> > Sent: Friday, October 17, 2008 4:02 AM
> > To: discuss@restlet.tigris.org
> > Subject: RE: uriPattern exactness
> >
> >
> > Hi Cliff,
> >
> > In combination with MODE_EQUALS, you could also add a variable for your
> > extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
> > alternative routes you would have to attach.
> >
> > Best regards,
> > Jerome Louvel
> > --
> > Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> > Noelios Technologies ~ Co-founder ~ http://www.noelios.com
> >
> >
> > -Message d'origine-
> > De : Cliff Binstock [mailto:[EMAIL PROTECTED]
> > Envoye : vendredi 17 octobre 2008 01:28
> > A : discuss@restlet.tigris.org
> > Objet : RE: uriPattern exactness
> >
> > Aron,
> >
> > Thanks, I didn't realize this was here.  This would potentially work, and
> > I
> > may end up using it.
> >
> > Frankly, I want to be able to "have my cake and eat it too".  An exact
> > match
> > using this construct would work, but would also force me to itemize every
> > possible variation of a path via router.attach().  I was hoping to do
> some
> > "fuzzy" enforcement in a base "Resource" class.
> >
> > Cliff Binstock
> > Coyote Reporting
> >
> >
> >
> >
> > > -Original Message-
> > > From: Aron Roberts [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, October 16, 2008 11:37 AM
> > > To: discuss@restlet.tigris.org
> > > Subject: RE: uriPattern exactness
> > >
> > > In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
> > > Binstock wrote:
> > >
> > > >P.S.  What is worse (maybe very confusing) is that this might match
> > too:
> > > >/foo/myFoo/bar/baz/bletch/fred.xml
> > > >Again, I would like to forcefully ensure that this doesn't end up
> > > matching.
> > >
> > >From memory - by default, the mode for matching incoming URIs to
> > > your URI templates is 'starts with' rather than 'equals'.
> > >
> > > As Jerome wrote back in February 2008:
> > > >In some cases, you might want to change this default mode, and this
> > > >is easy to do via the "defaultMatchingMode" property on Router, or by
> > > >modifying the "matchingMode" property of the template associated with
> > > >the route created by the Router.attach() methods. For the modes, you
> > can
> > > >use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
> > >
> > >Here's one example of the latter:
> > >
> > > router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
> > >
> > >Hope this is germane to your needs.
> > >
> > > Aron
>
>


Re: uriPattern exactness

2008-10-21 Thread Thierry Boileau

Hi Cliff,

as a workaround, you can derive the Router class and override the 
"getNext" method. It will give you access to the route, and then the 
matched pattern:


   Router router = new Router(getContext()) {
   @Override
   public Restlet getNext(Request request, Response response) {
   Restlet result = super.getNext(request, response);
   if (result instanceof Route) {
   Route route = (Route) result;
   request.getAttributes().put("pattern", 
route.getTemplate().getPattern());

   }
   return result;
   }
   };

By doing so, you're able to update the request and include the pattern 
as an attribute.



Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/>
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
<http://www.noelios.com/>



Jérôme,

I thought of another reason why it would be *really nice* to know the
matching URI pattern:  I would like to be able to dynamically determine how
to handle a resource request from a configuration.  To simplify my actual
use case, suppose for example that I implemented a default resource, and the
default resource could look at, say, an external XML configuration file to
determine which class to really call (dynamically).  This external
configuration might look like:


   /foo/{foos}/bar
   com.coyotereporting.foo.Bar


Right now, I can see how to use the above to dynamically define *resources*
once on startup, but not how to "abstract" this one level to have the
default resource call different handlers on the fly.

So, if I can add to the long term request list:
   1) Get back the original URI (e.g., /foo/{foos}/bar)
   2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).

Note that #1 above (original URI Pattern), would enable a very flexible
default handler.

Cliff Binstock
Coyote Reporting



  

-Original Message-
From: Jerome Louvel [mailto:[EMAIL PROTECTED]
Sent: Friday, October 17, 2008 4:02 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness


Hi Cliff,

In combination with MODE_EQUALS, you could also add a variable for your
extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
alternative routes you would have to attach.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


-Message d'origine-
De : Cliff Binstock [mailto:[EMAIL PROTECTED]
Envoye : vendredi 17 octobre 2008 01:28
A : discuss@restlet.tigris.org
Objet : RE: uriPattern exactness

Aron,

Thanks, I didn't realize this was here.  This would potentially work, and
I
may end up using it.

Frankly, I want to be able to "have my cake and eat it too".  An exact
match
using this construct would work, but would also force me to itemize every
possible variation of a path via router.attach().  I was hoping to do some
"fuzzy" enforcement in a base "Resource" class.

Cliff Binstock
Coyote Reporting






-Original Message-
From: Aron Roberts [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2008 11:37 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness

In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
Binstock wrote:

  

P.S.  What is worse (maybe very confusing) is that this might match


too:


/foo/myFoo/bar/baz/bletch/fred.xml
Again, I would like to forcefully ensure that this doesn't end up


matching.

   From memory - by default, the mode for matching incoming URIs to
your URI templates is 'starts with' rather than 'equals'.

As Jerome wrote back in February 2008:
  

In some cases, you might want to change this default mode, and this
is easy to do via the "defaultMatchingMode" property on Router, or by
modifying the "matchingMode" property of the template associated with
the route created by the Router.attach() methods. For the modes, you


can


use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."


   Here's one example of the latter:

router.getTemplate().setMatchingMode(Template.MODE_EQUALS)

   Hope this is germane to your needs.

Aron


RE: uriPattern exactness

2008-10-21 Thread Cliff Binstock
Erik,

 

Great question.  It’s not so much that the routes change at runtime
(although I was contemplating user-configurable routing—wouldn’t that be
intriguing!), but I want the behavior to change at runtime.  Ultimately, we
will allow users to define their own behaviors (you don’t like the XML we
return for one of the routes? Specify your own).

 

The immediate (and most annoying) problem is that the web server Resources
are extremely light weight, and we have a whole bunch of  “one-line”
Resource classes to call the corresponding behaviors, which is ridiculous,
not to mention tedious, error prone, and a maintenance annoyance.  Even
today, all of the behavior-switching is taken care of by a single abstract
class.

 

Cliff Binstock
Coyote Reporting

  _  

From: Erik Beeson [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 20, 2008 3:23 PM
To: discuss@restlet.tigris.org
Subject: Re: uriPattern exactness

 

In what scenario (other than maybe development) do your routes change at
runtime?

 

--Erik

 

On Mon, Oct 20, 2008 at 2:44 PM, Cliff Binstock
<[EMAIL PROTECTED]> wrote:

Jérôme,

I thought of another reason why it would be *really nice* to know the
matching URI pattern:  I would like to be able to dynamically determine how
to handle a resource request from a configuration.  To simplify my actual
use case, suppose for example that I implemented a default resource, and the
default resource could look at, say, an external XML configuration file to
determine which class to really call (dynamically).  This external
configuration might look like:


  /foo/{foos}/bar
  com.coyotereporting.foo.Bar


Right now, I can see how to use the above to dynamically define *resources*
once on startup, but not how to "abstract" this one level to have the
default resource call different handlers on the fly.

So, if I can add to the long term request list:
  1) Get back the original URI (e.g., /foo/{foos}/bar)
  2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).

Note that #1 above (original URI Pattern), would enable a very flexible
default handler.


Cliff Binstock
Coyote Reporting



> -Original Message-

> From: Jerome Louvel [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 17, 2008 4:02 AM
> To: discuss@restlet.tigris.org
> Subject: RE: uriPattern exactness
>
>
> Hi Cliff,
>
> In combination with MODE_EQUALS, you could also add a variable for your
> extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
> alternative routes you would have to attach.
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
> -Message d'origine-
> De : Cliff Binstock [mailto:[EMAIL PROTECTED]
> Envoye : vendredi 17 octobre 2008 01:28
> A : discuss@restlet.tigris.org
> Objet : RE: uriPattern exactness
>
> Aron,
>
> Thanks, I didn't realize this was here.  This would potentially work, and
> I
> may end up using it.
>
> Frankly, I want to be able to "have my cake and eat it too".  An exact
> match
> using this construct would work, but would also force me to itemize every
> possible variation of a path via router.attach().  I was hoping to do some
> "fuzzy" enforcement in a base "Resource" class.
>
> Cliff Binstock
> Coyote Reporting
>
>
>
>
> > -Original Message-
> > From: Aron Roberts [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, October 16, 2008 11:37 AM
> > To: discuss@restlet.tigris.org
> > Subject: RE: uriPattern exactness
> >
> > In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
> > Binstock wrote:
> >
> > >P.S.  What is worse (maybe very confusing) is that this might match
> too:
> > >/foo/myFoo/bar/baz/bletch/fred.xml
> > >Again, I would like to forcefully ensure that this doesn't end up
> > matching.
> >
> >From memory - by default, the mode for matching incoming URIs to
> > your URI templates is 'starts with' rather than 'equals'.
> >
> > As Jerome wrote back in February 2008:
> > >In some cases, you might want to change this default mode, and this
> > >is easy to do via the "defaultMatchingMode" property on Router, or by
> > >modifying the "matchingMode" property of the template associated with
> > >the route created by the Router.attach() methods. For the modes, you
> can
> > >use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
> >
> >Here's one example of the latter:
> >
> > router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
> >
> >Hope this is germane to your needs.
> >
> > Aron

 



RE: uriPattern exactness

2008-10-21 Thread Cliff Binstock
Thierry,

 

This works great, thank you very, very much!  I now have fully dynamic
behaviors.

Can I suggest that you make this a “standard” attribute?  Regardless, this
works for me.

 

Cliff Binstock
Coyote Reporting

  _  

From: Thierry Boileau [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 21, 2008 12:26 AM
To: discuss@restlet.tigris.org
Subject: Re: uriPattern exactness

 

Hi Cliff,

as a workaround, you can derive the Router class and override the "getNext"
method. It will give you access to the route, and then the matched pattern:

Router router = new Router(getContext()) {
@Override
public Restlet getNext(Request request, Response response) {
Restlet result = super.getNext(request, response);
if (result instanceof Route) {
Route route = (Route) result;
request.getAttributes().put("pattern",
route.getTemplate().getPattern());
}
return result;
}
};

By doing so, you're able to update the request and include the pattern as an
attribute.


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org <http://www.restlet.org/> 
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
<http://www.noelios.com/> 




Jérôme,
 
I thought of another reason why it would be *really nice* to know the
matching URI pattern:  I would like to be able to dynamically determine how
to handle a resource request from a configuration.  To simplify my actual
use case, suppose for example that I implemented a default resource, and the
default resource could look at, say, an external XML configuration file to
determine which class to really call (dynamically).  This external
configuration might look like:
 

   /foo/{foos}/bar
   com.coyotereporting.foo.Bar

 
Right now, I can see how to use the above to dynamically define *resources*
once on startup, but not how to "abstract" this one level to have the
default resource call different handlers on the fly.
 
So, if I can add to the long term request list:
   1) Get back the original URI (e.g., /foo/{foos}/bar)
   2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).
 
Note that #1 above (original URI Pattern), would enable a very flexible
default handler.
 
Cliff Binstock
Coyote Reporting
 
 
 
  

-Original Message-
From: Jerome Louvel [mailto:[EMAIL PROTECTED]
Sent: Friday, October 17, 2008 4:02 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness
 
 
Hi Cliff,
 
In combination with MODE_EQUALS, you could also add a variable for your
extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
alternative routes you would have to attach.
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
 
 
-Message d'origine-
De : Cliff Binstock [mailto:[EMAIL PROTECTED]
Envoye : vendredi 17 octobre 2008 01:28
A : discuss@restlet.tigris.org
Objet : RE: uriPattern exactness
 
Aron,
 
Thanks, I didn't realize this was here.  This would potentially work, and
I
may end up using it.
 
Frankly, I want to be able to "have my cake and eat it too".  An exact
match
using this construct would work, but would also force me to itemize every
possible variation of a path via router.attach().  I was hoping to do some
"fuzzy" enforcement in a base "Resource" class.
 
Cliff Binstock
Coyote Reporting
 
 
 
 


-Original Message-
From: Aron Roberts [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 16, 2008 11:37 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness
 
In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
Binstock wrote:
 
  

P.S.  What is worse (maybe very confusing) is that this might match


too:


/foo/myFoo/bar/baz/bletch/fred.xml
Again, I would like to forcefully ensure that this doesn't end up


matching.
 
   From memory - by default, the mode for matching incoming URIs to
your URI templates is 'starts with' rather than 'equals'.
 
As Jerome wrote back in February 2008:
  

In some cases, you might want to change this default mode, and this
is easy to do via the "defaultMatchingMode" property on Router, or by
modifying the "matchingMode" property of the template associated with
the route created by the Router.attach() methods. For the modes, you


can


use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."


   Here's one example of the latter:
 
router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
 
   Hope this is germane to your needs.
 
Aron



RE: uriPattern exactness

2008-10-22 Thread Jerome Louvel
Hi Cliff,
 
Aren't you trying to develop a specialized Router? Router can be dynamically
modified by adding/removing routes at runtime. If your routers (pattern +
target resource) are externalized in an XML file, you could regularly look
for changes and either:

*   

update the existing router to match the changes
*   

create a new router, configure it and plug it as a replacement of
the previous one

In the first case, you could simply write a Router subclass that would be
very reusable.
 
Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~  <http://www.restlet.org/>
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  <http://www.noelios.com/>
http://www.noelios.com

  _  

De : Erik Beeson [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 21 octobre 2008 00:23
À : discuss@restlet.tigris.org
Objet : Re: uriPattern exactness


In what scenario (other than maybe development) do your routes change at
runtime? 

--Erik


On Mon, Oct 20, 2008 at 2:44 PM, Cliff Binstock
<[EMAIL PROTECTED]> wrote:


Jérôme,

I thought of another reason why it would be *really nice* to know the
matching URI pattern:  I would like to be able to dynamically determine how
to handle a resource request from a configuration.  To simplify my actual
use case, suppose for example that I implemented a default resource, and the
default resource could look at, say, an external XML configuration file to
determine which class to really call (dynamically).  This external
configuration might look like:


  /foo/{foos}/bar
  com.coyotereporting.foo.Bar


Right now, I can see how to use the above to dynamically define *resources*
once on startup, but not how to "abstract" this one level to have the
default resource call different handlers on the fly.

So, if I can add to the long term request list:
  1) Get back the original URI (e.g., /foo/{foos}/bar)
  2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).

Note that #1 above (original URI Pattern), would enable a very flexible
default handler.


Cliff Binstock
Coyote Reporting



> -Original Message-

> From: Jerome Louvel [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 17, 2008 4:02 AM
> To: discuss@restlet.tigris.org
> Subject: RE: uriPattern exactness
>
>
> Hi Cliff,
>
> In combination with MODE_EQUALS, you could also add a variable for your
> extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
> alternative routes you would have to attach.
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
> -Message d'origine-
> De : Cliff Binstock [mailto:[EMAIL PROTECTED]
> Envoye : vendredi 17 octobre 2008 01:28
> A : discuss@restlet.tigris.org
> Objet : RE: uriPattern exactness
>
> Aron,
>
> Thanks, I didn't realize this was here.  This would potentially work, and
> I
> may end up using it.
>
> Frankly, I want to be able to "have my cake and eat it too".  An exact
> match
> using this construct would work, but would also force me to itemize every
> possible variation of a path via router.attach().  I was hoping to do some
> "fuzzy" enforcement in a base "Resource" class.
>
> Cliff Binstock
> Coyote Reporting
>
>
>
>
> > -----Original Message-
> > From: Aron Roberts [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, October 16, 2008 11:37 AM
> > To: discuss@restlet.tigris.org
> > Subject: RE: uriPattern exactness
> >
> > In the message "Re: uriPattern exactness", dated 2008-10-16, Cliff
> > Binstock wrote:
> >
> > >P.S.  What is worse (maybe very confusing) is that this might match
> too:
> > >/foo/myFoo/bar/baz/bletch/fred.xml
> > >Again, I would like to forcefully ensure that this doesn't end up
> > matching.
> >
> >From memory - by default, the mode for matching incoming URIs to
> > your URI templates is 'starts with' rather than 'equals'.
> >
> > As Jerome wrote back in February 2008:
> > >In some cases, you might want to change this default mode, and this
> > >is easy to do via the "defaultMatchingMode" property on Router, or by
> > >modifying the "matchingMode" property of the template associated with
> > >the route created by the Router.attach() methods. For the modes, you
> can
> > >use the Template.MODE_EQUALS or Template.MODE_STARTS_WITH constants."
> >
> >Here's one example of the latter:
> >
> > router.getTemplate().setMatchingMode(Template.MODE_EQUALS)
> >
> >Hope this is germane to your needs.
> >
> > Aron






RE: uriPattern exactness

2008-10-22 Thread Cliff Binstock
Jérôme,

 

I suppose I could specialize the Router—it hadn’t occurred to me.  For
better or worse it seemed logical to me to use the standard router, and have
a Resource dynamically binding the behaviors.  The key is that the behaviors
come in a handful of flavors, so I have a behavior interface and factory.
You are right that I could move the abstraction up a level, I suppose.  Note
that some URIs are bound in a fixed “standard” way to the Router.

 

The other advantage to the current approach is that there is just a very
lightweight “controller” (a Resource), between the standard Router, and my
standard behaviors.  You can completely change the way the router works, or
I can completely change the way the behaviors work, and maintenance on the
controller is minimal.  If I get to dynamically binding the URIs
(user-specified routes), I will keep in mind if subclassing the Router is
better or not.  Frankly, the current controller would work just fine, the
only “issue” is attaching/detaching the router on the fly, which on the
surface doesn’t really seem problematic.

 

Cliff Binstock
Coyote Reporting

  _  

From: Jerome Louvel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 22, 2008 12:47 AM
To: discuss@restlet.tigris.org
Subject: RE: uriPattern exactness

 

Hi Cliff,

 

Aren't you trying to develop a specialized Router? Router can be dynamically
modified by adding/removing routes at runtime. If your routers (pattern +
target resource) are externalized in an XML file, you could regularly look
for changes and either:

*   update the existing router to match the changes
*   create a new router, configure it and plug it as a replacement of
the previous one

In the first case, you could simply write a Router subclass that would be
very reusable.

 

Best regards,
Jérôme Louvel
--
Restlet ~ Founder and Lead developer ~  <http://www.restlet.org/>
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  <http://www.noelios.com/>
http://www.noelios.com

 

  _  

De : Erik Beeson [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 21 octobre 2008 00:23
À : discuss@restlet.tigris.org
Objet : Re: uriPattern exactness

In what scenario (other than maybe development) do your routes change at
runtime? 

 

--Erik

 

On Mon, Oct 20, 2008 at 2:44 PM, Cliff Binstock
<[EMAIL PROTECTED]> wrote:

Jérôme,

I thought of another reason why it would be *really nice* to know the
matching URI pattern:  I would like to be able to dynamically determine how
to handle a resource request from a configuration.  To simplify my actual
use case, suppose for example that I implemented a default resource, and the
default resource could look at, say, an external XML configuration file to
determine which class to really call (dynamically).  This external
configuration might look like:


  /foo/{foos}/bar
  com.coyotereporting.foo.Bar


Right now, I can see how to use the above to dynamically define *resources*
once on startup, but not how to "abstract" this one level to have the
default resource call different handlers on the fly.

So, if I can add to the long term request list:
  1) Get back the original URI (e.g., /foo/{foos}/bar)
  2) Get back the "as-matched" URI (e.g., /foo/myFoo/bar).

Note that #1 above (original URI Pattern), would enable a very flexible
default handler.


Cliff Binstock
Coyote Reporting



> -Original Message-

> From: Jerome Louvel [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 17, 2008 4:02 AM
> To: discuss@restlet.tigris.org
> Subject: RE: uriPattern exactness
>
>
> Hi Cliff,
>
> In combination with MODE_EQUALS, you could also add a variable for your
> extensions like: "/foos/{foo}/bar.{ext}". That could reduce the number of
> alternative routes you would have to attach.
>
> Best regards,
> Jerome Louvel
> --
> Restlet ~ Founder and Lead developer ~ http://www.restlet.org
> Noelios Technologies ~ Co-founder ~ http://www.noelios.com
>
>
> -Message d'origine-
> De : Cliff Binstock [mailto:[EMAIL PROTECTED]
> Envoye : vendredi 17 octobre 2008 01:28
> A : discuss@restlet.tigris.org
> Objet : RE: uriPattern exactness
>
> Aron,
>
> Thanks, I didn't realize this was here.  This would potentially work, and
> I
> may end up using it.
>
> Frankly, I want to be able to "have my cake and eat it too".  An exact
> match
> using this construct would work, but would also force me to itemize every
> possible variation of a path via router.attach().  I was hoping to do some
> "fuzzy" enforcement in a base "Resource" class.
>
> Cliff Binstock
> Coyote Reporting
>
>
>
>
> > -----Original Message-
> > From: Aron Roberts [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, October 16, 2008 11:37 AM
> > To: discuss@restlet.tigris.org
> > Subject: RE