You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2009/01/15 20:11:40 UTC

svn commit: r734781 - in /activemq/camel/trunk/components/camel-rest: ./ src/main/java/org/apache/camel/rest/model/ src/main/java/org/apache/camel/rest/resources/ src/main/java/org/apache/camel/rest/util/ src/main/resources/org/apache/camel/rest/model/...

Author: jstrachan
Date: Thu Jan 15 11:11:40 2009
New Revision: 734781

URL: http://svn.apache.org/viewvc?rev=734781&view=rev
Log:
improved the REST support for CAMEL-888; upgraded Jersey version, switched to explicit views to simplify some content negotiation issues we were having, simplified JSP and managed to get JSTL 1.1 working, got the HTML based test cases working after getting around http://jira.codehaus.org/browse/SUREFIRE-459

Added:
    activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Camel.java
      - copied, changed from r734392, activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java
    activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/Constants.java   (with props)
    activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/jspf/
    activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/jspf/header.jspf
    activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/endpoints.jsp   (with props)
    activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/foo.jsp   (with props)
    activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsHtmlTest.java
      - copied, changed from r734392, activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
Modified:
    activemq/camel/trunk/components/camel-rest/pom.xml
    activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
    activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
    activemq/camel/trunk/components/camel-rest/src/main/resources/org/apache/camel/rest/model/jaxb.index
    activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml
    activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/model/Endpoints/index.jsp
    activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
    activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
    activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/Main.java
    activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java

Modified: activemq/camel/trunk/components/camel-rest/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/pom.xml?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/pom.xml (original)
+++ activemq/camel/trunk/components/camel-rest/pom.xml Thu Jan 15 11:11:40 2009
@@ -33,7 +33,9 @@
 
   <properties>
     <camel.osgi.export.pkg>org.apache.camel.rest.*</camel.osgi.export.pkg>
-    <jersey-version>1.0-ea-SNAPSHOT</jersey-version>
+    <!--<jersey-version>1.0.1-ea-SNAPSHOT</jersey-version>-->
+    <!--<jersey-version>1.0.2-SNAPSHOT</jersey-version>-->
+    <jersey-version>1.0.1</jersey-version>
     <jetty-port>8080</jetty-port>
   </properties>
 
@@ -55,10 +57,18 @@
       <artifactId>camel-spring</artifactId>
     </dependency>
     <dependency>
-      <groupId>com.sun.jersey</groupId>
+      <!--<groupId>com.sun.jersey</groupId>-->
+      <groupId>com.sun.jersey.contribs</groupId>
       <artifactId>jersey-spring</artifactId>
       <version>${jersey-version}</version>
     </dependency>
+    <!--
+        <dependency>
+          <groupId>com.sun.jersey</groupId>
+          <artifactId>jersey-server</artifactId>
+          <version>${jersey-version}</version>
+        </dependency>
+    -->
     <dependency>
       <groupId>com.sun.jersey</groupId>
       <artifactId>jersey-json</artifactId>
@@ -77,6 +87,7 @@
       <version>${jersey-version}</version>
       <scope>test</scope>
     </dependency>
+
     <!-- web container -->
     <dependency>
       <groupId>org.mortbay.jetty</groupId>
