Re: Best way to serve CSS and Javascript from a WAR?

2007-06-18 Thread Dustin N. Jenkins

Jerome,

   Excellent!  Fantastic!  I will try it, thank you so much.

Dustin


Jerome Louvel wrote:

Hi Dustin,

The WAR client is automatically installed when you use the ServerServlet
adapter. In Restlet 1.1, this will work with the standalone mode too, so
Application portability will be intact.

So, you can already simplify your code like this:

public Representation getRepresentation(final Variant variant)
{
return getContext().getDispatcher()
.get(war:///css/{cssfile}).getEntity();
}

Note that going through the context's dispatcher lets you transparently
reuse request's attributes via URI templates :)

Let me know if this works for you.

Best regards,
Jerome  

  

-Message d'origine-
De : Dustin N. Jenkins [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 12 juin 2007 16:19

À : Discussion about Restlet
Objet : Best way to serve CSS and Javascript from a WAR?

I'm deploying my Restlet application into a WAR in Tomcat, and 
everything seems to be working just fine.  Normally, it'd be nicer to 
simply let Tomcat handle the CSS and Javascript files, but I 
want to map 
everything (/*) to the ServerServlet so I can keep the 
initial part of 
the resource ref (i.e. if I were to map /abc/* and /xyz/* I 
wouldn't be 
able to match those because it becomes the base ref and gets stripped 
off). 

Here's what I'm doing now for the CSSResource that the 
/css/{cssfile} is 
routed to:

public Representation getRepresentation(final Variant variant)
{
final ServletWarClient warClient =
new ServletWarClient(getContext(),
 ((ServletContextAdapter) 
getContext()).getServletContext());


return warClient.get(war:///css/
 + 
getRequestAttribute(cssfile)).getEntity();

}

Which isn't elegant at all as it's tuned specifically to 
being deployed 
as a WAR, and can no longer be run as a standalone, not to 
mention all 
the implementation specific stuff...
Is there a better way?  I know normal static stuff is served via the 
Directory resource, but it doesn't apply here because everything is 
inside the WAR. 


Any suggestions?
Thank you for the fantastic framework!

Dustin



--


Dustin N. Jenkins | Tel/Tél: 250.363.3101 | [EMAIL PROTECTED]

facsimile/télécopieur: (250) 363-0045

National Research Council Canada | 5071 West Saanich Rd, Victoria BC. 
V9E 2E7


Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria 
(C.-B) V9E 2E7


Government of Canada | Gouvernement du Canada


Re: Conditional GETs?

2007-06-18 Thread Avi Flax

Jerome, I'm eagerly awaiting this snapshot! No pressure, but are we looking
at a matter of days here, or is it more like weeks?
Thanks!
Avi

On 6/16/07, Jerome Louvel [EMAIL PROTECTED] wrote:



Hi all,

This RFE is now fixed in SVN trunk and will be testable in the upcoming
1.1
snapshot. Great optimization, thanks Stian for the idea.

Best regards,
Jerome


RE: Conditional GETs?

2007-06-18 Thread Jerome Louvel

Hi Avi,

A matter of days! Version 1.0.2 is pending too. 

Best regards,
Jerome  

 -Message d'origine-
 De : Avi Flax [mailto:[EMAIL PROTECTED] 
 Envoyé : lundi 18 juin 2007 20:05
 À : discuss@restlet.tigris.org
 Objet : Re: Conditional GETs?
 
 Jerome, I'm eagerly awaiting this snapshot! No pressure, but 
 are we looking at a matter of days here, or is it more like weeks?
 
 Thanks!
 Avi
 
 
 On 6/16/07, Jerome Louvel [EMAIL PROTECTED] wrote:
 
 
   Hi all,
   
   This RFE is now fixed in SVN trunk and will be testable 
 in the upcoming 1.1
   snapshot. Great optimization, thanks Stian for the idea.
   
   Best regards,
   Jerome