1

I am using Restlet 2.3 with the Jetty ext. How do you set the temp directory that the jar is unpacked to?

Using just jetty in another project it can be achieved using:

private void resetTempDirectory(WebAppContext context, String currentDir) {
        File tmpDir = new File(currentDir, ".tmp");
        tmpDir.deleteOnExit();
        tmpDir.mkdir();
        context.setTempDirectory(tmpDir);
    }
tarka
  • 5,289
  • 10
  • 51
  • 75

2 Answers2

0

You can find here all the supported parameters for the Jetty server connector: http://restlet.com/technical-resources/restlet-framework/javadocs/2.3/jse/ext/. It appears that there is no parameter for the temp directory.

For information here is the way to configure a server connector using context: http://restlet.com/technical-resources/restlet-framework/guide/2.3/core/base/connectors.

I have a look at the Jetty extension. Restlet leverages the class Server and JettyServerCall to respectively create the Jetty server and handle requests. I can't see any use of a class WebAppContext.

That said, I'm not sure Jetty / Restlet unpack things ;-) Could you give me hints about the way you configure / use Jetty in your other project? Thanks!

Hope it helps you, Thierry

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • Yep, the other project is in fact packaged as a `war` with embedded jetty. The `war` is added to jetty using `WebAppContext webapp = new WebAppContext(warFile, "/");`. It is possible that it only gets unpacked because its a `war`. – tarka Jun 04 '15 at 12:25
  • Yes, in fact, Restlet doesn't use war file for its Jetty extension. The Jetty server is embedded within the Restlet "application". To embed a Restlet application, you can use the servlet extension and such configuration can be done at the container level (jetty for example). – Thierry Templier Jun 04 '15 at 12:27
0

if you want to unpack a file to a temporary directory, you can simply use the "java.io.tmpdir" system property.

When you run a Restlet application using the Jetty extension, you are not running the Jetty's servlet container, but the part of Jetty that handle sockets. Just consider you are running a program inside a JVM.

user229044
  • 232,980
  • 40
  • 330
  • 338
Thierry Boileau
  • 866
  • 5
  • 8