Thierry - I very much appreciate your reply, but TestApplication does not take into account a custom Representation that may fail. I've changed the TestApplication class to TestApplicationJim to better explain what I am trying to do. The RepresentationFails class demonstrates that the methods in MyStatusService are never invoked.
As succinctly as I can state it: If a write operation in a custom representation fails, no method in the customized StatusService is invoked. FYI - The Restlet code is excellent, and I have improved my coding style after learning from yours. Code is below, and also attached package test; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; import org.restlet.Application; import org.restlet.Component; import org.restlet.Request; import org.restlet.Response; import org.restlet.data.MediaType; import org.restlet.data.Protocol; import org.restlet.data.Status; import org.restlet.representation.OutputRepresentation; import org.restlet.representation.Representation; import org.restlet.resource.ClientResource; import org.restlet.resource.ResourceException; import org.restlet.routing.Router; public class TestApplicationJim extends Application { /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { Component c = new Component(); c.getServers().add(Protocol.HTTP, 8182); c.getDefaultHost().attach(new TestApplicationJim()); c.start(); System.out.println("TestApplicationJim started"); ClientResource cr = new ClientResource("http://localhost:8182/test1"); cr.setRetryOnError(false); try { cr.get(); } catch (Exception e) { cr.getResponseEntity().write(System.out); } cr = new ClientResource("http://localhost:8182/test2"); cr.setRetryOnError(false); try { cr.get(); } catch (Exception e) { cr.getResponseEntity().write(System.out); } c.stop(); } public void handle(Request request, Response response) { System.out.println("TestApplicationJim handle"); class RepresentationFails extends OutputRepresentation { public RepresentationFails() { super(MediaType.APPLICATION_ZIP, -1); } @Override public ReadableByteChannel getChannel() throws IOException { throw new ResourceException(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } @Override public Reader getReader() throws IOException { throw new ResourceException(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } @Override public InputStream getStream() throws IOException { throw new ResourceException(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } @Override public void write(Writer writer) throws IOException { throw new ResourceException(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } @Override public void write(WritableByteChannel writableChannel) throws IOException { throw new ResourceException(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } @Override public void write(OutputStream outputStream) throws IOException { throw new ResourceException(Status.CLIENT_ERROR_NOT_ACCEPTABLE); } } response.setEntity(new RepresentationFails()); } public TestApplicationJim() { super(); setStatusService(new MyStatusService()); } public org.restlet.Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/test1", TestExceptionServerResource.class); router.attach("/test2", TestResourceExceptionServerResource.class); return router; }; } ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3010457
TestApplicationJim.java
Description: Binary data