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/02/18 14:12:18 UTC
svn commit: r745506 - in /camel/trunk/components/camel-web/src/main:
java/org/apache/camel/rest/resources/ webapp/WEB-INF/jspf/
webapp/org/apache/camel/rest/resources/EndpointResource/
webapp/org/apache/camel/rest/resources/ExchangeResource/
Author: jstrachan
Date: Wed Feb 18 13:12:17 2009
New Revision: 745506
URL: http://svn.apache.org/viewvc?rev=745506&view=rev
Log:
added a basic ability to browse browsable-endpoints and their messages
Added:
camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/ExchangeResource.java (with props)
camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/
camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/index.jsp (with props)
Modified:
camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
camel/trunk/components/camel-web/src/main/webapp/WEB-INF/jspf/header.jspf
camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/EndpointResource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/EndpointResource.java?rev=745506&r1=745505&r2=745506&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/EndpointResource.java (original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/EndpointResource.java Wed Feb 18 13:12:17 2009
@@ -24,10 +24,15 @@
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
+import org.apache.camel.util.EndpointHelper;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.spi.BrowsableEndpoint;
import org.apache.camel.rest.model.EndpointLink;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
@@ -70,6 +75,39 @@
return template;
}
+ public HttpHeaders getHeaders() {
+ return headers;
+ }
+
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+
+ public BrowsableEndpoint getBrowsableEndpoint() {
+ if (endpoint instanceof BrowsableEndpoint) {
+ return (BrowsableEndpoint) endpoint;
+ }
+ return null;
+ }
+
+ @Path("messages/{id}")
+ public ExchangeResource getExchange(@PathParam("id") String exchangeId) {
+ if (endpoint instanceof BrowsableEndpoint) {
+ BrowsableEndpoint browsableEndpoint = (BrowsableEndpoint) endpoint;
+ Exchange exchange = ExchangeHelper.getExchangeById(browsableEndpoint.getExchanges(), exchangeId);
+ if (exchange != null) {
+ return new ExchangeResource(this, exchange);
+ }
+ }
+ // should return 404
+ return null;
+ }
+
@POST
@Consumes({MediaType.TEXT_PLAIN, MediaType.TEXT_HTML, MediaType.TEXT_XML, MediaType.APPLICATION_XML})
public Response postMessage(final String body) throws URISyntaxException {
@@ -97,6 +135,8 @@
// lets pass in all the HTTP headers
if (headers != null) {
MultivaluedMap<String, String> requestHeaders = headers.getRequestHeaders();
+
+ System.out.println("Headers are: " + requestHeaders);
Set<Map.Entry<String, List<String>>> entries = requestHeaders.entrySet();
for (Map.Entry<String, List<String>> entry : entries) {
String key = entry.getKey();
@@ -109,6 +149,9 @@
}
}
}
+ else {
+ System.out.println("No request headers!");
+ }
}
});
}
Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/ExchangeResource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/ExchangeResource.java?rev=745506&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/ExchangeResource.java (added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/ExchangeResource.java Wed Feb 18 13:12:17 2009
@@ -0,0 +1,95 @@
+/**
+ *
+ * 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 com.sun.jersey.api.view.ImplicitProduces;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.spi.UnitOfWork;
+
+import java.util.Map;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@ImplicitProduces(Constants.HTML_MIME_TYPES)
+public class ExchangeResource {
+ private final EndpointResource endpointResource;
+ private final Exchange exchange;
+
+ public ExchangeResource(EndpointResource endpointResource, Exchange exchange) {
+ this.endpointResource = endpointResource;
+ this.exchange = exchange;
+ }
+
+ public Exchange getExchange() {
+ return exchange;
+ }
+
+ // Helper methods for the view
+ public CamelContext getCamelContext() {
+ return exchange.getContext();
+ }
+
+ public String getExchangeId() {
+ return exchange.getExchangeId();
+ }
+
+ public Throwable getException() {
+ return exchange.getException();
+ }
+
+ public Message getFault() {
+ return exchange.getFault();
+ }
+
+ public Endpoint getFromEndpoint() {
+ return exchange.getFromEndpoint();
+ }
+
+ public Message getIn() {
+ return exchange.getIn();
+ }
+
+ public Message getOut() {
+ return exchange.getOut(false);
+ }
+
+ public Map<String, Object> getProperties() {
+ return exchange.getProperties();
+ }
+
+ public ExchangePattern getPattern() {
+ return exchange.getPattern();
+ }
+
+ public UnitOfWork getUnitOfWork() {
+ return exchange.getUnitOfWork();
+ }
+
+ public boolean isFailed() {
+ return exchange.isFailed();
+ }
+
+ public boolean isTransacted() {
+ return exchange.isTransacted();
+ }
+}
Propchange: camel/trunk/components/camel-web/src/main/java/org/apache/camel/rest/resources/ExchangeResource.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: camel/trunk/components/camel-web/src/main/webapp/WEB-INF/jspf/header.jspf
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/WEB-INF/jspf/header.jspf?rev=745506&r1=745505&r2=745506&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/WEB-INF/jspf/header.jspf (original)
+++ camel/trunk/components/camel-web/src/main/webapp/WEB-INF/jspf/header.jspf Wed Feb 18 13:12:17 2009
@@ -15,7 +15,8 @@
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"%>
+<%@ page contentType="text/html" %>
+<%@ page pageEncoding="UTF-8" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
Modified: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp?rev=745506&r1=745505&r2=745506&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp (original)
+++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/EndpointResource/index.jsp Wed Feb 18 13:12:17 2009
@@ -7,9 +7,21 @@
<h1>Endpoint: ${it.uri}</h1>
-
<ul>
<li><a href="${it.href}/send">Send to this endpoint</a></li>
</ul>
+
+ <c:if test="${it.browsableEndpoint != null}">
+ <table>
+ <tr>
+ <th>Message ID (${fn:length(it.browsableEndpoint.exchanges)} in total)</th>
+ </tr>
+ <c:forEach items="${it.browsableEndpoint.exchanges}" var="exchange">
+ <tr>
+ <td><a href="${it.href}/messages/${exchange.exchangeId}" title="View this message">${exchange.exchangeId}</a></td>
+ </tr>
+ </c:forEach>
+ </table>
+ </c:if>
</body>
</html>
Added: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/index.jsp
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/index.jsp?rev=745506&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/index.jsp (added)
+++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/index.jsp Wed Feb 18 13:12:17 2009
@@ -0,0 +1,60 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Exchange ${it.exchangeId}</title>
+</head>
+<body>
+
+<h1>Exchange: ${it.exchangeId}</h1>
+
+
+<table>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th colspan="2">Properties</th>
+ </tr>
+ <tr>
+ <th>Name</th>
+ <th>Value</th>
+ </tr>
+ <c:forEach items="${it.properties}" var="entry">
+ <tr>
+ <td>${entry.key}</td>
+ <td>${entry.value}</td>
+ </tr>
+ </c:forEach>
+ </table>
+ </td>
+ <td>
+ <table>
+ <tr>
+ <th colspan="2">Headers</th>
+ </tr>
+ <tr>
+ <th>Name</th>
+ <th>Value</th>
+ </tr>
+ <c:forEach items="${it.in.headers}" var="entry">
+ <tr>
+ <td>${entry.key}</td>
+ <td>${entry.value}</td>
+ </tr>
+ </c:forEach>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <th colspan="2">
+ Message Body
+ </th>
+ </tr>
+ <tr>
+ <td colspan="2">
+ ${it.in.body}
+ </td>
+ </tr>
+</table>
+</body>
+</html>
Propchange: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/rest/resources/ExchangeResource/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native