On Fri, 2008-11-07 at 10:06 +0100, Stephan Koops wrote:
> Hi Bruno,
> 
> I planned a possibility of JAX-RS for this, but I had no time to 
> implement it.
> I will put it higher in my priority list.
> 

Cool.

I have just tried if I can do everything I need by some customization
(via subclassing). It works and it is a clean solution.

The only change I need in JaxRsRestlet is the ability to provide a
custom ExceptionHandler. I can then override the methods like
rootResourceNotFound() and set a flag in a response attribute.

I've attached a patch for this small change. I've added a method which
can be overridden using subclassing, just to avoid adding a public
method, but I'm fine with either approach. Do you think this is an
acceptable change?

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought                            http://www.daisycms.org/
[EMAIL PROTECTED]              http://www.kauriproject.org/
Index: modules/org.restlet.ext.jaxrs_1.0/src/org/restlet/ext/jaxrs/JaxRsRestlet.java
===================================================================
--- modules/org.restlet.ext.jaxrs_1.0/src/org/restlet/ext/jaxrs/JaxRsRestlet.java	(revision 3945)
+++ modules/org.restlet.ext.jaxrs_1.0/src/org/restlet/ext/jaxrs/JaxRsRestlet.java	(working copy)
@@ -198,7 +198,7 @@
         super(context);
         final ExtensionBackwardMapping extensionBackwardMapping = new ExtensionBackwardMapping(
                 metadataService);
-        this.excHandler = new ExceptionHandler(getLogger());
+        this.excHandler = getExceptionHandler();
         this.providers = new JaxRsProviders(this.objectFactory, this.tlContext,
                 extensionBackwardMapping, getLogger());
         this.resourceClasses = new ResourceClasses(this.tlContext,
@@ -210,6 +210,13 @@
             this.setRoleChecker(RoleChecker.REJECT_WITH_ERROR);
     }
 
+    /**
+     * Allows to provide a custom ExceptionHandler.
+     */
+    protected ExceptionHandler getExceptionHandler() {
+        return new ExceptionHandler(getLogger());
+    }
+
     private void loadDefaultProviders() {
         this.addSingleton(new BufferedReaderProvider(), true);
         this.addSingleton(new ByteArrayProvider(), true);

Reply via email to