Hello Magnus,
at this time, you can either provide the context to the client:
Client client = new Client(component.getContext().createChildContext(),
Protocol.FILE);
client.getContext().getParameters().add("timeToLive", "10");
component.getClients().add(client);
or let the "ClientList#add(Protocol)" create the the context:
component.getClients().add(Protocol.FILE);
component.getClients().get(0).getContext().getParameters().add("timeToLive",
"10");
That made us thinking about another way to do that. As the
"component#attach" method, we can let the "add(Client)" method handle
the context. We've just updated the svn repository.
Thus, here is another way to achieve what you want:
Client client = new Client(Protocol.FILE);
component.getClients().add(client);
client.getContext().getParameters().add("timeToLive", "10");
Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
Im having some trouble configuring the client which supposedly serves
the files from a Directory restlet. Im running this as a standalone java
application, not as a servlet.
... snip snip ...
Component component = new Component();
VelocityRepresentation.TEMPLATEPATH = "velocitytemplates/";
component.getServers().add(Protocol.HTTP, 9090);
Client client = new Client(Protocol.FILE);
client.getContext().getParameters().add("timeToLive", "10");
component.getClients().add(client);
component.getDefaultHost().attach(new MyApplication());
component.start();
... snip snip ...
As far as I can tell, client.getContext().getParameters() is null and my
application therefore throws a nullpointer exception.
Plain and simple, what Im trying to accomplish is to (globally) set the
time to live for my static file serving to 0... should I approach this
differently?