You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ch...@apache.org on 2007/08/07 23:33:12 UTC
svn commit: r563665 [3/11] - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/converter/jaxp/
camel-core/src/test/java/org/apache/camel/processor/
components/camel-activemq/src/main/java/org/apache/camel/component/activemq/
component...
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java Tue Aug 7 14:33:00 2007
@@ -1,23 +1,25 @@
/**
- * 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
+ * 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
+ * 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.
+ * 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.cxf.transport;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.message.Exchange;
@@ -27,11 +29,8 @@
import org.apache.cxf.transport.Conduit;
import org.apache.cxf.transport.ConduitInitiator;
import org.apache.cxf.transport.MessageObserver;
-import org.easymock.classextension.EasyMock;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import org.easymock.classextension.EasyMock;
public class CamelDestinationTest extends CamelTestSupport {
private Message destMessage;
@@ -41,8 +40,7 @@
while (inMessage == null && waitTime < 3000) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
// do nothing here
}
waitTime = waitTime + 1000;
@@ -55,8 +53,7 @@
while (destMessage == null && waitTime < 3000) {
try {
Thread.sleep(1000);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
// do nothing here
}
waitTime = waitTime + 1000;
@@ -87,43 +84,36 @@
BusFactory.setDefaultBus(null);
bus = bf.createBus("/wsdl/camel_test_config.xml");
BusFactory.setDefaultBus(bus);
- setupServiceInfo("http://cxf.apache.org/camel_conf_test",
- "/wsdl/camel_test_no_addr.wsdl",
- "HelloWorldQueueBinMsgService",
- "HelloWorldQueueBinMsgPort");
+ setupServiceInfo("http://cxf.apache.org/camel_conf_test", "/wsdl/camel_test_no_addr.wsdl", "HelloWorldQueueBinMsgService", "HelloWorldQueueBinMsgPort");
CamelDestination destination = setupCamelDestination(false);
- /*assertEquals("Can't get the right ServerConfig's MessageTimeToLive ",
- 500L,
- destination.getServerConfig().getMessageTimeToLive());
-assertEquals("Can't get the right Server's MessageSelector",
- "cxf_message_selector",
- destination.getRuntimePolicy().getMessageSelector());
-assertEquals("Can't get the right SessionPoolConfig's LowWaterMark",
- 10,
- destination.getSessionPool().getLowWaterMark());
-assertEquals("Can't get the right AddressPolicy's ConnectionPassword",
- "testPassword",
- destination.getCamelAddress().getConnectionPassword());*/
+ /*
+ * assertEquals("Can't get the right ServerConfig's MessageTimeToLive ",
+ * 500L, destination.getServerConfig().getMessageTimeToLive());
+ * assertEquals("Can't get the right Server's MessageSelector",
+ * "cxf_message_selector",
+ * destination.getRuntimePolicy().getMessageSelector());
+ * assertEquals("Can't get the right SessionPoolConfig's LowWaterMark",
+ * 10, destination.getSessionPool().getLowWaterMark());
+ * assertEquals("Can't get the right AddressPolicy's
+ * ConnectionPassword", "testPassword",
+ * destination.getCamelAddress().getConnectionPassword());
+ */
BusFactory.setDefaultBus(null);
}
public void testOneWayDestination() throws Exception {
destMessage = null;
inMessage = null;
- setupServiceInfo("http://cxf.apache.org/hello_world_camel",
- "/wsdl/camel_test.wsdl",
- "HWStaticReplyQBinMsgService",
- "HWStaticReplyQBinMsgPort");
+ setupServiceInfo("http://cxf.apache.org/hello_world_camel", "/wsdl/camel_test.wsdl", "HWStaticReplyQBinMsgService", "HWStaticReplyQBinMsgPort");
CamelConduit conduit = setupCamelConduit(true, false);
Message outMessage = new MessageImpl();
setupMessageHeader(outMessage);
CamelDestination destination = null;
try {
destination = setupCamelDestination(true);
- //destination.activate();
- }
- catch (IOException e) {
+ // destination.activate();
+ } catch (IOException e) {
assertFalse("The CamelDestination activate should not through exception ", false);
e.printStackTrace();
}
@@ -138,24 +128,21 @@
}
private void setupMessageHeader(Message outMessage) {
-/*
- CamelMessageHeadersType header = new CamelMessageHeadersType();
- header.setCamelCorrelationID("Destination test");
- header.setCamelDeliveryMode(3);
- header.setCamelPriority(1);
- header.setTimeToLive(1000);
- outMessage.put(CamelConstants.Camel_CLIENT_REQUEST_HEADERS, header);
-*/
+ /*
+ * CamelMessageHeadersType header = new CamelMessageHeadersType();
+ * header.setCamelCorrelationID("Destination test");
+ * header.setCamelDeliveryMode(3); header.setCamelPriority(1);
+ * header.setTimeToLive(1000);
+ * outMessage.put(CamelConstants.Camel_CLIENT_REQUEST_HEADERS, header);
+ */
}
private void verifyReceivedMessage(Message inMessage) {
- ByteArrayInputStream bis =
- (ByteArrayInputStream) inMessage.getContent(InputStream.class);
+ ByteArrayInputStream bis = (ByteArrayInputStream)inMessage.getContent(InputStream.class);
byte bytes[] = new byte[bis.available()];
try {
bis.read(bytes);
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
assertFalse("Read the Destination recieved Message error ", false);
ex.printStackTrace();
}
@@ -164,56 +151,49 @@
}
private void verifyRequestResponseHeaders(Message inMessage, Message outMessage) {
-/*
- CamelMessageHeadersType outHeader =
- (CamelMessageHeadersType)outMessage.get(CamelConstants.Camel_CLIENT_REQUEST_HEADERS);
-
- CamelMessageHeadersType inHeader =
- (CamelMessageHeadersType)inMessage.get(CamelConstants.Camel_CLIENT_RESPONSE_HEADERS);
-
- verifyJmsHeaderEquality(outHeader, inHeader);
-*/
+ /*
+ * CamelMessageHeadersType outHeader =
+ * (CamelMessageHeadersType)outMessage.get(CamelConstants.Camel_CLIENT_REQUEST_HEADERS);
+ * CamelMessageHeadersType inHeader =
+ * (CamelMessageHeadersType)inMessage.get(CamelConstants.Camel_CLIENT_RESPONSE_HEADERS);
+ * verifyJmsHeaderEquality(outHeader, inHeader);
+ */
}
private void verifyHeaders(Message inMessage, Message outMessage) {
-/*
- CamelMessageHeadersType outHeader =
- (CamelMessageHeadersType)outMessage.get(CamelConstants.Camel_CLIENT_REQUEST_HEADERS);
-
- CamelMessageHeadersType inHeader =
- (CamelMessageHeadersType)inMessage.get(CamelConstants.Camel_SERVER_REQUEST_HEADERS);
- verifyJmsHeaderEquality(outHeader, inHeader);
-*/
+ /*
+ * CamelMessageHeadersType outHeader =
+ * (CamelMessageHeadersType)outMessage.get(CamelConstants.Camel_CLIENT_REQUEST_HEADERS);
+ * CamelMessageHeadersType inHeader =
+ * (CamelMessageHeadersType)inMessage.get(CamelConstants.Camel_SERVER_REQUEST_HEADERS);
+ * verifyJmsHeaderEquality(outHeader, inHeader);
+ */
}
/*
- private void verifyJmsHeaderEquality(CamelMessageHeadersType outHeader, CamelMessageHeadersType inHeader) {
- assertEquals("The inMessage and outMessage Camel Header's CorrelationID should be equals",
- outHeader.getCamelCorrelationID(), inHeader.getCamelCorrelationID());
- assertEquals("The inMessage and outMessage Camel Header's CamelPriority should be equals",
- outHeader.getCamelPriority(), inHeader.getCamelPriority());
- assertEquals("The inMessage and outMessage Camel Header's CamelType should be equals",
- outHeader.getCamelType(), inHeader.getCamelType());
-
- }
-
- */
+ * private void verifyJmsHeaderEquality(CamelMessageHeadersType outHeader,
+ * CamelMessageHeadersType inHeader) { assertEquals("The inMessage and
+ * outMessage Camel Header's CorrelationID should be equals",
+ * outHeader.getCamelCorrelationID(), inHeader.getCamelCorrelationID());
+ * assertEquals("The inMessage and outMessage Camel Header's CamelPriority
+ * should be equals", outHeader.getCamelPriority(),
+ * inHeader.getCamelPriority()); assertEquals("The inMessage and outMessage
+ * Camel Header's CamelType should be equals", outHeader.getCamelType(),
+ * inHeader.getCamelType()); }
+ */
public void testRoundTripDestination() throws Exception {
inMessage = null;
- setupServiceInfo("http://cxf.apache.org/hello_world_camel",
- "/wsdl/camel_test.wsdl",
- "HelloWorldService",
- "HelloWorldPort");
- //set up the conduit send to be true
+ setupServiceInfo("http://cxf.apache.org/hello_world_camel", "/wsdl/camel_test.wsdl", "HelloWorldService", "HelloWorldPort");
+ // set up the conduit send to be true
CamelConduit conduit = setupCamelConduit(true, false);
final Message outMessage = new MessageImpl();
setupMessageHeader(outMessage);
final CamelDestination destination = setupCamelDestination(true);
- //set up MessageObserver for handlering the conduit message
+ // set up MessageObserver for handlering the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
Exchange exchange = new ExchangeImpl();
@@ -221,24 +201,23 @@
m.setExchange(exchange);
verifyReceivedMessage(m);
verifyHeaders(m, outMessage);
- //setup the message for
+ // setup the message for
Conduit backConduit;
try {
backConduit = destination.getBackChannel(m, null, null);
- //wait for the message to be got from the conduit
+ // wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendoutMessage(backConduit, replyMessage, true);
- }
- catch (Exception e) {
+ } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
destination.setMessageObserver(observer);
- //set is oneway false for get response from destination
+ // set is oneway false for get response from destination
sendoutMessage(conduit, outMessage, false);
- //wait for the message to be got from the destination,
+ // wait for the message to be got from the destination,
// create the thread to handler the Destination incomming message
waitForReceiveInMessage();
@@ -250,32 +229,27 @@
public void testPropertyExclusion() throws Exception {
- final String customPropertyName =
- "THIS_PROPERTY_WILL_NOT_BE_AUTO_COPIED";
+ final String customPropertyName = "THIS_PROPERTY_WILL_NOT_BE_AUTO_COPIED";
inMessage = null;
- setupServiceInfo("http://cxf.apache.org/hello_world_camel",
- "/wsdl/camel_test.wsdl",
- "HelloWorldService",
- "HelloWorldPort");
- //set up the conduit send to be true
+ setupServiceInfo("http://cxf.apache.org/hello_world_camel", "/wsdl/camel_test.wsdl", "HelloWorldService", "HelloWorldPort");
+ // set up the conduit send to be true
CamelConduit conduit = setupCamelConduit(true, false);
final Message outMessage = new MessageImpl();
setupMessageHeader(outMessage);
-/*
- CamelPropertyType excludeProp = new CamelPropertyType();
- excludeProp.setName(customPropertyName);
- excludeProp.setValue(customPropertyName);
-
- CamelMessageHeadersType headers = (CamelMessageHeadersType)
- outMessage.get(CamelConstants.Camel_CLIENT_REQUEST_HEADERS);
- headers.getProperty().add(excludeProp);
-*/
+ /*
+ * CamelPropertyType excludeProp = new CamelPropertyType();
+ * excludeProp.setName(customPropertyName);
+ * excludeProp.setValue(customPropertyName); CamelMessageHeadersType
+ * headers = (CamelMessageHeadersType)
+ * outMessage.get(CamelConstants.Camel_CLIENT_REQUEST_HEADERS);
+ * headers.getProperty().add(excludeProp);
+ */
final CamelDestination destination = setupCamelDestination(true);
- //set up MessageObserver for handlering the conduit message
+ // set up MessageObserver for handlering the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
Exchange exchange = new ExchangeImpl();
@@ -283,24 +257,23 @@
m.setExchange(exchange);
verifyReceivedMessage(m);
verifyHeaders(m, outMessage);
- //setup the message for
+ // setup the message for
Conduit backConduit;
try {
backConduit = destination.getBackChannel(m, null, null);
- //wait for the message to be got from the conduit
+ // wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendoutMessage(backConduit, replyMessage, true);
- }
- catch (Exception e) {
+ } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
destination.setMessageObserver(observer);
- //set is oneway false for get response from destination
+ // set is oneway false for get response from destination
sendoutMessage(conduit, outMessage, false);
- //wait for the message to be got from the destination,
+ // wait for the message to be got from the destination,
// create the thread to handler the Destination incomming message
waitForReceiveInMessage();
@@ -308,11 +281,12 @@
verifyRequestResponseHeaders(inMessage, outMessage);
-/*
- CamelMessageHeadersType inHeader =
- (CamelMessageHeadersType)inMessage.get(CamelConstants.Camel_CLIENT_RESPONSE_HEADERS);
- assertTrue("property has been excluded", inHeader.getProperty().isEmpty());
-*/
+ /*
+ * CamelMessageHeadersType inHeader =
+ * (CamelMessageHeadersType)inMessage.get(CamelConstants.Camel_CLIENT_RESPONSE_HEADERS);
+ * assertTrue("property has been excluded",
+ * inHeader.getProperty().isEmpty());
+ */
// wait for a while for the camel session recycling
Thread.sleep(1000);
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelTestSupport.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelTestSupport.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelTestSupport.java Tue Aug 7 14:33:00 2007
@@ -1,24 +1,30 @@
/**
- * 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
+ * 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
+ * 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.
+ * 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.cxf.transport;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
import junit.framework.TestCase;
+
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.cxf.Bus;
@@ -33,13 +39,8 @@
import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.apache.cxf.wsdl11.WSDLServiceFactory;
-import org.easymock.classextension.EasyMock;
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.List;
+import org.easymock.classextension.EasyMock;
public abstract class CamelTestSupport extends TestCase {
protected CamelContext camelContext = new DefaultCamelContext();
@@ -88,8 +89,7 @@
exchange.setInMessage(message);
try {
conduit.prepare(message);
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
assertFalse("CamelConduit can't perpare to send out message", false);
ex.printStackTrace();
}
@@ -102,8 +102,7 @@
protected CamelConduit setupCamelConduit(boolean send, boolean decoupled) {
if (decoupled) {
// setup the reference type
- }
- else {
+ } else {
target = EasyMock.createMock(EndpointReferenceType.class);
}
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpConsumer.java Tue Aug 7 14:33:00 2007
@@ -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,18 +16,18 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.Processor;
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPFile;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService;
+import org.apache.camel.Processor;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+
public class FtpConsumer extends RemoteFileConsumer<RemoteFileExchange> {
private boolean recursive = true;
private String regexPattern = "";
- private long lastPollTime = 0L;
+ private long lastPollTime;
private final FtpEndpoint endpoint;
private FTPClient client;
@@ -48,8 +47,7 @@
final String fileName = endpoint.getConfiguration().getFile();
if (endpoint.getConfiguration().isDirectory()) {
pollDirectory(fileName);
- }
- else {
+ } else {
client.changeWorkingDirectory(fileName.substring(0, fileName.lastIndexOf('/')));
final FTPFile[] files = client.listFiles(fileName.substring(fileName.lastIndexOf('/') + 1));
pollFile(files[0]);
@@ -62,13 +60,11 @@
for (FTPFile ftpFile : client.listFiles()) {
if (ftpFile.isFile()) {
pollFile(ftpFile);
- }
- else if (ftpFile.isDirectory()) {
+ } else if (ftpFile.isDirectory()) {
if (isRecursive()) {
pollDirectory(getFullFileName(ftpFile));
}
- }
- else {
+ } else {
throw new RuntimeException("");
}
}
@@ -79,7 +75,15 @@
}
private void pollFile(FTPFile ftpFile) throws Exception {
- if (ftpFile.getTimestamp().getTimeInMillis() > lastPollTime) { // TODO do we need to adjust the TZ? can we?
+ if (ftpFile.getTimestamp().getTimeInMillis() > lastPollTime) { // TODO
+ // do we
+ // need
+ // to
+ // adjust
+ // the
+ // TZ?
+ // can
+ // we?
if (isMatched(ftpFile)) {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
client.retrieveFile(ftpFile.getName(), byteArrayOutputStream);
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpEndpoint.java Tue Aug 7 14:33:00 2007
@@ -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,15 +16,15 @@
*/
package org.apache.camel.component.file.remote;
+import java.io.IOException;
+
import org.apache.camel.Processor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.net.ftp.FTPClient;
-import java.io.IOException;
-
public class FtpEndpoint extends RemoteFileEndpoint<RemoteFileExchange> {
- private static final transient Log log = LogFactory.getLog(FtpEndpoint.class);
+ private static final transient Log LOG = LogFactory.getLog(FtpEndpoint.class);
public FtpEndpoint(String uri, RemoteFileComponent remoteFileComponent, RemoteFileConfiguration configuration) {
super(uri, remoteFileComponent, configuration);
@@ -46,7 +45,7 @@
RemoteFileConfiguration config = getConfiguration();
String host = config.getHost();
int port = config.getPort();
- log.debug("Connecting to host: " + host + " port: " + port);
+ LOG.debug("Connecting to host: " + host + " port: " + port);
client.connect(host, port);
client.login(config.getUsername(), config.getPassword());
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperationFailedException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperationFailedException.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperationFailedException.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperationFailedException.java Tue Aug 7 14:33:00 2007
@@ -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-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpProducer.java Tue Aug 7 14:33:00 2007
@@ -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,13 +16,13 @@
*/
package org.apache.camel.component.file.remote;
+import java.io.IOException;
+import java.io.InputStream;
+
import org.apache.camel.Exchange;
import org.apache.camel.RuntimeCamelException;
import org.apache.commons.net.ftp.FTPClient;
-import java.io.IOException;
-import java.io.InputStream;
-
public class FtpProducer extends RemoteFileProducer<RemoteFileExchange> {
FtpEndpoint endpoint;
private final FTPClient client;
@@ -42,24 +41,22 @@
final String fileName;
InputStream payload = exchange.getIn().getBody(InputStream.class);
final String endpointFile = endpoint.getConfiguration().getFile();
- client.changeWorkingDirectory(endpointFile); // TODO this line might not be needed... check after finish writing unit tests
+ client.changeWorkingDirectory(endpointFile); // TODO this line might
+ // not be needed...
+ // check after finish
+ // writing unit tests
if (endpointFile == null) {
throw new NullPointerException("Null Endpoint File");
- }
- else {
+ } else {
if (endpoint.getConfiguration().isDirectory()) {
fileName = endpointFile + "/" + exchange.getIn().getMessageId();
- }
- else {
+ } else {
fileName = endpointFile;
}
}
buildDirectory(client, fileName.substring(0, fileName.lastIndexOf('/')));
final boolean success = client.storeFile(fileName, payload);
- if (success) {
-
- }
- else {
+ if (!success) {
throw new RuntimeCamelException("error sending file");
}
}
@@ -67,9 +64,11 @@
@Override
protected void doStart() throws Exception {
super.doStart();
-// client.connect(endpoint.getConfiguration().getHost());
-// client.login(endpoint.getConfiguration().getUsername(), endpoint.getConfiguration().getPassword());
-// client.setFileType(endpoint.getConfiguration().isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
+ // client.connect(endpoint.getConfiguration().getHost());
+ // client.login(endpoint.getConfiguration().getUsername(),
+ // endpoint.getConfiguration().getPassword());
+ // client.setFileType(endpoint.getConfiguration().isBinary() ?
+ // FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
}
@Override
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileBinding.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileBinding.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileBinding.java Tue Aug 7 14:33:00 2007
@@ -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-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileComponent.java Tue Aug 7 14:33:00 2007
@@ -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,14 +16,14 @@
*/
package org.apache.camel.component.file.remote;
+import java.net.URI;
+import java.util.Map;
+
import org.apache.camel.CamelContext;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.impl.DefaultComponent;
import org.apache.camel.util.IntrospectionSupport;
-import java.net.URI;
-import java.util.Map;
-
public class RemoteFileComponent extends DefaultComponent<RemoteFileExchange> {
private RemoteFileConfiguration configuration;
@@ -53,15 +52,14 @@
RemoteFileConfiguration config = getConfiguration().copy();
config.configure(new URI(uri));
- // lets make sure we copy the configuration as each endpoint can customize its own version
+ // lets make sure we copy the configuration as each endpoint can
+ // customize its own version
final RemoteFileEndpoint endpoint;
if ("ftp".equals(config.getProtocol())) {
endpoint = new FtpEndpoint(uri, this, config);
- }
- else if ("sftp".equals(config.getProtocol())) {
+ } else if ("sftp".equals(config.getProtocol())) {
endpoint = new SftpEndpoint(uri, this, config);
- }
- else {
+ } else {
throw new RuntimeCamelException("Unsupported protocol: " + config.getProtocol());
}
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConfiguration.java Tue Aug 7 14:33:00 2007
@@ -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,10 +16,10 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.RuntimeCamelException;
-
import java.net.URI;
+import org.apache.camel.RuntimeCamelException;
+
public class RemoteFileConfiguration implements Cloneable {
private String protocol;
private String username;
@@ -28,7 +27,7 @@
private int port;
private String password;
private String file;
- private boolean binary = false;
+ private boolean binary;
private boolean directory = true;
public RemoteFileConfiguration() {
@@ -40,17 +39,16 @@
public RemoteFileConfiguration copy() {
try {
- return (RemoteFileConfiguration) clone();
- }
- catch (CloneNotSupportedException e) {
+ return (RemoteFileConfiguration)clone();
+ } catch (CloneNotSupportedException e) {
throw new RuntimeCamelException(e);
}
}
public String toString() {
- return protocol + ":\\" + username + "@" + host + ":" + port + "/" + directory;
+ return protocol + ":\\" + username + "@" + host + ":" + port + "/" + directory;
}
-
+
public void configure(URI uri) {
setProtocol(uri.getScheme());
setDefaultPort();
@@ -63,8 +61,7 @@
protected void setDefaultPort() {
if ("ftp".equalsIgnoreCase(protocol)) {
setPort(21);
- }
- else if ("sftp".equalsIgnoreCase(protocol)) {
+ } else if ("sftp".equalsIgnoreCase(protocol)) {
setPort(22);
}
}
@@ -136,15 +133,7 @@
}
public String dump() {
- return "RemoteFileConfiguration{" +
- "protocol='" + protocol + '\'' +
- ", username='" + username + '\'' +
- ", host='" + host + '\'' +
- ", port=" + port +
- ", password='" + password + '\'' +
- ", file='" + file + '\'' +
- ", binary=" + binary +
- ", directory=" + directory +
- '}';
+ return "RemoteFileConfiguration{" + "protocol='" + protocol + '\'' + ", username='" + username + '\'' + ", host='" + host + '\'' + ", port=" + port + ", password='" + password + '\''
+ + ", file='" + file + '\'' + ", binary=" + binary + ", directory=" + directory + '}';
}
}
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileConsumer.java Tue Aug 7 14:33:00 2007
@@ -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,10 +16,10 @@
*/
package org.apache.camel.component.file.remote;
+import java.util.concurrent.ScheduledExecutorService;
+
import org.apache.camel.Processor;
import org.apache.camel.impl.ScheduledPollConsumer;
-
-import java.util.concurrent.ScheduledExecutorService;
public abstract class RemoteFileConsumer<T extends RemoteFileExchange> extends ScheduledPollConsumer<T> {
RemoteFileEndpoint<T> endpoint;
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java Tue Aug 7 14:33:00 2007
@@ -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,9 +16,9 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.impl.ScheduledPollEndpoint;
-
import java.io.ByteArrayOutputStream;
+
+import org.apache.camel.impl.ScheduledPollEndpoint;
public abstract class RemoteFileEndpoint<T extends RemoteFileExchange> extends ScheduledPollEndpoint<T> {
private RemoteFileBinding binding;
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileExchange.java Tue Aug 7 14:33:00 2007
@@ -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,10 +16,10 @@
*/
package org.apache.camel.component.file.remote;
+import java.io.ByteArrayOutputStream;
+
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultExchange;
-
-import java.io.ByteArrayOutputStream;
public class RemoteFileExchange<T extends RemoteFileBinding> extends DefaultExchange {
private T binding;
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileMessage.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileMessage.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileMessage.java Tue Aug 7 14:33:00 2007
@@ -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,10 +16,10 @@
*/
package org.apache.camel.component.file.remote;
-import org.apache.camel.impl.DefaultMessage;
-
import java.io.OutputStream;
import java.util.Map;
+
+import org.apache.camel.impl.DefaultMessage;
public class RemoteFileMessage extends DefaultMessage {
private OutputStream outputStream;
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java Tue Aug 7 14:33:00 2007
@@ -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-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpConsumer.java Tue Aug 7 14:33:00 2007
@@ -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,17 +16,18 @@
*/
package org.apache.camel.component.file.remote;
-import com.jcraft.jsch.ChannelSftp;
-import org.apache.camel.Processor;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.ScheduledExecutorService;
+import com.jcraft.jsch.ChannelSftp;
+
+import org.apache.camel.Processor;
+
public class SftpConsumer extends RemoteFileConsumer<RemoteFileExchange> {
private boolean recursive = true;
private String regexPattern = "";
- private long lastPollTime = 0L;
+ private long lastPollTime;
private final SftpEndpoint endpoint;
private ChannelSftp channel;
@@ -47,10 +47,9 @@
final String fileName = endpoint.getConfiguration().getFile();
if (endpoint.getConfiguration().isDirectory()) {
pollDirectory(fileName);
- }
- else {
+ } else {
channel.cd(fileName.substring(0, fileName.lastIndexOf('/')));
- final ChannelSftp.LsEntry file = (ChannelSftp.LsEntry) channel.ls(fileName.substring(fileName.lastIndexOf('/') + 1)).get(0);
+ final ChannelSftp.LsEntry file = (ChannelSftp.LsEntry)channel.ls(fileName.substring(fileName.lastIndexOf('/') + 1)).get(0);
pollFile(file);
}
lastPollTime = System.currentTimeMillis();
@@ -58,16 +57,14 @@
protected void pollDirectory(String dir) throws Exception {
channel.cd(dir);
- for (ChannelSftp.LsEntry sftpFile : (ChannelSftp.LsEntry[]) channel.ls(".").toArray(new ChannelSftp.LsEntry[]{})) {
+ for (ChannelSftp.LsEntry sftpFile : (ChannelSftp.LsEntry[])channel.ls(".").toArray(new ChannelSftp.LsEntry[] {})) {
if (sftpFile.getFilename().startsWith(".")) {
// skip
- }
- else if (sftpFile.getAttrs().isDir()) {
+ } else if (sftpFile.getAttrs().isDir()) {
if (isRecursive()) {
pollDirectory(getFullFileName(sftpFile));
}
- }
- else {
+ } else {
pollFile(sftpFile);
}
}
@@ -78,7 +75,10 @@
}
private void pollFile(ChannelSftp.LsEntry sftpFile) throws Exception {
- if (sftpFile.getAttrs().getMTime() * 1000 > lastPollTime) { // TODO do we need to adjust the TZ?
+ if (sftpFile.getAttrs().getMTime() * 1000 > lastPollTime) { // TODO do
+ // we need
+ // to adjust
+ // the TZ?
if (isMatched(sftpFile)) {
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
channel.get(sftpFile.getFilename(), byteArrayOutputStream);
@@ -119,4 +119,3 @@
this.regexPattern = regexPattern;
}
}
-
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpEndpoint.java Tue Aug 7 14:33:00 2007
@@ -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-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpProducer.java Tue Aug 7 14:33:00 2007
@@ -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,14 +16,15 @@
*/
package org.apache.camel.component.file.remote;
+import java.io.IOException;
+import java.io.InputStream;
+
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.SftpException;
+
import org.apache.camel.Exchange;
import org.apache.camel.RuntimeCamelException;
-import java.io.IOException;
-import java.io.InputStream;
-
public class SftpProducer extends RemoteFileProducer<RemoteFileExchange> {
SftpEndpoint endpoint;
private final ChannelSftp channel;
@@ -46,20 +46,17 @@
channel.cd(endpointFile);
if (endpointFile == null) {
throw new NullPointerException("Null Endpoint File");
- }
- else {
+ } else {
if (endpoint.getConfiguration().isDirectory()) {
fileName = endpointFile + "/" + exchange.getIn().getMessageId();
- }
- else {
+ } else {
fileName = endpointFile;
}
}
buildDirectory(channel, fileName.substring(0, fileName.lastIndexOf('/')));
try {
channel.put(payload, fileName);
- }
- catch (SftpException e) {
+ } catch (SftpException e) {
throw new RuntimeCamelException("error sending file", e);
}
}
@@ -67,9 +64,11 @@
@Override
protected void doStart() throws Exception {
super.doStart();
-// channel.connect(endpoint.getConfiguration().getHost());
-// channel.login(endpoint.getConfiguration().getUsername(), endpoint.getConfiguration().getPassword());
-// channel.setFileType(endpoint.getConfiguration().isBinary() ? SftpClient.BINARY_FILE_TYPE : SftpClient.ASCII_FILE_TYPE);
+ // channel.connect(endpoint.getConfiguration().getHost());
+ // channel.login(endpoint.getConfiguration().getUsername(),
+ // endpoint.getConfiguration().getPassword());
+ // channel.setFileType(endpoint.getConfiguration().isBinary() ?
+ // SftpClient.BINARY_FILE_TYPE : SftpClient.ASCII_FILE_TYPE);
}
@Override
@@ -89,11 +88,10 @@
if (!atLeastOneSuccess) {
atLeastOneSuccess = true;
}
- }
- catch (SftpException e) {
+ } catch (SftpException e) {
// ignore
}
}
return atLeastOneSuccess;
}
-}
\ No newline at end of file
+}
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRouteTest.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpRouteTest.java Tue Aug 7 14:33:00 2007
@@ -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,6 +16,8 @@
*/
package org.apache.camel.component.file.remote;
+import java.util.Properties;
+
import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
@@ -25,8 +26,6 @@
import org.apache.ftpserver.config.PropertiesConfiguration;
import org.apache.ftpserver.ftplet.Configuration;
import org.apache.ftpserver.interfaces.FtpServerContext;
-
-import java.util.Properties;
/**
* @version $Revision: 1.1 $
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/UriConfigurationTest.java Tue Aug 7 14:33:00 2007
@@ -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-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java Tue Aug 7 14:33:00 2007
@@ -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,
@@ -30,48 +29,50 @@
*/
public class CamelServlet extends HttpServlet {
- private ConcurrentHashMap<String, HttpConsumer> consumers=new ConcurrentHashMap<String, HttpConsumer>();
+ private ConcurrentHashMap<String, HttpConsumer> consumers = new ConcurrentHashMap<String, HttpConsumer>();
- public CamelServlet() {
+ public CamelServlet() {
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
-
- // Is there a consumer registered for the request.
- HttpConsumer consumer = resolve(request);
- if( consumer == null ) {
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- return;
- }
-
- // Have the camel process the HTTP exchange.
- HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
- consumer.getProcessor().process(exchange);
-
- // HC: The getBinding() is interesting because it illustrates the impedance miss-match between
- // HTTP's stream oriented protocol, and Camels more message oriented protocol exchanges.
-
- // now lets output to the response
- consumer.getBinding().writeResponse(exchange);
-
- } catch (Exception e) {
- throw new ServletException(e);
- }
+
+ // Is there a consumer registered for the request.
+ HttpConsumer consumer = resolve(request);
+ if (consumer == null) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+
+ // Have the camel process the HTTP exchange.
+ HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
+ consumer.getProcessor().process(exchange);
+
+ // HC: The getBinding() is interesting because it illustrates the
+ // impedance miss-match between
+ // HTTP's stream oriented protocol, and Camels more message oriented
+ // protocol exchanges.
+
+ // now lets output to the response
+ consumer.getBinding().writeResponse(exchange);
+
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+
+ protected HttpConsumer resolve(HttpServletRequest request) {
+ String path = request.getPathInfo();
+ return consumers.get(path);
}
- protected HttpConsumer resolve(HttpServletRequest request) {
- String path = request.getPathInfo();
- return consumers.get(path);
- }
-
- public void connect(HttpConsumer consumer) {
- consumers.put(consumer.getPath(), consumer);
- }
-
- public void disconnect(HttpConsumer consumer) {
- consumers.remove(consumer.getPath());
- }
+ public void connect(HttpConsumer consumer) {
+ consumers.put(consumer.getPath(), consumer);
+ }
+
+ public void disconnect(HttpConsumer consumer) {
+ consumers.remove(consumer.getPath());
+ }
}
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java Tue Aug 7 14:33:00 2007
@@ -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,8 +16,9 @@
*/
package org.apache.camel.component.http;
-import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
/**
* @version $Revision$
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java Tue Aug 7 14:33:00 2007
@@ -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,
@@ -23,43 +22,45 @@
import org.apache.camel.impl.DefaultComponent;
/**
- * Defines the <a href="http://activemq.apache.org/camel/http.html">HTTP Component</a>
- *
+ * Defines the <a href="http://activemq.apache.org/camel/http.html">HTTP
+ * Component</a>
+ *
* @version $Revision$
*/
public class HttpComponent extends DefaultComponent<HttpExchange> {
-
- private CamelServlet camelServlet;
-
- /**
- * Connects the URL specified on the endpoint to the specified processor.
- *
- * @throws Exception
- */
- public void connect(HttpConsumer consumer) throws Exception {
- camelServlet.connect(consumer);
- }
-
- /**
- * Disconnects the URL specified on the endpoint from the specified processor.
- *
- * @throws Exception
- */
- public void disconnect(HttpConsumer consumer) throws Exception {
- camelServlet.disconnect(consumer);
- }
-
- public CamelServlet getCamelServlet() {
- return camelServlet;
- }
-
- public void setCamelServlet(CamelServlet camelServlet) {
- this.camelServlet = camelServlet;
- }
-
- @Override
- protected Endpoint<HttpExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
- return new HttpEndpoint(uri, this);
- }
+
+ private CamelServlet camelServlet;
+
+ /**
+ * Connects the URL specified on the endpoint to the specified processor.
+ *
+ * @throws Exception
+ */
+ public void connect(HttpConsumer consumer) throws Exception {
+ camelServlet.connect(consumer);
+ }
+
+ /**
+ * Disconnects the URL specified on the endpoint from the specified
+ * processor.
+ *
+ * @throws Exception
+ */
+ public void disconnect(HttpConsumer consumer) throws Exception {
+ camelServlet.disconnect(consumer);
+ }
+
+ public CamelServlet getCamelServlet() {
+ return camelServlet;
+ }
+
+ public void setCamelServlet(CamelServlet camelServlet) {
+ this.camelServlet = camelServlet;
+ }
+
+ @Override
+ protected Endpoint<HttpExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
+ return new HttpEndpoint(uri, this);
+ }
}
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java Tue Aug 7 14:33:00 2007
@@ -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,
@@ -18,7 +17,6 @@
package org.apache.camel.component.http;
import org.apache.camel.Processor;
-import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultConsumer;
/**
@@ -26,16 +24,16 @@
*/
public class HttpConsumer extends DefaultConsumer<HttpExchange> {
- private final HttpEndpoint endpoint;
+ private final HttpEndpoint endpoint;
- public HttpConsumer(HttpEndpoint endpoint, Processor processor) {
- super(endpoint, processor);
- this.endpoint = endpoint;
- }
+ public HttpConsumer(HttpEndpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ this.endpoint = endpoint;
+ }
@Override
public HttpEndpoint getEndpoint() {
- return (HttpEndpoint) super.getEndpoint();
+ return (HttpEndpoint)super.getEndpoint();
}
public HttpBinding getBinding() {
@@ -47,15 +45,15 @@
}
@Override
- protected void doStart() throws Exception {
- super.doStart();
- endpoint.connect(this);
- }
-
- @Override
- protected void doStop() throws Exception {
- endpoint.disconnect(this);
- super.doStop();
- }
+ protected void doStart() throws Exception {
+ super.doStart();
+ endpoint.connect(this);
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ endpoint.disconnect(this);
+ super.doStop();
+ }
}
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java Tue Aug 7 14:33:00 2007
@@ -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,
@@ -25,29 +24,28 @@
import org.apache.camel.Consumer;
import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.impl.DefaultEndpoint;
/**
- * Represents a <a href="http://activemq.apache.org/camel/http.html">HTTP endpoint</a>
- *
+ * Represents a <a href="http://activemq.apache.org/camel/http.html">HTTP
+ * endpoint</a>
+ *
* @version $Revision$
*/
public class HttpEndpoint extends DefaultEndpoint<HttpExchange> {
private HttpBinding binding;
- private HttpComponent component;
- private URI httpUri;
-
+ private HttpComponent component;
+ private URI httpUri;
+
protected HttpEndpoint(String uri, HttpComponent component) throws URISyntaxException {
super(uri, component);
- this.component = component;
- this.httpUri = new URI(uri);
+ this.component = component;
+ this.httpUri = new URI(uri);
}
public HttpProducer createProducer() throws Exception {
- return new HttpProducer(this);
+ return new HttpProducer(this);
}
public Consumer<HttpExchange> createConsumer(Processor processor) throws Exception {
@@ -72,35 +70,35 @@
public void setBinding(HttpBinding binding) {
this.binding = binding;
}
-
- public boolean isSingleton() {
- return true;
- }
-
- public void connect(HttpConsumer consumer) throws Exception {
- component.connect(consumer);
- }
-
- public void disconnect(HttpConsumer consumer) throws Exception {
- component.disconnect(consumer);
- }
-
- public String getPath() {
- return httpUri.getPath();
- }
-
- public int getPort() {
- if( httpUri.getPort() == -1 ) {
- if( "https".equals(getProtocol() ) ) {
- return 443;
- } else {
- return 80;
- }
- }
- return httpUri.getPort();
- }
-
- public String getProtocol() {
- return httpUri.getScheme();
- }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void connect(HttpConsumer consumer) throws Exception {
+ component.connect(consumer);
+ }
+
+ public void disconnect(HttpConsumer consumer) throws Exception {
+ component.disconnect(consumer);
+ }
+
+ public String getPath() {
+ return httpUri.getPath();
+ }
+
+ public int getPort() {
+ if (httpUri.getPort() == -1) {
+ if ("https".equals(getProtocol())) {
+ return 443;
+ } else {
+ return 80;
+ }
+ }
+ return httpUri.getPort();
+ }
+
+ public String getProtocol() {
+ return httpUri.getScheme();
+ }
}
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java Tue Aug 7 14:33:00 2007
@@ -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,10 @@
*/
package org.apache.camel.component.http;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultExchange;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.impl.DefaultExchange;
/**
* Represents a HTTP exchange which exposes the underlying HTTP abtractions via
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java Tue Aug 7 14:33:00 2007
@@ -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,14 +16,14 @@
*/
package org.apache.camel.component.http;
-import org.apache.camel.impl.DefaultMessage;
-import org.apache.camel.Exchange;
-import org.apache.camel.RuntimeCamelException;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
-import java.util.Map;
-import java.util.Enumeration;
-import java.io.IOException;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultMessage;
/**
* @version $Revision$
@@ -32,7 +31,6 @@
public class HttpMessage extends DefaultMessage {
private HttpServletRequest request;
-
public HttpMessage(HttpExchange exchange, HttpServletRequest request) {
setExchange(exchange);
this.request = request;
@@ -44,7 +42,7 @@
@Override
public HttpExchange getExchange() {
- return (HttpExchange) super.getExchange();
+ return (HttpExchange)super.getExchange();
}
public HttpServletRequest getRequest() {
@@ -55,8 +53,7 @@
protected Object createBody() {
try {
return getExchange().getEndpoint().getBinding().parseBody(this);
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeCamelException(e);
}
}
@@ -65,7 +62,7 @@
protected void populateInitialHeaders(Map<String, Object> map) {
Enumeration names = request.getHeaderNames();
while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
+ String name = (String)names.nextElement();
Object value = request.getHeader(name);
map.put(name, value);
}
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?view=diff&rev=563665&r1=563664&r2=563665
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java Tue Aug 7 14:33:00 2007
@@ -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,6 +16,8 @@
*/
package org.apache.camel.component.http;
+import java.io.InputStream;
+
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Producer;
@@ -29,8 +30,6 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
-import java.io.InputStream;
-
/**
* @version $Revision: 1.1 $
*/
@@ -67,7 +66,8 @@
if (requestEntity == null) {
return new GetMethod(uri);
}
- // TODO we might be PUT? - have some better way to explicitly choose method
+ // TODO we might be PUT? - have some better way to explicitly choose
+ // method
PostMethod method = new PostMethod(uri);
method.setRequestEntity(requestEntity);
return method;
@@ -81,8 +81,7 @@
String contentType = in.getHeader("Content-Type", String.class);
if (contentType != null) {
return new ByteArrayRequestEntity(data, contentType);
- }
- else {
+ } else {
return new ByteArrayRequestEntity(data);
}
}