@@ -96,6 +107,18 @@
       <version>${jetty-version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>jstl</artifactId>
+        <version>1.1.2</version>
+        <scope>compile</scope>
+    </dependency>
+    <dependency>
+        <groupId>taglibs</groupId>
+        <artifactId>standard</artifactId>
+        <version>1.1.2</version>
+    </dependency>
+
     <!-- enable commons-logging when inside jetty6:run -->
     <!--
     <dependency>
@@ -119,6 +142,13 @@
       <artifactId>slf4j-log4j12</artifactId>
     </dependency>
 
+    <!--
+        <dependency>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-web</artifactId>
+          <scope>test</scope>
+        </dependency>
+    -->
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
@@ -152,14 +182,17 @@
     <plugins>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.3</version>
         <configuration>
-          <forkMode>pertest</forkMode>
+          <forkMode>once</forkMode>
+          <!-- these settings are mandatory to avoid SureFire giving a bogus system property to the web container -->
+          <useSystemClassLoader>false</useSystemClassLoader>
+          <useManifestOnlyJar>false</useManifestOnlyJar>
           <includes>
             <include>**/*Test.*</include>
           </includes>
           <excludes>
             <!-- TODO FIXME ASAP -->
-            <exclude>**/EndpointsHtmlTest.*</exclude>
             <exclude>**/RoutesTest.*</exclude>
           </excludes>
         </configuration>
@@ -203,25 +236,27 @@
           </systemProperties>
           <scanIntervalSeconds>10</scanIntervalSeconds>
         </configuration>
-        <dependencies>
-          <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>${log4j-version}</version>
-          </dependency>
-          <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>jstl</artifactId>
-            <version>1.2</version>
-          </dependency>
-          <dependency>
-            <groupId>taglibs</groupId>
-            <artifactId>standard</artifactId>
-            <version>1.1.2</version>
-          </dependency>
-        </dependencies>
+        <!--
+                <dependencies>
+                  <dependency>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                    <version>${log4j-version}</version>
+                  </dependency>
+                  <dependency>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>jstl</artifactId>
+                    <version>1.2</version>
+                  </dependency>
+                  <dependency>
+                    <groupId>taglibs</groupId>
+                    <artifactId>standard</artifactId>
+                    <version>1.1.2</version>
+                  </dependency>
+                </dependencies>
+        -->
       </plugin>
-      
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-javadoc-plugin</artifactId>
@@ -245,7 +280,7 @@
           <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
           <docletArtifacts>
             <docletArtifact>
-              <groupId>com.sun.jersey</groupId>
+              <groupId>com.sun.jersey.contribs</groupId>
               <artifactId>maven-wadl-plugin</artifactId>
               <version>${jersey-version}</version>
             </docletArtifact>
@@ -310,50 +345,50 @@
         </executions>
       </plugin>
     </plugins>
-    
+
     <pluginManagement>
       <plugins>
-          <plugin>
-            <groupId>com.sun.tools.jxc.maven2</groupId>
-            <artifactId>maven-jaxb-schemagen-plugin</artifactId>
-            <executions>
-              <execution>
-                <phase>process-sources</phase>
-                <configuration>
-                  <destdir>${project.build.directory}/schema</destdir>
-                  <srcdir>src/main/java/org/apache/camel/rest/model</srcdir>
-                  <schemas>
-                    <schema>
-                      <namespace>http://activemq.apache.org/camel/schema/rest</namespace>
-                      <file>camel-rest.xsd</file>
-                    </schema>
-                  </schemas>
-                  <!--<verbose>false</verbose>-->
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-dependency-plugin</artifactId>
-            <configuration>
-              <artifactItems>
-                <artifactItem>
-                  <groupId>org.apache.camel</groupId>
-                  <artifactId>camel-rest</artifactId>
-                  <version>${pom.version}</version>
-                  <type>xsd</type>
-                  <overWrite>false</overWrite>
-                  <outputDirectory>${project.build.directory}/schema</outputDirectory>
-                  <destFileName>camel-rest.xsd</destFileName>
-                </artifactItem>
-              </artifactItems>
-            </configuration>
-          </plugin>
+        <plugin>
+          <groupId>com.sun.tools.jxc.maven2</groupId>
+          <artifactId>maven-jaxb-schemagen-plugin</artifactId>
+          <executions>
+            <execution>
+              <phase>process-sources</phase>
+              <configuration>
+                <destdir>${project.build.directory}/schema</destdir>
+                <srcdir>src/main/java/org/apache/camel/rest/model</srcdir>
+                <schemas>
+                  <schema>
+                    <namespace>http://activemq.apache.org/camel/schema/rest</namespace>
+                    <file>camel-rest.xsd</file>
+                  </schema>
+                </schemas>
+                <!--<verbose>false</verbose>-->
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-dependency-plugin</artifactId>
+          <configuration>
+            <artifactItems>
+              <artifactItem>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-rest</artifactId>
+                <version>${pom.version}</version>
+                <type>xsd</type>
+                <overWrite>false</overWrite>
+                <outputDirectory>${project.build.directory}/schema</outputDirectory>
+                <destFileName>camel-rest.xsd</destFileName>
+              </artifactItem>
+            </artifactItems>
+          </configuration>
+        </plugin>
       </plugins>
-    </pluginManagement>    
+    </pluginManagement>
   </build>
-  
+
   <profiles>
     <!-- The next three profiles are used to bypass the schemagen plugin on HP and IBM JDKs.
 
@@ -403,14 +438,14 @@
                 </goals>
               </execution>
             </executions>
-          </plugin>                  
+          </plugin>
           <plugin>
             <groupId>com.sun.tools.jxc.maven2</groupId>
             <artifactId>maven-jaxb-schemagen-plugin</artifactId>
           </plugin>
         </plugins>
       </build>
-    </profile>    
+    </profile>
     <profile>
       <id>on-hpjdk</id>
       <activation>
@@ -433,13 +468,13 @@
                 </goals>
               </execution>
             </executions>
-          </plugin>                          
+          </plugin>
           <plugin>
             <groupId>com.sun.tools.jxc.maven2</groupId>
             <artifactId>maven-jaxb-schemagen-plugin</artifactId>
           </plugin>
         </plugins>
       </build>
-    </profile>        
-  </profiles>  
+    </profile>
+  </profiles>
 </project>

Copied: activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Camel.java (from r734392, activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Camel.java?p2=activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Camel.java&p1=activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java&r1=734392&r2=734781&rev=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Endpoints.java (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/model/Camel.java Thu Jan 15 11:11:40 2009
@@ -24,6 +24,7 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAttribute;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
@@ -33,47 +34,28 @@
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
-public class Endpoints {
-    @XmlElement(name = "endpoint")
-    private List<EndpointLink> endpoints = new ArrayList<EndpointLink>();
+public class Camel {
+    @XmlAttribute
+    private String name;
 
-    public Endpoints() {
+    public Camel() {
     }
 
-    public Endpoints(CamelContext camelContext) {
-        this();
-        load(camelContext);
+    public Camel(CamelContext camelContext) {
+        setName(camelContext.getName());
     }
 
     @Override
     public String toString() {
-        return "Endpoints" + endpoints;
+        return "CamelContext: " + getName();
 
     }
 
-    public List<EndpointLink> getEndpoints() {
-        return endpoints;
+    public String getName() {
+        return name;
     }
 
-    public void setEndpoints(List<EndpointLink> endpoints) {
-        this.endpoints = endpoints;
+    public void setName(String name) {
+        this.name = name;
     }
-
-    public void load(CamelContext camelContext) {
-        Collection<Endpoint> endpoints = camelContext.getSingletonEndpoints();
-        for (Endpoint endpoint : endpoints) {
-            addEndpoint(createEndpointLink(endpoint));
-        }
-
-    }
-
-    protected EndpointLink createEndpointLink(Endpoint endpoint) {
-        EndpointLink answer = new EndpointLink();
-        answer.load(endpoint);
-        return answer;
-    }
-
-    public void addEndpoint(EndpointLink endpointLink) {
-        getEndpoints().add(endpointLink);
-    }
-}
+}
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/CamelContextResource.java Thu Jan 15 11:11:40 2009
@@ -17,22 +17,25 @@
 package org.apache.camel.rest.resources;
 
 
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
 import com.sun.jersey.spi.inject.Inject;
 import com.sun.jersey.spi.resource.Singleton;
-
+import com.sun.jersey.api.view.Viewable;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.model.RouteType;
 import org.apache.camel.model.RoutesType;
+import org.apache.camel.rest.model.Camel;
+import org.apache.camel.rest.model.EndpointLink;
 import org.apache.camel.rest.model.Endpoints;
 
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.List;
+//import static org.apache.camel.rest.resources.Constants.*;
+
 /**
  * The resource for the CamelContext
  *
@@ -40,7 +43,6 @@
  */
 @Path("/")
 @Singleton
-@Produces({"text/html", "application/xml", "application/json"})
 public class CamelContextResource {
 
     private final CamelContext camelContext;
@@ -57,6 +59,46 @@
         return camelContext.getName();
     }
 
+/*
+    @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML,
+            MediaType.WILDCARD, //MediaType.MEDIA_TYPE_WILDCARD,
+            MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN})
+*/
+
+
+    @GET
+    @Path("{view}")
+    @Produces({MediaType.TEXT_HTML})
+    public Viewable get(@PathParam("view") String view) {
+        if (view == null || view.length() == 0) {
+            view = "index";
+        }
+        return new Viewable(view, this);
+    }
+
+/*
+    @GET
+    @Produces({MediaType.TEXT_HTML})
+    public Viewable getIndexView() {
+        return new Viewable("index", this);
+    }
+
+    @GET
+    @Path("endpoints")
+    @Produces({MediaType.TEXT_HTML})
+    public Viewable getEndpointsView() {
+        return new Viewable("endpoints", this);
+    }
+*/
+
+
+    @GET
+    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
+    public Camel getCamel() {
+        return new Camel(camelContext);
+    }
+
+
     /**
      * Returns a list of endpoints available in this context
      *
@@ -64,10 +106,24 @@
      */
     @GET
     @Path("endpoints")
-    public Endpoints getEndpoint() {
+    @Produces({"application/xml", "application/json"})
+    public Endpoints getEndpointsDTO() {
         return new Endpoints(camelContext);
     }
 
+    public List<EndpointLink> getEndpoints() {
+        return getEndpointsDTO().getEndpoints();
+    }
+
+/*
+    @GET
+    @Path("endpoints")
+    @Produces({"text/html"})
+    public List<EndpointLink> getEndpoints() {
+        return getEndpointsDTO().getEndpoints();
+    }
+*/
+
     /**
      * Looks up an individual endpoint
      */

Added: activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/Constants.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/Constants.java?rev=734781&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/Constants.java (added)
+++ activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/resources/Constants.java Thu Jan 15 11:11:40 2009
@@ -0,0 +1,33 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.rest.resources;
+
+import javax.ws.rs.core.MediaType;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class Constants {
+    public static final String[] HTML_VIEW = {
+            MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML,
+            MediaType.WILDCARD, MediaType.MEDIA_TYPE_WILDCARD,
+            MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN};
+
+    public static final String[] DATA_VIEW = {MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON};
+
+}

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

Modified: activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/java/org/apache/camel/rest/util/JAXBContextResolver.java Thu Jan 15 11:11:40 2009
@@ -31,6 +31,7 @@
 import org.apache.camel.model.RoutesType;
 import org.apache.camel.rest.model.EndpointLink;
 import org.apache.camel.rest.model.Endpoints;
+import org.apache.camel.rest.model.Camel;
 
 /**
  * @version $Revision$
@@ -51,7 +52,7 @@
 
     protected Class[] getJaxbClasses() {
         return new Class[]{RoutesType.class, RouteType.class,
-                           Endpoints.class, EndpointLink.class};
+                           Camel.class, Endpoints.class, EndpointLink.class};
     }
 
     public JAXBContext getContext(Class<?> objectType) {

Modified: activemq/camel/trunk/components/camel-rest/src/main/resources/org/apache/camel/rest/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/resources/org/apache/camel/rest/model/jaxb.index?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/resources/org/apache/camel/rest/model/jaxb.index (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/resources/org/apache/camel/rest/model/jaxb.index Thu Jan 15 11:11:40 2009
@@ -14,5 +14,6 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ------------------------------------------------------------------------
+Camel
 EndpointLink
 Endpoints

Added: activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/jspf/header.jspf
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/jspf/header.jspf?rev=734781&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/jspf/header.jspf (added)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/jspf/header.jspf Thu Jan 15 11:11:40 2009
@@ -0,0 +1,20 @@
+<%--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+--%>
+<%@page contentType="text/html"%>
+<%@page pageEncoding="UTF-8"%>
+<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Modified: activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/WEB-INF/web.xml Thu Jan 15 11:11:40 2009
@@ -15,11 +15,9 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-
 <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
-         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
          version="2.4">
 
   <description>
@@ -62,23 +60,23 @@
       <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
       <param-value>org.apache.camel.rest.util.CamelResourceConfig</param-value>
     </init-param>
-<!--
-    <init-param>
-      <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
-      <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
-    </init-param>
--->
+    <!--
+        <init-param>
+          <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
+          <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
+        </init-param>
+    -->
     <init-param>
       <param-name>com.sun.jersey.config.property.packages</param-name>
       <param-value>org.apache.camel.rest</param-value>
     </init-param>
     <init-param>
-        <param-name>com.sun.jersey.config.feature.Redirect</param-name>
-        <param-value>true</param-value>
+      <param-name>com.sun.jersey.config.feature.Redirect</param-name>
+      <param-value>true</param-value>
     </init-param>
     <init-param>
-        <param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
-        <param-value>true</param-value>
+      <param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
+      <param-value>true</param-value>
     </init-param>
   </servlet>
   <servlet-mapping>
@@ -86,4 +84,18 @@
     <url-pattern>/</url-pattern>
   </servlet-mapping>
 
+
+<!--
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>index.jsp</welcome-file>
+  </welcome-file-list>
+-->
+
+  <jsp-config>
+    <jsp-property-group>
+      <url-pattern>*.jsp</url-pattern>
+      <include-prelude>/WEB-INF/jspf/header.jspf</include-prelude>
+    </jsp-property-group>
+  </jsp-config>
 </web-app>

Modified: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/model/Endpoints/index.jsp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/model/Endpoints/index.jsp?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/model/Endpoints/index.jsp (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/model/Endpoints/index.jsp Thu Jan 15 11:11:40 2009
@@ -1,7 +1,3 @@
-<%@page contentType="text/html" %>
-<%@page pageEncoding="UTF-8" %>
-<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Added: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/endpoints.jsp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/endpoints.jsp?rev=734781&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/endpoints.jsp (added)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/endpoints.jsp Thu Jan 15 11:11:40 2009
@@ -0,0 +1,18 @@
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  <title>Endpoints</title>
+</head>
+<body>
+
+<h2>Endpoints</h2>
+
+<ul>
+  <c:forEach var="i" items="${it.endpoints}">
+    <li><a href="${i.href}">${i.uri}</a>
+  </c:forEach>
+</ul>
+
+
+</body>
+</html>

Propchange: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/endpoints.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/foo.jsp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/foo.jsp?rev=734781&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/foo.jsp (added)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/foo.jsp Thu Jan 15 11:11:40 2009
@@ -0,0 +1,13 @@
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  <title>Foo</title>
+</head>
+<body>
+
+<h2>Foo</h2>
+
+<p>This is the FOO view for the Camel Context</p>
+
+</body>
+</html>

Propchange: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/foo.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/CamelContextResource/index.jsp Thu Jan 15 11:11:40 2009
@@ -1,8 +1,3 @@
-<%@page contentType="text/html" %>
-<%@page pageEncoding="UTF-8" %>
-<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
 <html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Modified: activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp (original)
+++ activemq/camel/trunk/components/camel-rest/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp Thu Jan 15 11:11:40 2009
@@ -1,8 +1,3 @@
-<%@page contentType="text/html"%>
-<%@page pageEncoding="UTF-8"%>
-<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
 <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Modified: activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/Main.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/Main.java?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/Main.java (original)
+++ activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/Main.java Thu Jan 15 11:11:40 2009
@@ -60,6 +60,18 @@
         context.setResourceBase(WEBAPP_DIR);
         context.setContextPath(WEBAPP_CTX);
         context.setServer(server);
+
+        // lets find the class loader of JSTL
+/*
+        Class<?> stlVersion = Class.forName("org.apache.taglibs.standard.Version");
+        System.out.println("Found STL Version: " + stlVersion);
+        ClassLoader classLoader = stlVersion.getClassLoader();
+        context.setClassLoader(classLoader);
+*/
+
+
+        //Thread.currentThread().setContextClassLoader(classLoader);
+
         server.setHandlers(new Handler[] {context});
         server.setConnectors(new Connector[] {connector});
         server.start();

Copied: activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsHtmlTest.java (from r734392, activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsHtmlTest.java?p2=activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsHtmlTest.java&p1=activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java&r1=734392&r2=734781&rev=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java (original)
+++ activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsHtmlTest.java Thu Jan 15 11:11:40 2009
@@ -16,35 +16,23 @@
  */
 package org.apache.camel.rest.resources;
 
-import java.util.List;
-
-import com.sun.jersey.api.client.WebResource;
-
-import org.apache.camel.rest.model.EndpointLink;
-import org.apache.camel.rest.model.Endpoints;
-
 
 /**
  * @version $Revision$
  */
-public class EndpointsTest extends TestSupport {
+public class EndpointsHtmlTest extends TestSupport {
 
-    public void testEndpointsAsXml() throws Exception {
-        Endpoints endpoints = resource("endpoints").accept("application/xml").get(Endpoints.class);
-        assertValidEndpoints(endpoints);
+    public void testCamelAsHtml() throws Exception {
+        String response = resource("/").accept("text/html").get(String.class);
 
-        endpoints = resource("endpoints.xml").get(Endpoints.class);
-        assertValidEndpoints(endpoints);
+        assertTrue("Should contain <html> but was: " + response, response.contains("<html>"));
     }
 
-    // TODO test as JSON
 
-    protected void assertValidEndpoints(Endpoints endpoints) {
-        assertNotNull("Should have found endpoints", endpoints);
+    public void testEndpointsAsHtml() throws Exception {
+        String response = resource("endpoints").accept("text/html").get(String.class);
 
-        System.out.println("Found: " + endpoints.getEndpoints());
-
-        List<EndpointLink> list = endpoints.getEndpoints();
-        assertTrue("Should have received some endpoints!", !list.isEmpty());
+        assertTrue("Should contain <html> but was: " + response, response.contains("<html>"));
     }
+
 }
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java?rev=734781&r1=734780&r2=734781&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java (original)
+++ activemq/camel/trunk/components/camel-rest/src/test/java/org/apache/camel/rest/resources/EndpointsTest.java Thu Jan 15 11:11:40 2009
@@ -16,19 +16,25 @@
  */
 package org.apache.camel.rest.resources;
 
-import java.util.List;
-
-import com.sun.jersey.api.client.WebResource;
-
+import org.apache.camel.rest.model.Camel;
 import org.apache.camel.rest.model.EndpointLink;
 import org.apache.camel.rest.model.Endpoints;
 
+import java.util.List;
 
 /**
  * @version $Revision$
  */
 public class EndpointsTest extends TestSupport {
 
+    public void testCamelAsXml() throws Exception {
+        Camel camel = resource("/").accept("application/xml").get(Camel.class);
+        assertValidCamel(camel);
+
+        camel = resource("/.xml").get(Camel.class);
+        assertValidCamel(camel);
+    }
+
     public void testEndpointsAsXml() throws Exception {
         Endpoints endpoints = resource("endpoints").accept("application/xml").get(Endpoints.class);
         assertValidEndpoints(endpoints);
@@ -37,8 +43,16 @@
         assertValidEndpoints(endpoints);
     }
 
+
     // TODO test as JSON
 
+
+    protected void assertValidCamel(Camel camel) {
+        assertNotNull("Should have found camel", camel);
+
+        System.out.println("Found: " + camel);
+    }
+
     protected void assertValidEndpoints(Endpoints endpoints) {
         assertNotNull("Should have found endpoints", endpoints);