You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/03/25 08:49:26 UTC
svn commit: r640731 [2/4] - in /activemq/camel/trunk/components:
camel-amqp/src/main/java/org/apache/camel/component/amqp/
camel-amqp/src/test/java/org/apache/camel/component/amqp/
camel-ftp/src/main/java/org/apache/camel/component/file/remote/ camel-f...
Modified: activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java (original)
+++ activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/MessageTypeTest.java Tue Mar 25 00:49:12 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,12 +16,12 @@
*/
package org.apache.camel.converter.jaxb;
-import org.apache.camel.ExchangeTestSupport;
-import org.apache.camel.model.RouteContainer;
+import java.io.StringWriter;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
-import java.io.StringWriter;
+
+import org.apache.camel.ExchangeTestSupport;
/**
* @version $Revision$
@@ -37,7 +36,7 @@
log.info("headers: " + messageType.getHeaderMap());
log.info("body: " + messageType.getBody());
-
+
dump(messageType);
}
Modified: activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/PurchaseOrder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/PurchaseOrder.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/PurchaseOrder.java (original)
+++ activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/example/PurchaseOrder.java Tue Mar 25 00:49:12 2008
@@ -44,12 +44,16 @@
@Override
public boolean equals(Object o) {
if (o instanceof PurchaseOrder) {
- PurchaseOrder that = (PurchaseOrder) o;
- return ObjectHelper.equal(this.name, that.name) &&
- ObjectHelper.equal(this.amount, that.amount) &&
- ObjectHelper.equal(this.price, that.price);
+ PurchaseOrder that = (PurchaseOrder)o;
+ return ObjectHelper.equal(this.name, that.name) && ObjectHelper.equal(this.amount, that.amount)
+ && ObjectHelper.equal(this.price, that.price);
}
return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode() + (int)Math.round(price * 100) + (int)Math.round(amount * 100);
}
public double getAmount() {
Modified: activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java (original)
+++ activemq/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/DumpToXmlTest.java Tue Mar 25 00:49:12 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrProducer.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrProducer.java (original)
+++ activemq/camel/trunk/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrProducer.java Tue Mar 25 00:49:12 2008
@@ -49,8 +49,7 @@
session.save();
exchange.getOut().setBody(node.getUUID());
} finally {
- if (session != null &&
- session.isLive() ) {
+ if (session != null && session.isLive()) {
session.logout();
}
}
Modified: activemq/camel/trunk/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTest.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrRouteTest.java Tue Mar 25 00:49:12 2008
@@ -43,7 +43,8 @@
}
private void clean() throws IOException {
- File[] files = { new File("target/repository"), new File("target/repository.xml"), new File("derby.log") };
+ File[] files = {new File("target/repository"), new File("target/repository.xml"),
+ new File("derby.log")};
for (File file : files) {
if (file.exists()) {
FileUtil.delete(file);
@@ -75,10 +76,8 @@
@Override
public void configure() throws Exception {
// START SNIPPET: jcr
- from("direct:a")
- .setProperty(JcrComponent.NODE_NAME, constant("node"))
- .setProperty("my.contents.property", body())
- .to("jcr://user:pass@repository/home/test");
+ from("direct:a").setProperty(JcrComponent.NODE_NAME, constant("node"))
+ .setProperty("my.contents.property", body()).to("jcr://user:pass@repository/home/test");
// END SNIPPET: jcr
}
};
Modified: activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcComponent.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcComponent.java (original)
+++ activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcComponent.java Tue Mar 25 00:49:12 2008
@@ -11,7 +11,7 @@
* 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 pejdbcssions and
+ * See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.jdbc;
Modified: activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java Tue Mar 25 00:49:12 2008
@@ -11,7 +11,7 @@
* 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 pejdbcssions and
+ * See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.jdbc;
@@ -23,7 +23,6 @@
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
-import org.apache.camel.ExchangePattern;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.impl.DefaultExchange;
Modified: activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java (original)
+++ activemq/camel/trunk/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcProducer.java Tue Mar 25 00:49:12 2008
@@ -11,7 +11,7 @@
* 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 pejdbcssions and
+ * See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.component.jdbc;
@@ -49,7 +49,7 @@
/**
* Execute sql of exchange and set results on output
- *
+ *
* @see org.apache.camel.Processor#process(org.apache.camel.Exchange)
*/
public void process(Exchange exchange) throws Exception {
Modified: activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcRouteTest.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcRouteTest.java Tue Mar 25 00:49:12 2008
@@ -16,6 +16,13 @@
*/
package org.apache.camel.component.jdbc;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.sql.DataSource;
+
import junit.framework.TestCase;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelTemplate;
@@ -24,12 +31,6 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.util.jndi.JndiContext;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.util.ArrayList;
-import java.util.HashMap;
/**
* @version $Revision$
Modified: activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/TestDataSource.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/TestDataSource.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/TestDataSource.java (original)
+++ activemq/camel/trunk/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/TestDataSource.java Tue Mar 25 00:49:12 2008
@@ -25,18 +25,20 @@
/**
* TODO Provide description for TestDataSource.
- *
+ *
* @author <a href="mailto:nsandhu@raleys.com">nsandhu</a>
*
*/
-public class TestDataSource implements DataSource{
- private String url, username, password;
- public TestDataSource(String url, String user, String password){
- this.url=url;
- this.username=user;
- this.password=password;
+public class TestDataSource implements DataSource {
+ private final String url;
+ private final String username;
+ private final String password;
+ public TestDataSource(String url, String user, String password) {
+ this.url = url;
+ this.username = user;
+ this.password = password;
}
-
+
public Connection getConnection() throws SQLException {
return DriverManager.getConnection(url, username, password);
}
@@ -54,20 +56,20 @@
}
public void setLoginTimeout(int seconds) throws SQLException {
- DriverManager.setLoginTimeout(seconds);
+ DriverManager.setLoginTimeout(seconds);
}
public void setLogWriter(PrintWriter out) throws SQLException {
DriverManager.setLogWriter(out);
}
- public boolean isWrapperFor(Class<?> iface) throws SQLException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public <T> T unwrap(Class<T> iface) throws SQLException {
- return null;
- }
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ return null;
+ }
}
Modified: activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java (original)
+++ activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java Tue Mar 25 00:49:12 2008
@@ -74,14 +74,14 @@
});
if (!sync) {
-
+
// Wait for the exchange to get processed.
// This might block until it completes or it might return via an exception and
// then this method is re-invoked once the the exchange has finished processing
- continuation.suspend(0);
-
+ continuation.suspend(0);
+
}
-
+
// HC: The getBinding() is interesting because it illustrates the
// impedance miss-match between
// HTTP's stream oriented protocol, and Camels more message oriented
@@ -91,8 +91,8 @@
consumer.getBinding().writeResponse(exchange, response);
return;
}
-
- if (continuation.isResumed() ) {
+
+ if (continuation.isResumed()) {
HttpExchange exchange = (HttpExchange)continuation.getObject();
// now lets output to the response
consumer.getBinding().writeResponse(exchange, response);
Modified: activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java Tue Mar 25 00:49:12 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -44,7 +43,7 @@
@Override
public Producer<HttpExchange> createProducer() throws Exception {
return super.createProducer();
- // return new JettyHttpProducer(this);
+ // return new JettyHttpProducer(this);
}
@Override
Modified: activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java (original)
+++ activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java Tue Mar 25 00:49:12 2008
@@ -30,12 +30,12 @@
import org.apache.camel.component.http.HttpEndpoint;
import org.apache.camel.component.http.HttpExchange;
import org.apache.camel.impl.DefaultProducer;
-
import org.mortbay.io.Buffer;
import org.mortbay.jetty.HttpFields;
+import org.mortbay.jetty.HttpFields.Field;
import org.mortbay.jetty.HttpMethods;
import org.mortbay.jetty.HttpURI;
-import org.mortbay.jetty.HttpFields.Field;
+
import org.mortbay.jetty.client.HttpClient;
import org.mortbay.jetty.client.HttpExchange.ContentExchange;
@@ -129,11 +129,11 @@
}
HttpBinding binding = ((HttpEndpoint)getEndpoint()).getBinding();
- for (String name : in.getHeaders().keySet()) {
+ for (String name : in.getHeaders().keySet()) {
String value = in.getHeader(name, String.class);
- if( "Content-Type".equals(name) ) {
+ if ("Content-Type".equals(name)) {
jettyExchange.setRequestContentType(value);
- } else if (binding.shouldHeaderBePropagated(name, value)){
+ } else if (binding.shouldHeaderBePropagated(name, value)) {
jettyExchange.addRequestHeader(name, value);
}
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java Tue Mar 25 00:49:12 2008
@@ -16,16 +16,31 @@
*/
package org.apache.camel.component.jhc;
-import org.apache.http.*;
-import org.apache.http.impl.DefaultHttpResponseFactory;
+import java.io.IOException;
+
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseFactory;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolVersion;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.nio.util.ByteBufferAllocator;
+import org.apache.http.impl.DefaultHttpResponseFactory;
import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.nio.util.ByteBufferAllocator;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpParamsLinker;
-import org.apache.http.protocol.*;
-
-import java.io.IOException;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.http.protocol.ResponseConnControl;
+import org.apache.http.protocol.ResponseContent;
+import org.apache.http.protocol.ResponseDate;
+import org.apache.http.protocol.ResponseServer;
/**
* Created by IntelliJ IDEA.
@@ -36,7 +51,7 @@
*/
public class AsyncBufferingHttpServiceHandler extends BufferingHttpServiceHandler {
-
+
public AsyncBufferingHttpServiceHandler(final HttpParams params) {
super(createDefaultProcessor(),
new DefaultHttpResponseFactory(),
@@ -90,10 +105,10 @@
HttpRequestHandler handler = null;
if (handlerResolver != null) {
- String requestURI = request.getRequestLine().getUri();
- handler = handlerResolver.lookup(requestURI);
+ String requestURI = request.getRequestLine().getUri();
+ handler = handlerResolver.lookup(requestURI);
}
- if (handler != null) {
+ if (handler != null) {
if (handler instanceof AsyncHttpRequestHandler) {
((AsyncHttpRequestHandler)handler).handle(request, context, new AsyncResponseHandler() {
public void sendResponse(HttpResponse response) throws IOException, HttpException {
@@ -119,7 +134,7 @@
context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
handler.handle(request, response, context);
sendResponse(conn, response);
- }
+ }
} else {
// add the default handler here
HttpResponse response = this.responseFactory.newHttpResponse(
@@ -127,7 +142,7 @@
HttpStatus.SC_OK,
conn.getContext());
response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
-
+
}
} catch (HttpException ex) {
@@ -140,6 +155,6 @@
sendResponse(conn, response);
}
- }
+ }
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncHttpRequestHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncHttpRequestHandler.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncHttpRequestHandler.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncHttpRequestHandler.java Tue Mar 25 00:49:12 2008
@@ -24,10 +24,9 @@
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
-
public interface AsyncHttpRequestHandler extends HttpRequestHandler {
-
- void handle(HttpRequest request, HttpContext context, AsyncResponseHandler handler)
- throws HttpException, IOException;
+
+ void handle(HttpRequest request, HttpContext context, AsyncResponseHandler handler) throws HttpException,
+ IOException;
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncResponseHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncResponseHandler.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncResponseHandler.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncResponseHandler.java Tue Mar 25 00:49:12 2008
@@ -22,7 +22,7 @@
import org.apache.http.HttpResponse;
public interface AsyncResponseHandler {
-
- void sendResponse(HttpResponse response) throws IOException, HttpException;
-
+
+ void sendResponse(HttpResponse response) throws IOException, HttpException;
+
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java Tue Mar 25 00:49:12 2008
@@ -1,37 +1,38 @@
-/*
- * $HeadURL: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha5/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java $
- * $Revision$
- * $Date$
- *
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
+/**
+ * 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.component.jhc;
-import org.apache.http.*;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.http.ConnectionReuseStrategy;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseFactory;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.MethodNotSupportedException;
+import org.apache.http.ProtocolException;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.UnsupportedHttpVersionException;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.nio.ContentDecoder;
import org.apache.http.nio.ContentEncoder;
@@ -40,15 +41,20 @@
import org.apache.http.nio.entity.ContentBufferEntity;
import org.apache.http.nio.entity.ContentOutputStream;
import org.apache.http.nio.protocol.NHttpServiceHandlerBase;
-import org.apache.http.nio.util.*;
+import org.apache.http.nio.util.ByteBufferAllocator;
+import org.apache.http.nio.util.ContentInputBuffer;
+import org.apache.http.nio.util.ContentOutputBuffer;
+import org.apache.http.nio.util.HeapByteBufferAllocator;
+import org.apache.http.nio.util.SimpleInputBuffer;
+import org.apache.http.nio.util.SimpleOutputBuffer;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpParamsLinker;
-import org.apache.http.protocol.*;
+import org.apache.http.protocol.ExecutionContext;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpProcessor;
+import org.apache.http.protocol.HttpRequestHandler;
import org.apache.http.util.EncodingUtils;
-import java.io.IOException;
-import java.io.OutputStream;
-
/**
* HTTP service handler implementation that buffers the content of HTTP messages
* entirely in memory and processes HTTP requests on the main I/O thread.
@@ -59,7 +65,7 @@
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
*
*/
-public class BufferingHttpServiceHandler extends NHttpServiceHandlerBase
+public class BufferingHttpServiceHandler extends NHttpServiceHandlerBase
implements NHttpServiceHandler {
public BufferingHttpServiceHandler(
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java Tue Mar 25 00:49:12 2008
@@ -1,55 +1,38 @@
-/*
- * $HeadURL$
- * $Revision$
- * $Date$
- *
- * ====================================================================
- * 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.
- * ====================================================================
+/**
+ * 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
*
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
+ * 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.component.jhc;
+import java.io.IOException;
+import java.net.SocketAddress;
+import java.nio.channels.CancelledKeyException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.util.Iterator;
+import java.util.Set;
+
import org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor;
import org.apache.http.impl.nio.reactor.ChannelEntry;
-
-import org.apache.http.nio.reactor.IOEventDispatch;
import org.apache.http.nio.reactor.IOReactorException;
-import org.apache.http.nio.reactor.IOReactorExceptionHandler;
import org.apache.http.nio.reactor.ListeningIOReactor;
-import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.concurrent.ThreadFactory;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.nio.channels.*;
-import java.util.Iterator;
-import java.util.Set;
-
/**
* Trunk version of DefaultListenerIOReactor.
* Should be removed when upgrading to httpcore > alpha5
@@ -57,18 +40,18 @@
public class DefaultListeningIOReactor extends AbstractMultiworkerIOReactor
implements ListeningIOReactor {
- private volatile boolean closed = false;
+ private volatile boolean closed;
private final HttpParams params;
-
-
+
+
public DefaultListeningIOReactor(
int workerCount,
final ThreadFactory threadFactory,
final HttpParams params) throws IOReactorException {
super(workerCount, threadFactory, params);
- this.params = params;
+ this.params = params;
}
public DefaultListeningIOReactor(
@@ -77,25 +60,23 @@
this(workerCount, null, params);
}
-
- private void processEvents(final Set selectedKeys)
- throws IOReactorException {
- for (Iterator it = selectedKeys.iterator(); it.hasNext(); ) {
- SelectionKey key = (SelectionKey) it.next();
+ private void processEvents(final Set selectedKeys) throws IOReactorException {
+ for (Iterator it = selectedKeys.iterator(); it.hasNext();) {
+
+ SelectionKey key = (SelectionKey)it.next();
processEvent(key);
}
selectedKeys.clear();
}
- private void processEvent(final SelectionKey key)
- throws IOReactorException {
+ private void processEvent(final SelectionKey key) throws IOReactorException {
try {
if (key.isAcceptable()) {
- ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
+ ServerSocketChannel serverChannel = (ServerSocketChannel)key.channel();
SocketChannel socketChannel = null;
try {
socketChannel = serverChannel.accept();
@@ -113,7 +94,7 @@
throw new IOReactorException("Failure initalizing socket", ex);
}
}
- ChannelEntry entry = new ChannelEntry(socketChannel);
+ ChannelEntry entry = new ChannelEntry(socketChannel);
addChannel(entry);
}
}
@@ -139,7 +120,7 @@
@Override
protected void processEvents(int count) throws IOReactorException {
processEvents(this.selector.selectedKeys());
-
+
}
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java Tue Mar 25 00:49:12 2008
@@ -16,44 +16,21 @@
*/
package org.apache.camel.component.jhc;
+import java.net.URI;
+import java.util.Map;
+
import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.Message;
import org.apache.camel.impl.DefaultComponent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.nio.reactor.ConnectingIOReactor;
-import org.apache.http.nio.reactor.IOEventDispatch;
-import org.apache.http.nio.reactor.SessionRequestCallback;
-import org.apache.http.nio.reactor.SessionRequest;
-import org.apache.http.nio.protocol.BufferingHttpClientHandler;
-import org.apache.http.nio.protocol.HttpRequestExecutionHandler;
-import org.apache.http.nio.protocol.EventListener;
-import org.apache.http.nio.NHttpConnection;
-import org.apache.http.util.concurrent.ThreadFactory;
-import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
-import org.apache.http.impl.nio.DefaultClientIOEventDispatch;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
-import org.apache.http.protocol.*;
-import org.apache.http.*;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Iterator;
-import java.io.InterruptedIOException;
-import java.io.IOException;
public class JhcComponent extends DefaultComponent<JhcExchange> {
- private static Log LOG = LogFactory.getLog(JhcComponent.class);
+ private static final Log LOG = LogFactory.getLog(JhcComponent.class);
private HttpParams params;
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java Tue Mar 25 00:49:12 2008
@@ -16,74 +16,57 @@
*/
package org.apache.camel.component.jhc;
+import java.io.IOException;
+
import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.impl.DefaultConsumer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.*;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseFactory;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.ProtocolVersion;
import org.apache.http.impl.DefaultHttpResponseFactory;
-import org.apache.http.impl.nio.DefaultServerIOEventDispatch;
-import org.apache.http.impl.nio.reactor.SSLServerIOEventDispatch;
-import org.apache.http.nio.*;
-import org.apache.http.nio.entity.ContentOutputStream;
-import org.apache.http.nio.util.ContentOutputBuffer;
+import org.apache.http.nio.NHttpConnection;
import org.apache.http.nio.protocol.EventListener;
-import org.apache.http.nio.reactor.IOEventDispatch;
-import org.apache.http.nio.reactor.ListeningIOReactor;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpParamsLinker;
-import org.apache.http.protocol.*;
-import org.apache.http.util.EncodingUtils;
-import org.apache.http.util.concurrent.ThreadFactory;
-
-import javax.net.ssl.SSLContext;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.UnsupportedEncodingException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.ServerSocketChannel;
-import java.nio.channels.SelectionKey;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
/**
- * Created by IntelliJ IDEA.
- * User: gnodet
- * Date: Sep 7, 2007
- * Time: 8:15:54 PM
- * To change this template use File | Settings | File Templates.
+ * Created by IntelliJ IDEA. User: gnodet Date: Sep 7, 2007 Time: 8:15:54 PM To
+ * change this template use File | Settings | File Templates.
*/
public class JhcConsumer extends DefaultConsumer<JhcExchange> {
- private static Log LOG = LogFactory.getLog(JhcConsumer.class);
+ private static final Log LOG = LogFactory.getLog(JhcConsumer.class);
private JhcServerEngine engine;
private MyHandler handler;
-
public JhcConsumer(JhcEndpoint endpoint, Processor processor) {
super(endpoint, processor);
- engine = JhcServerEngineFactory.getJhcServerEngine(endpoint.getParams(),
- endpoint.getPort(),
- endpoint.getProtocol());
+ engine = JhcServerEngineFactory.getJhcServerEngine(endpoint.getParams(), endpoint.getPort(), endpoint
+ .getProtocol());
handler = new MyHandler(endpoint.getParams(), endpoint.getPath());
-
+
}
public JhcEndpoint getEndpoint() {
- return (JhcEndpoint) super.getEndpoint();
+ return (JhcEndpoint)super.getEndpoint();
}
protected void doStart() throws Exception {
- super.doStart();
+ super.doStart();
engine.register(handler.getPath() + "*", handler);
- if(! engine.isStarted()) {
+ if (!engine.isStarted()) {
engine.start();
}
}
@@ -98,7 +81,8 @@
class MyHttpRequestHandler implements HttpRequestHandler {
- public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext) throws HttpException, IOException {
+ public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
LOG.debug("handle");
}
}
@@ -137,37 +121,40 @@
}
-
class MyHandler implements AsyncHttpRequestHandler {
private final HttpParams params;
private final HttpResponseFactory responseFactory;
private final String path;
-
+
public MyHandler(HttpParams params, String path) {
this(params, path, new DefaultHttpResponseFactory());
}
+
public MyHandler(HttpParams params, String path, HttpResponseFactory responseFactory) {
this.params = params;
this.path = path;
this.responseFactory = responseFactory;
}
-
+
public String getPath() {
return path;
}
- public void handle(final HttpRequest request, final HttpContext context, final AsyncResponseHandler handler) throws HttpException, IOException {
+
+ public void handle(final HttpRequest request, final HttpContext context,
+ final AsyncResponseHandler handler) throws HttpException, IOException {
final Exchange exchange = getEndpoint().createExchange();
exchange.getIn().setHeader("http.uri", request.getRequestLine().getUri());
if (request instanceof HttpEntityEnclosingRequest) {
- exchange.getIn().setBody(((HttpEntityEnclosingRequest) request).getEntity());
+ exchange.getIn().setBody(((HttpEntityEnclosingRequest)request).getEntity());
}
getAsyncProcessor().process(exchange, new AsyncCallback() {
public void done(boolean doneSynchronously) {
LOG.debug("handleExchange");
// create the default response to this request
ProtocolVersion httpVersion = (HttpVersion)request.getRequestLine().getProtocolVersion();
-
- HttpResponse response = responseFactory.newHttpResponse(httpVersion, HttpStatus.SC_OK, context);
+
+ HttpResponse response = responseFactory.newHttpResponse(httpVersion, HttpStatus.SC_OK,
+ context);
HttpParamsLinker.link(response, params);
HttpEntity entity = exchange.getOut().getBody(HttpEntity.class);
response.setEntity(entity);
@@ -179,11 +166,13 @@
}
}
});
-
+
}
- public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
+
+ public void handle(HttpRequest request, HttpResponse response, HttpContext context)
+ throws HttpException, IOException {
// now we just handler the requset async, do nothing here
-
+
}
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java Tue Mar 25 00:49:12 2008
@@ -16,15 +16,15 @@
*/
package org.apache.camel.component.jhc;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
import org.apache.camel.Converter;
import org.apache.http.HttpEntity;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
/**
* Created by IntelliJ IDEA.
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java Tue Mar 25 00:49:12 2008
@@ -16,15 +16,14 @@
*/
package org.apache.camel.component.jhc;
+import java.net.URI;
+
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
import org.apache.http.params.BasicHttpParams;
-
-import java.net.URI;
+import org.apache.http.params.HttpParams;
/**
* Created by IntelliJ IDEA.
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java Tue Mar 25 00:49:12 2008
@@ -19,5 +19,5 @@
import org.apache.camel.impl.DefaultMessage;
public class JhcMessage extends DefaultMessage {
-
+
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java Tue Mar 25 00:49:12 2008
@@ -71,14 +71,15 @@
* To change this template use File | Settings | File Templates.
*/
public class JhcProducer extends DefaultProducer<JhcExchange> implements AsyncProcessor {
-
- private static Log LOG = LogFactory.getLog(JhcProducer.class);
-
- private static final String HTTP_RESPONSE_CODE = "http.responseCode";
- // This should be a set of lower-case strings
+ public static final String HTTP_RESPONSE_CODE = "http.responseCode";
+ // This should be a set of lower-case strings
public static final Set<String> HEADERS_TO_SKIP = new HashSet<String>(Arrays.asList(
- "content-length", "content-type", HTTP_RESPONSE_CODE.toLowerCase()));
-
+ "content-length", "content-type", HTTP_RESPONSE_CODE.toLowerCase()));
+
+ private static final Log LOG = LogFactory.getLog(JhcProducer.class);
+
+
+
private int nbThreads = 2;
private ConnectingIOReactor ioReactor;
private ThreadFactory threadFactory;
@@ -161,7 +162,7 @@
req = new BasicHttpEntityEnclosingRequest("POST", getEndpoint().getPath());
((BasicHttpEntityEnclosingRequest)req).setEntity(entity);
}
-
+
// propagate headers as HTTP headers
for (String headerName : exchange.getIn().getHeaders().keySet()) {
String headerValue = exchange.getIn().getHeader(headerName, String.class);
@@ -169,7 +170,7 @@
req.addHeader(headerName, headerValue);
}
}
-
+
return req;
}
@@ -207,7 +208,7 @@
}
return true;
}
-
+
static class MySessionRequestCallback implements SessionRequestCallback {
public void completed(SessionRequest sessionRequest) {
@@ -237,8 +238,8 @@
class MyHttpRequestExecutionHandler implements HttpRequestExecutionHandler {
- private final static String REQUEST_SENT = "request-sent";
- private final static String RESPONSE_RECEIVED = "response-received";
+ private static final String REQUEST_SENT = "request-sent";
+ private static final String RESPONSE_RECEIVED = "response-received";
public void initalizeContext(HttpContext httpContext, Object o) {
if (LOG.isDebugEnabled()) {
@@ -280,7 +281,7 @@
public void finalizeContext(HttpContext arg0) {
// TODO Auto-generated method stub
-
+
}
}
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngine.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngine.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngine.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngine.java Tue Mar 25 00:49:12 2008
@@ -38,70 +38,70 @@
import org.apache.http.util.concurrent.ThreadFactory;
public class JhcServerEngine {
- private static Log LOG = LogFactory.getLog(JhcServerEngine.class);
+ private static final Log LOG = LogFactory.getLog(JhcServerEngine.class);
private final HttpParams params;
private int port;
private String protocol;
private int nbThreads = 2;
private ListeningIOReactor ioReactor;
private ThreadFactory threadFactory;
- private Thread runner;
- private SSLContext sslContext;
+ private Thread runner;
+ private SSLContext sslContext;
private AsyncBufferingHttpServiceHandler serviceHandler;
private HttpRequestHandlerRegistry handlerRegistry;
private boolean isStarted;
private int referenceCounter;
-
+
JhcServerEngine(HttpParams params, int port, String protocol) {
this.params = params;
- serviceHandler = new AsyncBufferingHttpServiceHandler(params);
+ serviceHandler = new AsyncBufferingHttpServiceHandler(params);
handlerRegistry = new HttpRequestHandlerRegistry();
serviceHandler.setHandlerResolver(handlerRegistry);
this.port = port;
this.protocol = protocol;
}
-
-
+
+
public int getPort() {
return port;
}
-
+
public String getProtocol() {
return this.protocol;
}
-
+
public void setSslContext(SSLContext sslContext) {
this.sslContext = sslContext;
}
-
+
public SSLContext getSslContext() {
return this.sslContext;
}
-
+
public synchronized void register(String pattern, AsyncHttpRequestHandler handler) {
handlerRegistry.register(pattern, handler);
- referenceCounter ++;
+ referenceCounter++;
}
-
+
public synchronized void unregister(String pattern) {
handlerRegistry.unregister(pattern);
- referenceCounter --;
+ referenceCounter--;
}
-
+
public int getReferenceCounter() {
return referenceCounter;
}
-
+
public boolean isStarted() {
return isStarted;
}
-
+
public void start() throws IOReactorException {
- final SocketAddress addr = new InetSocketAddress(port);
+ final SocketAddress addr = new InetSocketAddress(port);
ioReactor = new DefaultListeningIOReactor(nbThreads, threadFactory, params);
final IOEventDispatch ioEventDispatch;
- if ("https".equals(protocol)) {
+ if ("https".equals(protocol)) {
ioEventDispatch = new SSLServerIOEventDispatch(serviceHandler, sslContext, params);
} else {
ioEventDispatch = new DefaultServerIOEventDispatch(serviceHandler, params);
@@ -111,7 +111,7 @@
try {
ioReactor.listen(addr);
isStarted = true;
- ioReactor.execute(ioEventDispatch);
+ ioReactor.execute(ioEventDispatch);
} catch (InterruptedIOException ex) {
LOG.info("Interrupted");
} catch (IOException e) {
@@ -122,7 +122,7 @@
};
runner.start();
}
-
+
public void stop() throws IOException {
LOG.debug("Stopping the jhc ioReactor ");
ioReactor.shutdown();
Modified: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngineFactory.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngineFactory.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngineFactory.java (original)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcServerEngineFactory.java Tue Mar 25 00:49:12 2008
@@ -20,20 +20,24 @@
import java.util.Map;
import org.apache.http.params.HttpParams;
-public class JhcServerEngineFactory {
- private static Map<Integer, JhcServerEngine> portMap =
- new HashMap<Integer, JhcServerEngine>();
-
- public synchronized static JhcServerEngine getJhcServerEngine(HttpParams params, int port, String protocol) {
+public final class JhcServerEngineFactory {
+
+ private static Map<Integer, JhcServerEngine> portMap = new HashMap<Integer, JhcServerEngine>();
+
+ private JhcServerEngineFactory() {
+ //Utility Class
+ }
+
+ public static synchronized JhcServerEngine getJhcServerEngine(final HttpParams params, final int port, final String protocol) {
JhcServerEngine engine = portMap.get(port);
- // check the engine parament
+ // check the engine parament
if (engine == null) {
engine = new JhcServerEngine(params, port, protocol.trim());
portMap.put(port, engine);
} else {
if (!engine.getProtocol().equals(protocol.trim())) {
- throw new IllegalArgumentException("Jhc protocol error, the engine's protocol is " + engine.getProtocol()
- + " you want is " + protocol);
+ throw new IllegalArgumentException("Jhc protocol error, the engine's protocol is "
+ + engine.getProtocol() + " you want is " + protocol);
}
}
return engine;
Modified: activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java (original)
+++ activemq/camel/trunk/components/camel-jing/src/main/java/org/apache/camel/component/validator/jing/JingComponent.java Tue Mar 25 00:49:12 2008
@@ -16,13 +16,13 @@
*/
package org.apache.camel.component.validator.jing;
+import java.util.Map;
+
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.component.ResourceBasedComponent;
import org.apache.camel.impl.ProcessorEndpoint;
import org.springframework.core.io.Resource;
-
-import java.util.Map;
/**
* A component for validating XML payloads using the
Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/EndpointMessageListener.java Tue Mar 25 00:49:12 2008
@@ -69,8 +69,7 @@
if (out != null && !disableReplyTo) {
sendReply(replyDestination, message, exchange, out);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeCamelException(e);
}
}
Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java Tue Mar 25 00:49:12 2008
@@ -35,6 +35,8 @@
import javax.jms.TextMessage;
import javax.xml.transform.TransformerException;
+import org.w3c.dom.Node;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.converter.jaxp.XmlConverter;
@@ -43,7 +45,8 @@
import org.apache.camel.util.ObjectHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Node;
+
+
/**
* A Strategy used to convert between a Camel {@JmsExchange} and {@JmsMessage}
@@ -65,27 +68,21 @@
public Object extractBodyFromJms(Exchange exchange, Message message) {
try {
if (message instanceof ObjectMessage) {
- ObjectMessage objectMessage = (ObjectMessage) message;
+ ObjectMessage objectMessage = (ObjectMessage)message;
return objectMessage.getObject();
- }
- else if (message instanceof TextMessage) {
- TextMessage textMessage = (TextMessage) message;
+ } else if (message instanceof TextMessage) {
+ TextMessage textMessage = (TextMessage)message;
return textMessage.getText();
- }
- else if (message instanceof MapMessage) {
- return createMapFromMapMessage((MapMessage) message);
- }
- else if (message instanceof BytesMessage) {
+ } else if (message instanceof MapMessage) {
+ return createMapFromMapMessage((MapMessage)message);
+ } else if (message instanceof BytesMessage) {
return createByteArrayFromBytesMessage((BytesMessage)message);
- }
- else if (message instanceof StreamMessage) {
+ } else if (message instanceof StreamMessage) {
return message;
- }
- else {
+ } else {
return null;
}
- }
- catch (JMSException e) {
+ } catch (JMSException e) {
throw new RuntimeJmsException("Failed to extract body due to: " + e + ". Message: " + message, e);
}
}
@@ -94,7 +91,7 @@
if (message.getBodyLength() > Integer.MAX_VALUE) {
return null;
}
- byte[] result = new byte[(int) message.getBodyLength()];
+ byte[] result = new byte[(int)message.getBodyLength()];
message.readBytes(result);
return result;
}
@@ -117,10 +114,11 @@
* @return a newly created JMS Message instance containing the
* @throws JMSException if the message could not be created
*/
- public Message makeJmsMessage(Exchange exchange, org.apache.camel.Message camelMessage, Session session) throws JMSException {
+ public Message makeJmsMessage(Exchange exchange, org.apache.camel.Message camelMessage, Session session)
+ throws JMSException {
Message answer = null;
if (camelMessage instanceof JmsMessage) {
- JmsMessage jmsMessage = (JmsMessage) camelMessage;
+ JmsMessage jmsMessage = (JmsMessage)camelMessage;
answer = jmsMessage.getJmsMessage();
}
if (answer == null) {
@@ -136,11 +134,12 @@
public void appendJmsProperties(Message jmsMessage, Exchange exchange) throws JMSException {
appendJmsProperties(jmsMessage, exchange, exchange.getIn());
}
-
+
/**
* Appends the JMS headers from the Camel {@link JmsMessage}
*/
- public void appendJmsProperties(Message jmsMessage, Exchange exchange, org.apache.camel.Message in) throws JMSException {
+ public void appendJmsProperties(Message jmsMessage, Exchange exchange, org.apache.camel.Message in)
+ throws JMSException {
Set<Map.Entry<String, Object>> entries = in.getHeaders().entrySet();
for (Map.Entry<String, Object> entry : entries) {
String headerName = entry.getKey();
@@ -148,69 +147,69 @@
if (headerName.startsWith("JMS") && !headerName.startsWith("JMSX")) {
if (headerName.equals("JMSCorrelationID")) {
- jmsMessage.setJMSCorrelationID(ExchangeHelper.convertToType(exchange, String.class, headerValue));
- }
- else if (headerName.equals("JMSCorrelationID")) {
- jmsMessage.setJMSCorrelationID(ExchangeHelper.convertToType(exchange, String.class, headerValue));
- }
- else if (headerName.equals("JMSReplyTo")) {
- jmsMessage.setJMSReplyTo(ExchangeHelper.convertToType(exchange, Destination.class, headerValue));
- }
- else if (headerName.equals("JMSType")) {
+ jmsMessage.setJMSCorrelationID(ExchangeHelper.convertToType(exchange, String.class,
+ headerValue));
+ } else if (headerName.equals("JMSCorrelationID")) {
+ jmsMessage.setJMSCorrelationID(ExchangeHelper.convertToType(exchange, String.class,
+ headerValue));
+ } else if (headerName.equals("JMSReplyTo")) {
+ jmsMessage.setJMSReplyTo(ExchangeHelper.convertToType(exchange, Destination.class,
+ headerValue));
+ } else if (headerName.equals("JMSType")) {
jmsMessage.setJMSType(ExchangeHelper.convertToType(exchange, String.class, headerValue));
- }
- else if (LOG.isDebugEnabled()) {
+ } else if (LOG.isDebugEnabled()) {
// The following properties are set by the MessageProducer
- // JMSDeliveryMode, JMSDestination, JMSExpiration, JMSPriority,
+ // JMSDeliveryMode, JMSDestination, JMSExpiration,
+ // JMSPriority,
// The following are set on the underlying JMS provider
- // JMSMessageID, JMSTimestamp, JMSRedelivered
+ // JMSMessageID, JMSTimestamp, JMSRedelivered
LOG.debug("Ignoring JMS header: " + headerName + " with value: " + headerValue);
}
- }
- else if (shouldOutputHeader(in, headerName, headerValue)) {
+ } else if (shouldOutputHeader(in, headerName, headerValue)) {
jmsMessage.setObjectProperty(headerName, headerValue);
}
}
}
- protected Message createJmsMessage(Object body, Session session, CamelContext context) throws JMSException {
+ protected Message createJmsMessage(Object body, Session session, CamelContext context)
+ throws JMSException {
if (body instanceof Node) {
// lets convert the document to a String format
try {
- body = xmlConverter.toString((Node) body);
- }
- catch (TransformerException e) {
+ body = xmlConverter.toString((Node)body);
+ } catch (TransformerException e) {
JMSException jmsException = new JMSException(e.getMessage());
jmsException.setLinkedException(e);
- throw jmsException;
+ throw jmsException;
}
}
if (body instanceof byte[]) {
BytesMessage result = session.createBytesMessage();
- result.writeBytes((byte[]) body);
+ result.writeBytes((byte[])body);
return result;
}
if (body instanceof Map) {
MapMessage result = session.createMapMessage();
- Map<?, ?> map = (Map<?, ?>) body;
+ Map<?, ?> map = (Map<?, ?>)body;
try {
populateMapMessage(result, map, context);
return result;
} catch (JMSException e) {
- // if MapMessage creation failed then fall back to Object Message
+ // if MapMessage creation failed then fall back to Object
+ // Message
}
}
if (body instanceof String) {
- return session.createTextMessage((String) body);
+ return session.createTextMessage((String)body);
}
if (body instanceof Serializable) {
- return session.createObjectMessage((Serializable) body);
+ return session.createObjectMessage((Serializable)body);
}
return session.createMessage();
}
/**
- * Populates a {@link MapMessage} from a {@link Map} instance.
+ * Populates a {@link MapMessage} from a {@link Map} instance.
*/
protected void populateMapMessage(MapMessage message, Map<?, ?> map, CamelContext context)
throws JMSException {
@@ -251,22 +250,21 @@
/**
* Strategy to allow filtering of headers which are put on the JMS message
*/
- protected boolean shouldOutputHeader(org.apache.camel.Message camelMessage, String headerName, Object headerValue) {
- return headerValue != null && !getIgnoreJmsHeaders().contains(headerName) && ObjectHelper.isJavaIdentifier(headerName);
+ protected boolean shouldOutputHeader(org.apache.camel.Message camelMessage, String headerName,
+ Object headerValue) {
+ return headerValue != null && !getIgnoreJmsHeaders().contains(headerName)
+ && ObjectHelper.isJavaIdentifier(headerName);
}
/**
- * Populate any JMS headers that should be excluded from being copied from an input message
- * onto an outgoing message
+ * Populate any JMS headers that should be excluded from being copied from
+ * an input message onto an outgoing message
*/
protected void populateIgnoreJmsHeaders(Set<String> set) {
// ignore provider specified JMS extension headers
// see page 39 of JMS 1.1 specification
- String[] ignore = {
- "JMSXUserID", "JMSXAppID",
- "JMSXDeliveryCount", "JMSXProducerTXID", "JMSXConsumerTXID",
- "JMSXRcvTimestamp", "JMSXState"
- };
+ String[] ignore = {"JMSXUserID", "JMSXAppID", "JMSXDeliveryCount", "JMSXProducerTXID",
+ "JMSXConsumerTXID", "JMSXRcvTimestamp", "JMSXState"};
set.addAll(Arrays.asList(ignore));
}
}
Modified: activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java?rev=640731&r1=640730&r2=640731&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsComponent.java Tue Mar 25 00:49:12 2008
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.jms;
+
import java.util.Map;
import javax.jms.ConnectionFactory;
@@ -26,7 +27,7 @@
import org.apache.camel.Endpoint;
import org.apache.camel.component.jms.requestor.Requestor;
import org.apache.camel.impl.DefaultComponent;
-import static org.apache.camel.util.ObjectHelper.removeStartingCharacters;
+
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -37,6 +38,8 @@
import org.springframework.jms.support.converter.MessageConverter;
import org.springframework.jms.support.destination.DestinationResolver;
import org.springframework.transaction.PlatformTransactionManager;
+import static org.apache.camel.util.ObjectHelper.removeStartingCharacters;
+
/**
* A <a href="http://activemq.apache.org/jms.html">JMS Component</a>
@@ -119,7 +122,7 @@
if (configuration == null) {
configuration = createConfiguration();
- // If we are being configured with spring...
+ // If we are being configured with spring...
if (applicationContext != null) {
Map beansOfType = applicationContext.getBeansOfType(ConnectionFactory.class);
if (!beansOfType.isEmpty()) {
@@ -323,8 +326,7 @@
if (remaining.startsWith(QUEUE_PREFIX)) {
pubSubDomain = false;
remaining = removeStartingCharacters(remaining.substring(QUEUE_PREFIX.length()), '/');
- }
- else if (remaining.startsWith(TOPIC_PREFIX)) {
+ } else if (remaining.startsWith(TOPIC_PREFIX)) {
pubSubDomain = true;
remaining = removeStartingCharacters(remaining.substring(TOPIC_PREFIX.length()), '/');
}
@@ -337,12 +339,11 @@
JmsEndpoint endpoint;
if (pubSubDomain) {
endpoint = new JmsEndpoint(uri, this, subject, pubSubDomain, newConfiguration);
- }
- else {
+ } else {
endpoint = new JmsQueueEndpoint(uri, this, subject, newConfiguration);
}
- String selector = (String) parameters.remove("selector");
+ String selector = (String)parameters.remove("selector");
if (selector != null) {
endpoint.setSelector(selector);
}