camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r736251 - in /camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources: CamelContextResource.java EndpointResource.java ResourceSupport.java ViewableResource.java
Date Wed, 21 Jan 2009 07:31:35 GMT
Author: jstrachan
Date: Tue Jan 20 23:31:34 2009
New Revision: 736251

URL: http://svn.apache.org/viewvc?rev=736251&view=rev
Log:
almost there in the DRY approach to coding both a human and computer REST interface for  CAMEL-888;
still have some crud left around util these issues are resolved: https://jsr311.dev.java.net/issues/show_bug.cgi?id=46
https://jsr311.dev.java.net/issues/show_bug.cgi?id=65 (its the same issue really - needing
to be able to prioritise HTML over other formats irrespective of the use of regex)

Added:
    camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ResourceSupport.java
  (contents, props changed)
      - copied, changed from r735938, camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ViewableResource.java
Removed:
    camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ViewableResource.java
Modified:
    camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
    camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java

Modified: camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java?rev=736251&r1=736250&r2=736251&view=diff
==============================================================================
--- camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
(original)
+++ camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
Tue Jan 20 23:31:34 2009
@@ -45,7 +45,7 @@
  */
 @Path("/")
 @Singleton
-public class CamelContextResource extends ViewableResource {
+public class CamelContextResource extends ResourceSupport {
 
     private final CamelContext camelContext;
 
@@ -61,15 +61,16 @@
         return camelContext.getName();
     }
 
-
-
-    // HTML representations
-    //-------------------------------------------------------------------------
-
-    // Its a shame there's not an easier way to bind the explicit views...
-    //-------------------------------------------------------------------------
-
-
+    // TODO remove redunant non-DRY code ASAP
+    //
+    // The following redundant methods are here
+    // until there is a way to specify a higher priority for HTML views
+    //
+    // for more details see these issues
+    //
+    // https://jsr311.dev.java.net/issues/show_bug.cgi?id=65
+    // https://jsr311.dev.java.net/issues/show_bug.cgi?id=46
+    
     @GET
     @Path("endpoints")
     @Produces({MediaType.TEXT_HTML})
@@ -78,34 +79,15 @@
     }
 
     @GET
-    @Path("foo")
-    @Produces({MediaType.TEXT_HTML})
-    public Viewable foo() {
-        return view("foo");
-    }
-
-/*
-    @GET
-    @Path("{view}")
-    @Produces({MediaType.TEXT_HTML})
-    public Viewable genericView(@PathParam("view") String view) {
-        return view(view);
-    }
-
-*/
-
-    @GET
     @Path("routes")
     @Produces({MediaType.TEXT_HTML})
     public Viewable routesView() {
         return view("routes");
     }
 
-
     // XML / JSON representations
     //-------------------------------------------------------------------------
 
-
     @GET
     @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
     public Camel getCamel() {
@@ -129,15 +111,6 @@
         return getEndpointsDTO().getEndpoints();
     }
 
-/*
-    @GET
-    @Path("endpoints")
-    @Produces({"text/html"})
-    public List<EndpointLink> getEndpoints() {
-        return getEndpointsDTO().getEndpoints();
-    }
-*/
-
     /**
      * Looks up an individual endpoint
      */

Modified: camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java?rev=736251&r1=736250&r2=736251&view=diff
==============================================================================
--- camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
(original)
+++ camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
Tue Jan 20 23:31:34 2009
@@ -22,7 +22,7 @@
 /**
  * @version $Revision$
  */
-public class EndpointResource extends ViewableResource {
+public class EndpointResource extends ResourceSupport {
 
     private final Endpoint endpoint;
 

Copied: camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ResourceSupport.java
(from r735938, camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ViewableResource.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ResourceSupport.java?p2=camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ResourceSupport.java&p1=camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ViewableResource.java&r1=735938&r2=736251&rev=736251&view=diff
==============================================================================
--- camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ViewableResource.java
(original)
+++ camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ResourceSupport.java
Tue Jan 20 23:31:34 2009
@@ -18,6 +18,8 @@
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Produces;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.core.MediaType;
 
 import com.sun.jersey.api.view.Viewable;
@@ -27,16 +29,12 @@
  *
  * @version $Revision: 1.1 $
  */
-@Produces({MediaType.TEXT_HTML})
-public abstract class ViewableResource {
+public abstract class ResourceSupport {
 
     @GET
+    @Path("{view:\\w*}")
     @Produces({MediaType.TEXT_HTML})
-    public Viewable index() {
-        return view("index");
-    }
-
-    protected Viewable view(String view) {
+    public Viewable view(@PathParam("view") String view) {
         if (view == null || view.length() == 0) {
             view = "index";
         }

Propchange: camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/ResourceSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message