Tagging camel 1.0.0 RC 3
git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/tags/camel-1.0.0@551248 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index d882114..72f2c9b 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -56,6 +56,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-irc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-jaxb</artifactId>
</dependency>
<dependency>
@@ -170,8 +174,9 @@
<goal>createbundle</goal>
</goals>
<configuration>
- <includes>camel-activemq,camel-bam,camel-core,camel-cxf,camel-file,camel-http,camel-jaxb,
- camel-jbi,camel-jms,camel-josql,camel-jpa,camel-mail,camel-mina,camel-quartz,camel-rmi,
+ <includes>camel-activemq,camel-bam,camel-core,camel-cxf,camel-file,camel-http,
+ camel-irc,camel-jaxb,camel-jbi,camel-jms,camel-josql,
+ camel-jpa,camel-mail,camel-mina,camel-quartz,camel-rmi,
camel-saxon,camel-script,camel-spring,camel-xmpp,commons-logging</includes>
</configuration>
</execution>
diff --git a/apache-camel/src/main/descriptors/unix-bin.xml b/apache-camel/src/main/descriptors/unix-bin.xml
index 3a0fd3c..446fa81 100644
--- a/apache-camel/src/main/descriptors/unix-bin.xml
+++ b/apache-camel/src/main/descriptors/unix-bin.xml
@@ -73,6 +73,7 @@
<include>org.apache.camel:camel-core</include>
<include>org.apache.camel:camel-cxf</include>
<include>org.apache.camel:camel-http</include>
+ <include>org.apache.camel:camel-irc</include>
<include>org.apache.camel:camel-jaxb</include>
<include>org.apache.camel:camel-jbi</include>
<include>org.apache.camel:camel-jms</include>
diff --git a/apache-camel/src/main/descriptors/windows-bin.xml b/apache-camel/src/main/descriptors/windows-bin.xml
index 935203c..0dd7698 100644
--- a/apache-camel/src/main/descriptors/windows-bin.xml
+++ b/apache-camel/src/main/descriptors/windows-bin.xml
@@ -79,6 +79,7 @@
<include>org.apache.camel:camel-core</include>
<include>org.apache.camel:camel-cxf</include>
<include>org.apache.camel:camel-http</include>
+ <include>org.apache.camel:camel-irc</include>
<include>org.apache.camel:camel-jaxb</include>
<include>org.apache.camel:camel-jbi</include>
<include>org.apache.camel:camel-jms</include>
diff --git a/camel-core/pom.xml b/camel-core/pom.xml
index 3c9f9f3..fa5c98f 100755
--- a/camel-core/pom.xml
+++ b/camel-core/pom.xml
@@ -91,23 +91,6 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <childDelegation>false</childDelegation>
- <useFile>true</useFile>
- <includes>
- <include>**/*Test.*</include>
- </includes>
- <excludes>
- <exclude>**/PojoRouteTest.*</exclude>
- <!-- TODO fixme ASAP -->
- <exclude>**/ResequencerTest.*</exclude>
- </excludes>
- </configuration>
- </plugin>
-
</plugins>
</build>
diff --git a/camel-core/src/main/java/org/apache/camel/Exchange.java b/camel-core/src/main/java/org/apache/camel/Exchange.java
index b6ffecd..afcfd1a 100644
--- a/camel-core/src/main/java/org/apache/camel/Exchange.java
+++ b/camel-core/src/main/java/org/apache/camel/Exchange.java
@@ -82,12 +82,21 @@
Message getIn();
/**
- * Returns the aresponse message
+ * Returns the outbound message, lazily creating one if one has not already been associated with this exchange.
+ * If you want to inspect this property but not force lazy creation then invoke the {@link #getOut(boolean)} method
+ * passing in null
+ *
* @return the response
*/
Message getOut();
/**
+ * Returns the outbound message; optionally lazily creating one if one has not been associated with this exchange
+ * @return the response
+ */
+ Message getOut(boolean lazyCreate);
+
+ /**
* Returns the fault message
* @return the fault
*/
diff --git a/camel-core/src/main/java/org/apache/camel/builder/WhenBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/WhenBuilder.java
index dcf1d86..ae82045 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/WhenBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/WhenBuilder.java
@@ -19,6 +19,7 @@
import org.apache.camel.Endpoint;
import org.apache.camel.Predicate;
+import org.apache.camel.Processor;
/**
* @version $Revision$
@@ -33,17 +34,22 @@
@Override
@Fluent
- public ChoiceBuilder to(@FluentArg("ref") Endpoint endpoint) {
+ public ChoiceBuilder to(@FluentArg("ref")Endpoint endpoint) {
super.to(endpoint);
return parent;
}
@Override
@Fluent
- public ChoiceBuilder to(@FluentArg("uri") String uri) {
+ public ChoiceBuilder to(@FluentArg("uri")String uri) {
super.to(uri);
return parent;
}
-
+ @Override
+ @Fluent
+ public ChoiceBuilder process(@FluentArg("ref")Processor processor) {
+ super.process(processor);
+ return parent;
+ }
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
index b25235e..13b1601 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
@@ -126,7 +126,11 @@
}
public Message getOut() {
- if (out == null) {
+ return getOut(true);
+ }
+
+ public Message getOut(boolean lazyCreate) {
+ if (out == null && lazyCreate) {
out = createOutMessage();
configureMessage(out);
}
diff --git a/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java b/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
index f165622..c781338 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
@@ -37,10 +37,7 @@
*/
public static void startServices(Object... services) throws Exception {
for (Object value : services) {
- if (value instanceof Service) {
- Service service = (Service) value;
- service.start();
- }
+ startService(value);
}
}
@@ -56,6 +53,15 @@
}
}
+ public static void startService(Object value) throws Exception {
+ if (value instanceof Service) {
+ Service service = (Service) value;
+ service.start();
+ }
+ else if (value instanceof Collection) {
+ startServices((Collection) value);
+ }
+ }
/**
* Stops all of the given services, throwing the first exception caught
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
index 5bd3716..53d89c9 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
@@ -32,6 +32,8 @@
import org.xmlsoap.schemas.wsdl.http.AddressType;
/**
+ * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Component</a>
+
* @version $Revision$
*/
public class CxfComponent extends DefaultComponent<CxfExchange> {
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
index 30d38f7..98b1c2d 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
@@ -27,7 +27,7 @@
import org.apache.cxf.transport.local.LocalTransportFactory;
/**
- * The endpoint in the service engine
+ * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Endpoint</a>
*
* @version $Revision$
*/
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
index 2bd1964..2a965c2 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfExchange.java
@@ -73,6 +73,11 @@
}
@Override
+ public CxfMessage getOut(boolean lazyCreate) {
+ return (CxfMessage) super.getOut(lazyCreate);
+ }
+
+ @Override
public CxfMessage getFault() {
return (CxfMessage) super.getFault();
}
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/package.html b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/package.html
new file mode 100644
index 0000000..382d6c0
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/package.html
@@ -0,0 +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
+
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Component</a>
+
+</body>
+</html>
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/package.html b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/package.html
index a937b7b..da24e29 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/package.html
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/package.html
@@ -19,7 +19,7 @@
</head>
<body>
-Defines the File transport for communicating with Remote Files
+Defines the File transport for communicating with Remote Files and <a href="http://activemq.apache.org/camel/ftp.html">FTP</a>
</body>
</html>
diff --git a/components/camel-http/pom.xml b/components/camel-http/pom.xml
index 8f11b65..aabc43c 100644
--- a/components/camel-http/pom.xml
+++ b/components/camel-http/pom.xml
@@ -38,23 +38,33 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
-
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging-api</artifactId>
- </dependency>
-
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
</dependency>
+ <!-- only required for consuming -->
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1-rc1</version>
+ <optional>true</optional>
+ </dependency>
+
+ <!-- only required for producing -->
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<optional>true</optional>
</dependency>
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
index 052026e..fce2108 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
@@ -47,7 +47,7 @@
}
// Have the camel process the HTTP exchange.
- HttpExchange exchange = new HttpExchange(consumer.getEndpoint().getContext(), request, response);
+ 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
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
index b772d2b..c399fde 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
@@ -17,6 +17,9 @@
*/
package org.apache.camel.component.http;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+
/**
* @version $Revision$
*/
@@ -28,4 +31,13 @@
public void writeResponse(HttpExchange exchange) {
/** TODO */
}
+
+ /**
+ * Parses the body from a HTTP message
+ */
+ public Object parseBody(HttpMessage httpMessage) throws IOException {
+ // lets assume the body is a reader
+ HttpServletRequest request = httpMessage.getRequest();
+ return request.getReader();
+ }
}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
index 6b7f30c..e2a57fc 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
@@ -23,18 +23,18 @@
import org.apache.camel.impl.DefaultComponent;
/**
+ * Defines the <a href="http://activemq.apache.org/camel/http.html">HTTP Component</a>
+ *
* @version $Revision$
*/
public class HttpComponent extends DefaultComponent<HttpExchange> {
- CamelServlet camelServlet;
+ private CamelServlet camelServlet;
/**
* Connects the URL specified on the endpoint to the specified processor.
*
- * @param endpoint
- * @param processor
- * @throws Exception
+ * @throws Exception
*/
public void connect(HttpConsumer consumer) throws Exception {
camelServlet.connect(consumer);
@@ -43,9 +43,7 @@
/**
* Disconnects the URL specified on the endpoint from the specified processor.
*
- * @param endpoint
- * @param processor
- * @throws Exception
+ * @throws Exception
*/
public void disconnect(HttpConsumer consumer) throws Exception {
camelServlet.disconnect(consumer);
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
index 1e45bb6..77655dd 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConsumer.java
@@ -18,6 +18,7 @@
package org.apache.camel.component.http;
import org.apache.camel.Processor;
+import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultConsumer;
/**
@@ -31,8 +32,21 @@
super(endpoint, processor);
this.endpoint = endpoint;
}
-
- @Override
+
+ @Override
+ public HttpEndpoint getEndpoint() {
+ return (HttpEndpoint) super.getEndpoint();
+ }
+
+ public HttpBinding getBinding() {
+ return endpoint.getBinding();
+ }
+
+ public String getPath() {
+ return endpoint.getPath();
+ }
+
+ @Override
protected void doStart() throws Exception {
super.doStart();
endpoint.connect(this);
@@ -44,13 +58,4 @@
super.doStop();
}
- public HttpBinding getBinding() {
- return endpoint.getBinding();
- }
-
- public String getPath() {
- return endpoint.getPath();
- }
-
-
}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
index 99487b6..1f78f8f 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
@@ -30,7 +30,7 @@
import org.apache.camel.impl.DefaultEndpoint;
/**
- * Represents a HTTP based Endpoint
+ * Represents a <a href="http://activemq.apache.org/camel/http.html">HTTP endpoint</a>
*
* @version $Revision$
*/
@@ -46,8 +46,8 @@
this.httpUri = new URI(uri);
}
- public Producer<HttpExchange> createProducer() throws Exception {
- throw new RuntimeCamelException("Not implemented.");
+ public HttpProducer createProducer() throws Exception {
+ return new HttpProducer(this);
}
public Consumer<HttpExchange> createConsumer(Processor processor) throws Exception {
@@ -55,11 +55,11 @@
}
public HttpExchange createExchange() {
- return new HttpExchange(getContext());
+ return new HttpExchange(this);
}
public HttpExchange createExchange(HttpServletRequest request, HttpServletResponse response) {
- return new HttpExchange(getContext(), request, response);
+ return new HttpExchange(this, request, response);
}
public HttpBinding getBinding() {
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
index f840a23..1dedf29 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
@@ -18,6 +18,7 @@
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;
@@ -30,20 +31,23 @@
* @version $Revision$
*/
public class HttpExchange extends DefaultExchange {
+ private final HttpEndpoint endpoint;
private HttpServletRequest request;
private HttpServletResponse response;
- public HttpExchange(CamelContext context) {
- super(context);
+ public HttpExchange(HttpEndpoint endpoint) {
+ super(endpoint.getContext());
+ this.endpoint = endpoint;
}
- public HttpExchange(CamelContext context, HttpServletRequest request, HttpServletResponse response) {
- super(context);
+ public HttpExchange(HttpEndpoint endpoint, HttpServletRequest request, HttpServletResponse response) {
+ this(endpoint);
this.request = request;
this.response = response;
- setIn(new HttpMessage(request));
+ setIn(new HttpMessage(this, request));
}
+
/**
* Returns the underlying Servlet request for inbound HTTP requests
*
@@ -61,4 +65,8 @@
public HttpServletResponse getResponse() {
return response;
}
+
+ public HttpEndpoint getEndpoint() {
+ return endpoint;
+ }
}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
index c4d3524..949ccae 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
@@ -18,9 +18,13 @@
package org.apache.camel.component.http;
import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
+import java.util.Enumeration;
+import java.io.IOException;
/**
* @version $Revision$
@@ -28,20 +32,42 @@
public class HttpMessage extends DefaultMessage {
private HttpServletRequest request;
- public HttpMessage() {
+
+ public HttpMessage(HttpExchange exchange, HttpServletRequest request) {
+ setExchange(exchange);
+ this.request = request;
+
+ // lets force a parse of the body and headers
+ getBody();
+ getHeaders();
}
- public HttpMessage(HttpServletRequest request) {
- this.request = request;
+ @Override
+ public HttpExchange getExchange() {
+ return (HttpExchange) super.getExchange();
+ }
+
+ public HttpServletRequest getRequest() {
+ return request;
}
@Override
protected Object createBody() {
- return super.createBody(); /** TODO */
+ try {
+ return getExchange().getEndpoint().getBinding().parseBody(this);
+ }
+ catch (IOException e) {
+ throw new RuntimeCamelException(e);
+ }
}
@Override
- protected Map<String, Object> createHeaders() {
- return super.createHeaders(); /** TODO */
+ protected void populateInitialHeaders(Map<String, Object> map) {
+ Enumeration names = request.getHeaderNames();
+ while (names.hasMoreElements()) {
+ String name = (String) names.nextElement();
+ Object value = request.getHeader(name);
+ map.put(name, value);
+ }
}
}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
new file mode 100644
index 0000000..d00f512
--- /dev/null
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * 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.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+import java.io.InputStream;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class HttpProducer extends DefaultProducer<HttpExchange> implements Producer<HttpExchange> {
+ private HttpClient httpClient = new HttpClient();
+
+ public HttpProducer(HttpEndpoint endpoint) {
+ super(endpoint);
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ HttpMethod method = createMethod(exchange);
+ int responseCode = httpClient.executeMethod(method);
+
+ // lets store the result in the output message.
+ InputStream in = method.getResponseBodyAsStream();
+ Message out = exchange.getOut(true);
+ out.setBody(in);
+
+ // lets set the headers
+ Header[] headers = method.getResponseHeaders();
+ for (Header header : headers) {
+ String name = header.getName();
+ String value = header.getValue();
+ out.setHeader(name, value);
+ }
+
+ out.setHeader("http.responseCode", responseCode);
+ }
+
+ protected HttpMethod createMethod(Exchange exchange) {
+ String uri = getEndpoint().getEndpointUri();
+ RequestEntity requestEntity = createRequestEntity(exchange);
+ if (requestEntity == null) {
+ return new GetMethod(uri);
+ }
+ // TODO we might be PUT? - have some better way to explicitly choose method
+ PostMethod method = new PostMethod(uri);
+ method.setRequestEntity(requestEntity);
+ return method;
+ }
+
+ protected RequestEntity createRequestEntity(Exchange exchange) {
+ Message in = exchange.getIn();
+ RequestEntity entity = in.getBody(RequestEntity.class);
+ if (entity == null) {
+ byte[] data = in.getBody(byte[].class);
+ String contentType = in.getHeader("Content-Type", String.class);
+ if (contentType != null) {
+ return new ByteArrayRequestEntity(data, contentType);
+ }
+ else {
+ return new ByteArrayRequestEntity(data);
+ }
+ }
+ return entity;
+ }
+}
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/package.html b/components/camel-http/src/main/java/org/apache/camel/component/http/package.html
new file mode 100644
index 0000000..08e592e
--- /dev/null
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/package.html
@@ -0,0 +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
+
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the <a href="http://activemq.apache.org/camel/http.html">HTTP Component</a>
+
+</body>
+</html>
diff --git a/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http b/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http
similarity index 92%
rename from components/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
rename to components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http
index 4d7b69c..8d4fbf8 100644
--- a/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
+++ b/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/component/http
@@ -15,4 +15,4 @@
# limitations under the License.
#
-class=org.apache.camel.component.http.HttpEndpointResolver
+class=org.apache.camel.component.http.JettyHttpComponent
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteTest.java
index 5ca8fdb..bd42ff7 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteTest.java
@@ -17,51 +17,63 @@
*/
package org.apache.camel.component.http;
-import java.io.InputStream;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.DefaultCamelContext;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.List;
+import java.util.Map;
/**
* @version $Revision: 520220 $
*/
-public class HttpRouteTest extends TestCase {
-
- public void testPojoRoutes() throws Exception {
- CamelContext camelContext = new DefaultCamelContext();
-
- // START SNIPPET: register
- JettyHttpComponent component = new JettyHttpComponent();
- camelContext.addComponent("http", component);
- // END SNIPPET: register
-
- // START SNIPPET: route
- // lets add simple route
- camelContext.addRoutes(new RouteBuilder() {
- public void configure() {
- from("http://0.0.0.0:8080/test").to("mock:a");
- }
- });
- // END SNIPPET: route
+public class HttpRouteTest extends ContextTestSupport {
+ protected String expectedBody = "<hello>world!</hello>";
- MockEndpoint mockA = (MockEndpoint) camelContext.getEndpoint("mock:a");
- mockA.expectedMessageCount(1);
-
- camelContext.start();
-
- // START SNIPPET: invoke
- URL url = new URL("http://localhost:8080/test");
- InputStream is = url.openConnection().getInputStream();
- System.out.println("Content: "+is);
- // END SNIPPET: invoke
-
- mockA.assertIsSatisfied();
-
- camelContext.stop();
+ public void testPojoRoutes() throws Exception {
+ MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:a", MockEndpoint.class);
+ mockEndpoint.expectedMessageCount(1);
+
+ invokeHttpEndpoint();
+
+ mockEndpoint.assertIsSatisfied();
+ List<Exchange> list = mockEndpoint.getReceivedExchanges();
+ Exchange exchange = list.get(0);
+ assertNotNull("exchange", exchange);
+
+ Message in = exchange.getIn();
+ assertNotNull("in", in);
+
+ Map<String,Object> headers = in.getHeaders();
+ String actualBody = in.getBody(String.class);
+
+ log.info("Headers: " + headers);
+ log.info("Received body: " + actualBody);
+
+ assertEquals("Body", expectedBody, actualBody);
+ assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
+ }
+
+ protected void invokeHttpEndpoint() throws IOException {
+ template.sendBody("http://localhost:8080/test", expectedBody, "Content-Type", "application/xml");
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("http://localhost:8080/test").convertBodyTo(String.class).to("mock:a");
+ }
+ };
}
}
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteUsingUrlPostTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteUsingUrlPostTest.java
new file mode 100644
index 0000000..7e1377f
--- /dev/null
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpRouteUsingUrlPostTest.java
@@ -0,0 +1,71 @@
+/**
+ *
+ * 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.http;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @version $Revision: 520220 $
+ */
+public class HttpRouteUsingUrlPostTest extends HttpRouteTest {
+
+ protected void invokeHttpEndpoint() throws IOException {
+ URL url = new URL("http://localhost:8080/test");
+ URLConnection urlConnection = url.openConnection();
+ urlConnection.setDoInput(true);
+ urlConnection.setDoOutput(true);
+ urlConnection.setUseCaches(false);
+ urlConnection.setRequestProperty("Content-Type", "application/xml");
+
+ // Send POST data
+ OutputStream out = urlConnection.getOutputStream();
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
+ writer.write(expectedBody);
+ writer.close();
+
+ // read the response data
+ BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
+ while (true) {
+ String line = reader.readLine();
+ if (line == null) {
+ break;
+ }
+ log.info("Read: " + line);
+ }
+ reader.close();
+
+// InputStream is = url.openConnection().getInputStream();
+// System.out.println("Content: "+is);
+ }
+
+}
\ No newline at end of file
diff --git a/components/camel-irc/pom.xml b/components/camel-irc/pom.xml
new file mode 100644
index 0000000..bc2e0bb
--- /dev/null
+++ b/components/camel-irc/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>camel-irc</artifactId>
+ <name>Camel :: IRC</name>
+ <description>Camel IRC support</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.schwering</groupId>
+ <artifactId>irclib</artifactId>
+ <version>1.10</version>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcBinding.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcBinding.java
new file mode 100644
index 0000000..0c1094f
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcBinding.java
@@ -0,0 +1,31 @@
+/**
+ *
+ * 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.irc;
+
+public class IrcBinding {
+ public Object extractBodyFromIrc(IrcExchange exchange, IrcMessage message) {
+ String type = message.getMessageType();
+ String text = message.getMessage();
+ if (text != null) {
+ return text;
+ }
+ else {
+ return type;
+ }
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
new file mode 100644
index 0000000..402a388
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcComponent.java
@@ -0,0 +1,135 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.schwering.irc.lib.IRCConnection;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Defines the <a href="http://activemq.apache.org/camel/irc.html">IRC Component</a>
+ *
+ * @version $Revision:$
+ */
+public class IrcComponent extends DefaultComponent<IrcExchange> {
+ private static final transient Log log = LogFactory.getLog(IrcComponent.class);
+ private IrcConfiguration configuration;
+ private final Map<String, IRCConnection> connectionCache = new HashMap<String, IRCConnection>();
+
+ public static IrcComponent ircComponent() {
+ return new IrcComponent();
+ }
+
+ public IrcComponent() {
+ configuration = new IrcConfiguration();
+ }
+
+ public IrcComponent(IrcConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public IrcComponent(CamelContext context) {
+ super(context);
+ configuration = new IrcConfiguration();
+ }
+
+ protected IrcEndpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
+ IrcConfiguration config = getConfiguration().copy();
+ config.configure(new URI(uri));
+
+ // lets make sure we copy the configuration as each endpoint can customize its own version
+ final IrcEndpoint endpoint = new IrcEndpoint(uri, this, config);
+
+ IntrospectionSupport.setProperties(endpoint.getConfiguration(), parameters);
+ return endpoint;
+ }
+
+ public IrcConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(IrcConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public synchronized IRCConnection getIRCConnection(IrcConfiguration configuration) {
+ final IRCConnection connection;
+ if (connectionCache.containsKey(configuration.getCacheKey())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Returning Cached Connection to " + configuration.getHostname() + " " + configuration.getTarget());
+ }
+ connection = connectionCache.get(configuration.getCacheKey());
+ }
+ else {
+ connection = createConnection(configuration);
+ connectionCache.put(configuration.getCacheKey(), connection);
+ }
+ return connection;
+ }
+
+ protected IRCConnection createConnection(IrcConfiguration configuration) {
+ log.debug("Creating Connection to " + configuration.getHostname() + " destination: " + configuration.getTarget()
+ + " nick: " + configuration.getNickname() + " user: " + configuration.getUsername());
+
+ final IRCConnection conn = new IRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(), configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
+ conn.setEncoding("UTF-8");
+// conn.setDaemon(true);
+ conn.setColors(configuration.isColors());
+ conn.setPong(true);
+
+ try {
+ conn.connect();
+ }
+ catch (Exception e) {
+ log.error("Failed to connect: " + e, e);
+
+ // TODO use checked exceptions?
+ throw new RuntimeCamelException(e);
+ }
+ return conn;
+ }
+
+ public void closeConnection(String key, IRCConnection connection) {
+ try {
+ connection.doQuit();
+ connection.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected synchronized void doStop() throws Exception {
+ // lets use a copy so we can clear the connections eagerly in case of exceptions
+ Map<String, IRCConnection> map = new HashMap<String, IRCConnection>(connectionCache);
+ connectionCache.clear();
+ for (Map.Entry<String, IRCConnection> entry : map.entrySet()) {
+ closeConnection(entry.getKey(), entry.getValue());
+ }
+ super.doStop();
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
new file mode 100644
index 0000000..50a96ed
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConfiguration.java
@@ -0,0 +1,241 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.RuntimeCamelException;
+
+import java.net.URI;
+
+public class IrcConfiguration implements Cloneable {
+ String target;
+ String hostname;
+ String password;
+ String nickname;
+ String realname;
+ String username;
+ boolean persistent = true;
+ boolean colors = true;
+ boolean onNick = true;
+ boolean onQuit = true;
+ boolean onJoin = true;
+ boolean onKick = true;
+ boolean onMode = true;
+ boolean onPart = true;
+ boolean onTopic = true;
+ boolean onPrivmsg = true;
+ int[] ports = {6667, 6668, 6669};
+
+ public IrcConfiguration() {
+ }
+
+ public IrcConfiguration(String hostname, String nickname, String displayname, String target) {
+ this.target = target;
+ this.hostname = hostname;
+ this.nickname = nickname;
+ this.username = nickname;
+ this.realname = displayname;
+ }
+
+ public IrcConfiguration(String hostname, String username, String password, String nickname, String displayname, String target) {
+ this.target = target;
+ this.hostname = hostname;
+ this.username = username;
+ this.password = password;
+ this.nickname = nickname;
+ this.realname = displayname;
+ }
+
+ public IrcConfiguration copy() {
+ try {
+ return (IrcConfiguration) clone();
+ }
+ catch (CloneNotSupportedException e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ public String getCacheKey() {
+ return hostname + ":" + nickname;
+ }
+
+ public void configure(URI uri) {
+ setNickname(uri.getUserInfo());
+ setUsername(uri.getUserInfo());
+ setRealname(uri.getUserInfo());
+ setHostname(uri.getHost());
+ setTarget(uri.getPath().substring(1));
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public String getRealname() {
+ return realname;
+ }
+
+ public void setRealname(String realname) {
+ this.realname = realname;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public int[] getPorts() {
+ return ports;
+ }
+
+ public void setPorts(int[] ports) {
+ this.ports = ports;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public boolean isPersistent() {
+ return persistent;
+ }
+
+ public void setPersistent(boolean persistent) {
+ this.persistent = persistent;
+ }
+
+ public boolean isColors() {
+ return colors;
+ }
+
+ public void setColors(boolean colors) {
+ this.colors = colors;
+ }
+
+ public boolean isOnNick() {
+ return onNick;
+ }
+
+ public void setOnNick(boolean onNick) {
+ this.onNick = onNick;
+ }
+
+ public boolean isOnQuit() {
+ return onQuit;
+ }
+
+ public void setOnQuit(boolean onQuit) {
+ this.onQuit = onQuit;
+ }
+
+ public boolean isOnJoin() {
+ return onJoin;
+ }
+
+ public void setOnJoin(boolean onJoin) {
+ this.onJoin = onJoin;
+ }
+
+ public boolean isOnKick() {
+ return onKick;
+ }
+
+ public void setOnKick(boolean onKick) {
+ this.onKick = onKick;
+ }
+
+ public boolean isOnMode() {
+ return onMode;
+ }
+
+ public void setOnMode(boolean onMode) {
+ this.onMode = onMode;
+ }
+
+ public boolean isOnPart() {
+ return onPart;
+ }
+
+ public void setOnPart(boolean onPart) {
+ this.onPart = onPart;
+ }
+
+ public boolean isOnTopic() {
+ return onTopic;
+ }
+
+ public void setOnTopic(boolean onTopic) {
+ this.onTopic = onTopic;
+ }
+
+ public boolean isOnPrivmsg() {
+ return onPrivmsg;
+ }
+
+ public void setOnPrivmsg(boolean onPrivmsg) {
+ this.onPrivmsg = onPrivmsg;
+ }
+
+ public String toString() {
+ return "IrcConfiguration{" +
+ "target='" + target + '\'' +
+ ", hostname='" + hostname + '\'' +
+ ", password='" + password + '\'' +
+ ", nickname='" + nickname + '\'' +
+ ", realname='" + realname + '\'' +
+ ", username='" + username + '\'' +
+ ", persistent=" + persistent +
+ ", colors=" + colors +
+ ", onNick=" + onNick +
+ ", onQuit=" + onQuit +
+ ", onJoin=" + onJoin +
+ ", onKick=" + onKick +
+ ", onMode=" + onMode +
+ ", onPart=" + onPart +
+ ", onTopic=" + onTopic +
+ ", onPrivmsg=" + onPrivmsg +
+ ", ports=" + ports +
+ '}';
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
new file mode 100644
index 0000000..47b5277
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcConsumer.java
@@ -0,0 +1,198 @@
+/**
+ *
+ * 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.irc;
+
+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.schwering.irc.lib.IRCConnection;
+import org.schwering.irc.lib.IRCEventAdapter;
+import org.schwering.irc.lib.IRCModeParser;
+import org.schwering.irc.lib.IRCUser;
+
+public class IrcConsumer extends DefaultConsumer<IrcExchange> {
+ private static final transient Log log = LogFactory.getLog(IrcConsumer.class);
+ final private IrcEndpoint endpoint;
+ final private IRCConnection connection;
+ final IrcConfiguration configuration;
+ private FilteredIRCEventAdapter listener = null;
+
+ public IrcConsumer(IrcEndpoint endpoint, Processor processor, IRCConnection connection) {
+ super(endpoint, processor);
+ this.endpoint = endpoint;
+ this.connection = connection;
+ configuration = endpoint.getConfiguration();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ String target = endpoint.getConfiguration().getTarget();
+ connection.doPart(target);
+ connection.removeIRCEventListener(listener);
+
+ super.doStop();
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ String target = endpoint.getConfiguration().getTarget();
+ connection.addIRCEventListener(new FilteredIRCEventAdapter(target));
+
+ log.debug("joining: " + target);
+ connection.doJoin(target);
+ }
+
+ public IRCConnection getConnection() {
+ return connection;
+ }
+
+ class FilteredIRCEventAdapter extends IRCEventAdapter {
+ final String target;
+
+ public FilteredIRCEventAdapter(String target) {
+ this.target = target;
+ }
+
+ @Override
+ public void onNick(IRCUser user, String newNick) {
+ if (configuration.isOnNick()) {
+ IrcExchange exchange = endpoint.createOnNickExchange(user, newNick);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void onQuit(IRCUser user, String msg) {
+ if (configuration.isOnQuit()) {
+ IrcExchange exchange = endpoint.createOnQuitExchange(user, msg);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void onJoin(String channel, IRCUser user) {
+ if (configuration.isOnJoin()) {
+ if (channel.equals(configuration.getTarget())) {
+ IrcExchange exchange = endpoint.createOnJoinExchange(channel, user);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onKick(String channel, IRCUser user, String passiveNick, String msg) {
+ if (configuration.isOnKick()) {
+ if (channel.equals(configuration.getTarget())) {
+ IrcExchange exchange = endpoint.createOnKickExchange(channel, user, passiveNick, msg);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onMode(String channel, IRCUser user, IRCModeParser modeParser) {
+ if (configuration.isOnMode()) {
+ if (channel.equals(configuration.getTarget())) {
+ IrcExchange exchange = endpoint.createOnModeExchange(channel, user, modeParser);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onPart(String channel, IRCUser user, String msg) {
+ if (configuration.isOnPart()) {
+ if (channel.equals(configuration.getTarget())) {
+ IrcExchange exchange = endpoint.createOnPartExchange(channel, user, msg);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onTopic(String channel, IRCUser user, String topic) {
+ if (configuration.isOnTopic()) {
+ if (channel.equals(configuration.getTarget())) {
+ IrcExchange exchange = endpoint.createOnTopicExchange(channel, user, topic);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onPrivmsg(String target, IRCUser user, String msg) {
+ if (configuration.isOnPrivmsg()) {
+ if (target.equals(configuration.getTarget())) {
+ IrcExchange exchange = endpoint.createOnPrivmsgExchange(target, user, msg);
+ try {
+ getProcessor().process(exchange);
+ }
+ catch (Exception e) {
+ // TODO: what should we do when a processing failure occurs??
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
new file mode 100644
index 0000000..2f1306a
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcEndpoint.java
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.schwering.irc.lib.IRCModeParser;
+import org.schwering.irc.lib.IRCUser;
+
+/**
+ * Defines the <a href="http://activemq.apache.org/camel/irc.html">IRC Endpoint</a>
+ *
+ * @version $Revision:$
+ */
+public class IrcEndpoint extends DefaultEndpoint<IrcExchange> {
+ private IrcBinding binding;
+ private IrcConfiguration configuration;
+ private IrcComponent component;
+
+ public IrcEndpoint(String endpointUri, IrcComponent component, IrcConfiguration configuration) {
+ super(endpointUri, component);
+ this.component = component;
+ this.configuration = configuration;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public IrcExchange createExchange() {
+ return new IrcExchange(getContext(), getBinding());
+ }
+
+ public IrcExchange createOnPrivmsgExchange(String target, IRCUser user, String msg) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("PRIVMSG", target, user, msg));
+ }
+
+ public IrcExchange createOnNickExchange(IRCUser user, String newNick) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("NICK", user, newNick));
+ }
+
+ public IrcExchange createOnQuitExchange(IRCUser user, String msg) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("QUIT", user, msg));
+ }
+
+ public IrcExchange createOnJoinExchange(String channel, IRCUser user) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("JOIN", channel, user));
+ }
+
+ public IrcExchange createOnKickExchange(String channel, IRCUser user, String whoWasKickedNick, String msg) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("KICK", channel, user, whoWasKickedNick, msg));
+ }
+
+ public IrcExchange createOnModeExchange(String channel, IRCUser user, IRCModeParser modeParser) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("MODE", channel, user, modeParser.getLine()));
+ }
+
+ public IrcExchange createOnPartExchange(String channel, IRCUser user, String msg) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("PART", channel, user, msg));
+ }
+
+ public IrcExchange createOnTopicExchange(String channel, IRCUser user, String topic) {
+ return new IrcExchange(getContext(), getBinding(), new IrcMessage("TOPIC", channel, user, topic));
+ }
+
+ public IrcProducer createProducer() throws Exception {
+ return new IrcProducer(this, component.getIRCConnection(configuration));
+ }
+
+ public IrcConsumer createConsumer(Processor processor) throws Exception {
+ return new IrcConsumer(this, processor, component.getIRCConnection(configuration));
+ }
+
+ public IrcComponent getComponent() {
+ return component;
+ }
+
+ public void setComponent(IrcComponent component) {
+ this.component = component;
+ }
+
+ public IrcBinding getBinding() {
+ if (binding == null) {
+ binding = new IrcBinding();
+ }
+ return binding;
+ }
+
+ public void setBinding(IrcBinding binding) {
+ this.binding = binding;
+ }
+
+ public IrcConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(IrcConfiguration configuration) {
+ this.configuration = configuration;
+ }
+}
+
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcErrorLogger.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcErrorLogger.java
new file mode 100644
index 0000000..2bf164a
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcErrorLogger.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.commons.logging.Log;
+import org.schwering.irc.lib.IRCEventAdapter;
+import org.schwering.irc.lib.IRCModeParser;
+import org.schwering.irc.lib.IRCUser;
+
+/**
+ * A helper class which logs errors
+ *
+ * @version $Revision: 1.1 $
+ */
+public class IrcErrorLogger extends IRCEventAdapter {
+ private Log log;
+
+ public IrcErrorLogger(Log log) {
+ this.log = log;
+ }
+
+ @Override
+ public void onRegistered() {
+ super.onRegistered();
+ log.info("onRegistered");
+ }
+
+ @Override
+ public void onDisconnected() {
+ super.onDisconnected();
+ log.info("onDisconnected");
+ }
+
+ @Override
+ public void onMode(String string, IRCUser ircUser, IRCModeParser ircModeParser) {
+ super.onMode(string, ircUser, ircModeParser);
+ log.info("onMode.string = " + string);
+ log.info("onMode.ircUser = " + ircUser);
+ log.info("onMode.ircModeParser = " + ircModeParser);
+ }
+
+ @Override
+ public void onMode(IRCUser ircUser, String string, String string1) {
+ super.onMode(ircUser, string, string1);
+ log.info("onMode.ircUser = " + ircUser);
+ log.info("onMode.string = " + string);
+ log.info("onMode.string1 = " + string1);
+ }
+
+ @Override
+ public void onPing(String string) {
+ super.onPing(string);
+ log.info("onPing.string = " + string);
+ }
+
+ @Override
+ public void onError(String string) {
+ log.info("onError.string = " + string);
+ }
+
+ @Override
+ public void onError(int i, String string) {
+ super.onError(i, string);
+ log.error("onError.i = " + i);
+ log.error("onError.string = " + string);
+ }
+
+ @Override
+ public void unknown(String string, String string1, String string2, String string3) {
+ super.unknown(string, string1, string2, string3);
+ log.error("unknown.string = " + string);
+ log.error("unknown.string1 = " + string1);
+ log.error("unknown.string2 = " + string2);
+ log.error("unknown.string3 = " + string3);
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcExchange.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcExchange.java
new file mode 100644
index 0000000..68af677
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcExchange.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultExchange;
+
+public class IrcExchange extends DefaultExchange {
+ private IrcBinding binding;
+
+ public IrcExchange(CamelContext context, IrcBinding binding) {
+ super(context);
+ this.binding = binding;
+ }
+
+ public IrcExchange(CamelContext context, IrcBinding binding, IrcMessage inMessage) {
+ this(context, binding);
+ setIn(inMessage);
+ }
+
+ public IrcBinding getBinding() {
+ return binding;
+ }
+
+ public void setBinding(IrcBinding binding) {
+ this.binding = binding;
+ }
+
+ @Override
+ public IrcMessage getIn() {
+ return (IrcMessage) super.getIn();
+ }
+
+ @Override
+ public IrcMessage getOut() {
+ return (IrcMessage) super.getOut();
+ }
+
+ @Override
+ public IrcMessage getOut(boolean lazyCreate) {
+ return (IrcMessage) super.getOut(lazyCreate);
+ }
+
+ @Override
+ public IrcMessage getFault() {
+ return (IrcMessage) super.getFault();
+ }
+
+ @Override
+ public IrcExchange newInstance() {
+ return new IrcExchange(getContext(), getBinding());
+ }
+
+ @Override
+ protected IrcMessage createInMessage() {
+ return new IrcMessage();
+ }
+
+ @Override
+ protected IrcMessage createOutMessage() {
+ return new IrcMessage();
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcMessage.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcMessage.java
new file mode 100644
index 0000000..4a54508
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcMessage.java
@@ -0,0 +1,145 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.impl.DefaultMessage;
+import org.schwering.irc.lib.IRCUser;
+
+import java.util.Map;
+
+public class IrcMessage extends DefaultMessage {
+ private String messageType;
+ private String target;
+ private IRCUser user;
+ private String whoWasKickedNick;
+ private String message;
+
+ public IrcMessage() {
+ }
+
+ public IrcMessage(String messageType, IRCUser user, String message) {
+ this.messageType = messageType;
+ this.user = user;
+ this.message = message;
+ }
+
+ public IrcMessage(String messageType, String target, IRCUser user, String message) {
+ this.messageType = messageType;
+ this.target = target;
+ this.user = user;
+ this.message = message;
+ }
+
+ public IrcMessage(String messageType, String target, IRCUser user, String whoWasKickedNick, String message) {
+ this.messageType = messageType;
+ this.target = target;
+ this.user = user;
+ this.whoWasKickedNick = whoWasKickedNick;
+ this.message = message;
+ }
+
+ public IrcMessage(String messageType, String target, IRCUser user) {
+ this.messageType = messageType;
+ this.target = target;
+ this.user = user;
+ }
+
+ public String getMessageType() {
+ return messageType;
+ }
+
+ public void setMessageType(String messageType) {
+ this.messageType = messageType;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public IRCUser getUser() {
+ return user;
+ }
+
+ public void setUser(IRCUser user) {
+ this.user = user;
+ }
+
+ public String getWhoWasKickedNick() {
+ return whoWasKickedNick;
+ }
+
+ public void setWhoWasKickedNick(String whoWasKickedNick) {
+ this.whoWasKickedNick = whoWasKickedNick;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public IrcExchange getExchange() {
+ return (IrcExchange) super.getExchange();
+ }
+
+ @Override
+ protected Object createBody() {
+ IrcExchange ircExchange = getExchange();
+ IrcBinding binding = ircExchange.getBinding();
+ return binding.extractBodyFromIrc(ircExchange, this);
+ }
+
+ @Override
+ public IrcMessage newInstance() {
+ return new IrcMessage();
+ }
+
+ @Override
+ protected void populateInitialHeaders(Map<String, Object> map) {
+ map.put("irc.messageType", messageType);
+ if (target != null) {
+ map.put("irc.target", target);
+ }
+ if (whoWasKickedNick != null) {
+ map.put("irc.user.kicked", whoWasKickedNick);
+ }
+ if (user != null) {
+ map.put("irc.user.host", user.getHost());
+ map.put("irc.user.nick", user.getNick());
+ map.put("irc.user.servername", user.getServername());
+ map.put("irc.user.username", user.getUsername());
+ }
+ }
+
+ @Override
+ public String toString() {
+ if (message != null) {
+ return "IrcMessage: " + message;
+ }
+ else {
+ return "IrcMessage: " + getBody();
+ }
+ }
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java
new file mode 100644
index 0000000..17f12e6
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/IrcProducer.java
@@ -0,0 +1,102 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.schwering.irc.lib.IRCConnection;
+import org.schwering.irc.lib.IRCEventListener;
+
+public class IrcProducer extends DefaultProducer<IrcExchange> {
+ private static final transient Log log = LogFactory.getLog(IrcProducer.class);
+ private IRCConnection connection;
+ private IrcEndpoint endpoint;
+ private IRCEventListener ircErrorLogger;
+
+ public IrcProducer(IrcEndpoint endpoint, IRCConnection connection) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.connection = connection;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ try {
+ final String msg = exchange.getIn().getBody(String.class);
+ if (isMessageACommand(msg)) {
+ connection.send(msg);
+ }
+ else {
+ final String target = endpoint.getConfiguration().getTarget();
+
+ if (log.isDebugEnabled()) {
+ log.debug("sending to: " + target + " message: " + msg);
+ }
+
+ connection.doPrivmsg(target, msg);
+ }
+ }
+ catch (Exception e) {
+ throw new RuntimeCamelException(e);
+ }
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+
+ ircErrorLogger = createIrcErrorLogger();
+ connection.addIRCEventListener(ircErrorLogger);
+
+ final String target = endpoint.getConfiguration().getTarget();
+
+ log.debug("joining: " + target);
+ connection.doJoin(target);
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ super.doStop();
+ if (connection != null) {
+ connection.removeIRCEventListener(ircErrorLogger);
+ }
+ }
+
+ protected boolean isMessageACommand(String msg) {
+ for (String command : commands) {
+ if (msg.startsWith(command)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected IRCEventListener createIrcErrorLogger() {
+ return new IrcErrorLogger(log);
+ }
+
+ public final String[] commands = new String[]{
+ "AWAY", "INVITE", "ISON", "JOIN",
+ "KICK", "LIST", "NAMES", "PRIVMSG",
+ "MODE", "NICK", "NOTICE", "PART",
+ "PONG", "QUIT", "TOPIC", "WHO",
+ "WHOIS", "WHOWAS", "USERHOST"
+ };
+}
diff --git a/components/camel-irc/src/main/java/org/apache/camel/component/irc/package.html b/components/camel-irc/src/main/java/org/apache/camel/component/irc/package.html
new file mode 100644
index 0000000..eafdba6
--- /dev/null
+++ b/components/camel-irc/src/main/java/org/apache/camel/component/irc/package.html
@@ -0,0 +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
+
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the <a href="http://activemq.apache.org/camel/irc.html">IRC Component</a>
+
+</body>
+</html>
diff --git a/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http b/components/camel-irc/src/main/resources/META-INF/services/org/apache/camel/component/irc
similarity index 91%
copy from components/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
copy to components/camel-irc/src/main/resources/META-INF/services/org/apache/camel/component/irc
index 4d7b69c..de19273 100644
--- a/components/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
+++ b/components/camel-irc/src/main/resources/META-INF/services/org/apache/camel/component/irc
@@ -1,4 +1,3 @@
-#
# 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.
@@ -15,4 +14,4 @@
# limitations under the License.
#
-class=org.apache.camel.component.http.HttpEndpointResolver
+class=org.apache.camel.component.irc.IrcComponent#
diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/CodehausIrcChat.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/CodehausIrcChat.java
new file mode 100644
index 0000000..2a1dae4
--- /dev/null
+++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/CodehausIrcChat.java
@@ -0,0 +1,116 @@
+/**
+ *
+ * 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.irc;
+
+import org.schwering.irc.lib.IRCConnection;
+import org.schwering.irc.lib.IRCEventAdapter;
+import org.schwering.irc.lib.IRCUser;
+import org.schwering.irc.lib.IRCModeParser;
+
+import java.io.IOException;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class CodehausIrcChat {
+ public static void main(String[] args) throws InterruptedException {
+ final IrcConfiguration config = new IrcConfiguration("irc.codehaus.org", "camel-irc", "Camel IRC Component", "#camel-test");
+
+ final IRCConnection conn = new IRCConnection(config.getHostname(), config.getPorts(), config.getPassword(), config.getNickname(), config.getUsername(), config.getRealname());
+
+ conn.addIRCEventListener(new IRCEventAdapter() {
+
+ @Override
+ public void onRegistered() {
+ super.onRegistered();
+ System.out.println("onRegistered");
+ }
+
+ @Override
+ public void onDisconnected() {
+ super.onDisconnected();
+ System.out.println("onDisconnected");
+ }
+
+ @Override
+ public void onMode(String string, IRCUser ircUser, IRCModeParser ircModeParser) {
+ super.onMode(string, ircUser, ircModeParser);
+ System.out.println("onMode.string = " + string);
+ System.out.println("onMode.ircUser = " + ircUser);
+ System.out.println("onMode.ircModeParser = " + ircModeParser);
+ }
+
+ @Override
+ public void onMode(IRCUser ircUser, String string, String string1) {
+ super.onMode(ircUser, string, string1);
+ System.out.println("onMode.ircUser = " + ircUser);
+ System.out.println("onMode.string = " + string);
+ System.out.println("onMode.string1 = " + string1);
+ }
+
+ @Override
+ public void onPing(String string) {
+ super.onPing(string);
+ System.out.println("onPing.string = " + string);
+ }
+
+ @Override
+ public void onError(String string) {
+ System.out.println("onError.string = " + string);
+ }
+
+ @Override
+ public void onError(int i, String string) {
+ super.onError(i, string);
+ System.out.println("onError.i = " + i);
+ System.out.println("onError.string = " + string);
+ }
+
+ @Override
+ public void unknown(String string, String string1, String string2, String string3) {
+ super.unknown(string, string1, string2, string3);
+ System.out.println("unknown.string = " + string);
+ System.out.println("unknown.string1 = " + string1);
+ System.out.println("unknown.string2 = " + string2);
+ System.out.println("unknown.string3 = " + string3);
+ }
+ });
+ conn.setEncoding("UTF-8");
+ //conn.setDaemon(true);
+ conn.setColors(false);
+ conn.setPong(true);
+
+ try {
+ conn.connect();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+// while (!conn.isConnected()) {
+// Thread.sleep(1000);
+// System.out.println("Sleeping");
+// }
+ System.out.println("Connected");
+ //conn.send("/JOIN #camel-test");
+
+ //System.out.println("Joining Channel: " + config.getTarget());
+ conn.doJoin(config.getTarget());
+
+ conn.doPrivmsg("#camel-test", "hi!");
+ Thread.sleep(Integer.MAX_VALUE);
+ }
+}
diff --git a/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteIntegration.java b/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteIntegration.java
new file mode 100644
index 0000000..3f7daad
--- /dev/null
+++ b/components/camel-irc/src/test/java/org/apache/camel/component/irc/IrcRouteIntegration.java
@@ -0,0 +1,84 @@
+/**
+ *
+ * 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.irc;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class IrcRouteIntegration extends ContextTestSupport {
+ protected MockEndpoint resultEndpoint;
+ protected String body1 = "Message One";
+ protected String body2 = "Message Two";
+ private boolean sentMessages;
+
+ public void testIrcMessages() throws Exception {
+ resultEndpoint = (MockEndpoint) context.getEndpoint("mock:result");
+ resultEndpoint.expectedBodiesReceived(body1, body2);
+
+ resultEndpoint.assertIsSatisfied();
+ //Thread.sleep(10000);
+
+ List<Exchange> list = resultEndpoint.getReceivedExchanges();
+ for (Exchange exchange : list) {
+ log.info("Received exchange: " + exchange + " headers: " + exchange.getIn().getHeaders());
+ }
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("irc://camel-con@irc.codehaus.org:6667/%23camel-test").
+ choice().
+ when(header("irc.messageType").isEqualTo("PRIVMSG")).to("mock:result").
+ when(header("irc.messageType").isEqualTo("JOIN")).to("queue:consumerJoined");
+
+ // TODO this causes errors on shutdown...
+ //otherwise().to("mock:otherIrcCommands");
+
+ from("queue:consumerJoined").process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ sendMessages();
+ }
+ });
+ }
+ };
+ }
+
+ /**
+ * Lets send messages once the consumer has joined
+ */
+ protected void sendMessages() {
+ if (!sentMessages) {
+ sentMessages = true;
+
+ // now the consumer has joined, lets send some messages
+ String sendUri = "irc://camel-prd@irc.codehaus.org:6667/%23camel-test";
+
+ template.sendBody(sendUri, body1);
+ template.sendBody(sendUri, body2);
+ }
+ }
+}
\ No newline at end of file
diff --git a/components/camel-irc/src/test/resources/log4j.properties b/components/camel-irc/src/test/resources/log4j.properties
new file mode 100644
index 0000000..f25fc86
--- /dev/null
+++ b/components/camel-irc/src/test/resources/log4j.properties
@@ -0,0 +1,29 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
diff --git a/components/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java b/components/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
index de5e3c9..cb6bb59 100644
--- a/components/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
+++ b/components/camel-jbi/src/main/java/org/apache/camel/component/jbi/JbiExchange.java
@@ -61,6 +61,11 @@
}
@Override
+ public JbiMessage getOut(boolean lazyCreate) {
+ return (JbiMessage) super.getOut(lazyCreate);
+ }
+
+ @Override
public JbiMessage getFault() {
return (JbiMessage) super.getFault();
}
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
index 9edc72c..bb1f508 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsExchange.java
@@ -52,6 +52,11 @@
}
@Override
+ public JmsMessage getOut(boolean lazyCreate) {
+ return (JmsMessage) super.getOut(lazyCreate);
+ }
+
+ @Override
public JmsMessage getFault() {
return (JmsMessage) super.getFault();
}
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringAndJmsNameTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringAndJmsNameTest.java
index c5fa2ed..5cb8aa3 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringAndJmsNameTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringAndJmsNameTest.java
@@ -24,7 +24,7 @@
public class JmsRouteUsingSpringAndJmsNameTest extends JmsRouteUsingSpringTest {
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpringAndJmsNameTest.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpringAndJmsName.xml");
}
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java
index 94c0e46..125a965 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringTest.java
@@ -32,7 +32,7 @@
}
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpring.xml");
}
@Override
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringWithAutoWireTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringWithAutoWireTest.java
index 50a771a..75b7558 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringWithAutoWireTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteUsingSpringWithAutoWireTest.java
@@ -24,7 +24,7 @@
public class JmsRouteUsingSpringWithAutoWireTest extends JmsRouteUsingSpringAndJmsNameTest {
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpringWithAutoWireTest.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/jms/jmsRouteUsingSpringWithAutoWire.xml");
}
}
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml
similarity index 100%
rename from components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringTest.xml
rename to components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpring.xml
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringAndJmsNameTest.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringAndJmsName.xml
similarity index 100%
rename from components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringAndJmsNameTest.xml
rename to components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringAndJmsName.xml
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringWithAutoWireTest.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringWithAutoWire.xml
similarity index 100%
rename from components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringWithAutoWireTest.xml
rename to components/camel-jms/src/test/resources/org/apache/camel/component/jms/jmsRouteUsingSpringWithAutoWire.xml
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
index a5f30af..3b26281 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
@@ -52,6 +52,11 @@
}
@Override
+ public MailMessage getOut(boolean lazyCreate) {
+ return (MailMessage) super.getOut(lazyCreate);
+ }
+
+ @Override
public MailMessage getFault() {
return (MailMessage) super.getFault();
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
index 1b85a64..a06be80 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
@@ -37,14 +37,14 @@
private static final transient Log log = LogFactory.getLog(CamelContextFactoryBeanTest.class);
public void testClassPathRouteLoading() throws Exception {
- ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBeanTest.xml");
+ ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = (CamelContext) applicationContext.getBean("camel");
assertValidContext(context);
}
public void testClassPathRouteLoadingUsingNamespaces() throws Exception {
- ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBeanTest.xml");
+ ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = (CamelContext) applicationContext.getBean("camel3");
assertValidContext(context);
@@ -69,7 +69,7 @@
}
public void testXMLRouteLoading() throws Exception {
- ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBeanTest.xml");
+ ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = (CamelContext) applicationContext.getBean("camel2");
assertNotNull("No context found!", context);
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/InjectedBeanTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/InjectedBeanTest.java
index 4259ff36..0e70db2 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/InjectedBeanTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/InjectedBeanTest.java
@@ -53,7 +53,7 @@
}
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/spring/injectedBeanTest.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/injectedBean.xml");
}
protected int getExpectedRouteCount() {
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java
index 913a5d8..68ab360 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/RoutingUsingCamelContextFactoryTest.java
@@ -67,7 +67,7 @@
}
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new ClassPathXmlApplicationContext("org/apache/camel/spring/routingUsingCamelContextFactoryTest.xml");
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/routingUsingCamelContextFactory.xml");
}
@Override
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBeanTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
similarity index 100%
rename from components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBeanTest.xml
rename to components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBeanTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml
similarity index 100%
rename from components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBeanTest.xml
rename to components/camel-spring/src/test/resources/org/apache/camel/spring/injectedBean.xml
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingCamelContextFactoryTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingCamelContextFactory.xml
similarity index 100%
rename from components/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingCamelContextFactoryTest.xml
rename to components/camel-spring/src/test/resources/org/apache/camel/spring/routingUsingCamelContextFactory.xml
diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
index 7a20821..e846c27 100644
--- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
+++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
@@ -51,6 +51,11 @@
}
@Override
+ public XmppMessage getOut(boolean lazyCreate) {
+ return (XmppMessage) super.getOut(lazyCreate);
+ }
+
+ @Override
public XmppMessage getFault() {
return (XmppMessage) super.getFault();
}
diff --git a/components/pom.xml b/components/pom.xml
index 4b72903..6eaf983 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -39,6 +39,7 @@
<module>camel-cxf</module>
<module>camel-ftp</module>
<module>camel-http</module>
+ <module>camel-irc</module>
<module>camel-jaxb</module>
<module>camel-jbi</module>
<module>camel-jms</module>
diff --git a/examples/camel-example-jms-file/pom.xml b/examples/camel-example-jms-file/pom.xml
index b101a4b..9cb5ff7 100755
--- a/examples/camel-example-jms-file/pom.xml
+++ b/examples/camel-example-jms-file/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-parent</artifactId>
+ <artifactId>examples</artifactId>
<version>1.0.0</version>
</parent>
@@ -66,6 +66,7 @@
<goals>
<goal>java</goal>
</goals>
+ <phase>install</phase>
</execution>
</executions>
<configuration>
diff --git a/examples/camel-example-spring/pom.xml b/examples/camel-example-spring/pom.xml
index 6b682cb..b3f2910 100755
--- a/examples/camel-example-spring/pom.xml
+++ b/examples/camel-example-spring/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-parent</artifactId>
+ <artifactId>examples</artifactId>
<version>1.0.0</version>
</parent>
diff --git a/pom.xml b/pom.xml
index 91ddfe5..e6571f0 100755
--- a/pom.xml
+++ b/pom.xml
@@ -190,6 +190,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-irc</artifactId>
+ <version>${camel-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-jbi</artifactId>
<version>${camel-version}</version>
</dependency>
@@ -576,6 +581,17 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <includes>
+ <include>**/*Test.*</include>
+ </includes>
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -717,5 +733,24 @@
</pluginRepository>
</pluginRepositories>
</profile>
+
+ <profile>
+ <id>integration</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <childDelegation>false</childDelegation>
+ <useFile>true</useFile>
+ <includes>
+ <include>**/*Test.*</include>
+ <include>**/*Integration.*</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
</project>
diff --git a/tooling/archetypes/camel-router/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/camel-context.xml b/tooling/archetypes/camel-router/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/camel-context.xml
index d6f8f1a..149c78e 100644
--- a/tooling/archetypes/camel-router/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/camel-context.xml
+++ b/tooling/archetypes/camel-router/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/camel-context.xml
@@ -24,7 +24,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
- <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring" packages="org.apache.camel.example.spring">
+ <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring" packages="${package}">
</camelContext>
</beans>
diff --git a/camel-book/pom.xml b/tooling/camel-book/pom.xml
similarity index 72%
rename from camel-book/pom.xml
rename to tooling/camel-book/pom.xml
index 3ce5ec5..d7e8251 100644
--- a/camel-book/pom.xml
+++ b/tooling/camel-book/pom.xml
@@ -58,21 +58,21 @@
<goals>
<goal>htmlToDocbook</goal>
</goals>
- <phase>generate-sources</phase>
+ <phase>site</phase>
</execution>
</executions>
<configuration>
- <baseURL>http://activemq.apache.org/camel/</baseURL>
+ <baseURL>http://cwiki.apache.org/CAMEL/</baseURL>
<title>Camel</title>
<subtitle>User Guide</subtitle>
<resources>
- <resource>index.html</resource>
- <resource>getting-started.html</resource>
- <resource>architecture.html</resource>
- <resource>user-guide.html</resource>
- <resource>components.html</resource>
-
- </resources>
+ <resource>book-introduction.html</resource>
+ <resource>book-architecture.html</resource>
+ <resource>book-enterprise-integration-patterns.html</resource>
+ <resource>book-getting-started.html</resource>
+ <resource>book-pattern-appendix.html</resource>
+ <resource>book-component-appendix.html</resource>
+ </resources>
<authors>
<author>James Strachan</author>
<author>Hiram Chirino</author>
@@ -86,13 +86,36 @@
<version>2.0.3-SNAPSHOT</version>
<executions>
<execution>
+ <id>execution1</id>
+ <goals>
+ <goal>generate-html</goal>
+ </goals>
+ <phase>site</phase>
+ <configuration>
+ <targetDirectory>${basedir}/target/site/book/html</targetDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>execution2</id>
<goals>
<goal>generate-pdf</goal>
- <goal>generate-html</goal>
+ <!--goal>generate-manpages</goal-->
+ </goals>
+ <phase>site</phase>
+ <configuration>
+ <targetDirectory>${basedir}/target/site/book/pdf</targetDirectory>
+ </configuration>
+ </execution>
+ <execution>
+ <id>execution3</id>
+ <goals>
<goal>generate-manpages</goal>
</goals>
- <phase>generate-sources</phase>
- </execution>
+ <phase>site</phase>
+ <configuration>
+ <targetDirectory>${basedir}/target/site/book/manpage</targetDirectory>
+ </configuration>
+ </execution>
</executions>
<dependencies>
<dependency>
@@ -105,7 +128,7 @@
<configuration>
<foCustomization>${basedir}/src/styles/docbook-fo.xsl</foCustomization>
- <includes>Camel.xml</includes>
+ <includes>manual.xml</includes>
<!-- lets use separate pages per chapter for HTML -->
<chunkedOutput>true</chunkedOutput>
@@ -120,14 +143,9 @@
<!--<xincludeSupport>true</xincludeSupport>-->
- <sourceDirectory>${basedir}/target/docbkx/source</sourceDirectory>
- <!--
+ <sourceDirectory>${basedir}/target/docbkx/docbkx-source</sourceDirectory>
- <preProcess>
- <ant target="generate-manual" inheritAll="true"/>
- </preProcess>
- -->
- <!--<htmlStylesheet>http://agilejava.com/downloads/kubrick-docbkx.css</htmlStylesheet>-->
+
<headerRule>0</headerRule>
<footerRule>0</footerRule>
<draftMode>0</draftMode>
diff --git a/camel-book/src/docbkx/images/asf-logo.gif b/tooling/camel-book/src/docbkx/images/asf-logo.gif
similarity index 100%
rename from camel-book/src/docbkx/images/asf-logo.gif
rename to tooling/camel-book/src/docbkx/images/asf-logo.gif
Binary files differ
diff --git a/camel-book/src/docbkx/images/logo.jpeg b/tooling/camel-book/src/docbkx/images/logo.jpeg
similarity index 100%
rename from camel-book/src/docbkx/images/logo.jpeg
rename to tooling/camel-book/src/docbkx/images/logo.jpeg
Binary files differ
diff --git a/camel-book/src/styles/docbook-fo.xsl b/tooling/camel-book/src/styles/docbook-fo.xsl
similarity index 100%
rename from camel-book/src/styles/docbook-fo.xsl
rename to tooling/camel-book/src/styles/docbook-fo.xsl
diff --git a/camel-book/src/styles/docbook.xsl b/tooling/camel-book/src/styles/docbook.xsl
similarity index 90%
rename from camel-book/src/styles/docbook.xsl
rename to tooling/camel-book/src/styles/docbook.xsl
index facd53e..893bf57 100644
--- a/camel-book/src/styles/docbook.xsl
+++ b/tooling/camel-book/src/styles/docbook.xsl
@@ -26,14 +26,17 @@
<xsl:param name="bridgeprefix">br_</xsl:param>
<xsl:param name="root_url" select="div/@baseURL"/>
<!-- This template converts each "wiki-content maincontent" DIV into a DocBook
- section. -->
+ section. For a title, it selects the first h1 element -->
<xsl:template match="div[contains(@class,'wiki-content maincontent')]">
<chapter >
<xsl:attribute name="id">
<xsl:value-of select="@chapterId"/>
</xsl:attribute>
<title>
- <xsl:value-of select="@chapterTitle"/>
+ <xsl:value-of
+ select=".//h1[1]
+ |.//h2[1]
+ |.//h3[1]"/>
</title>
<section>
<xsl:if test="$filename != ''">
@@ -60,12 +63,14 @@
|h6">
<bridgehead>
<xsl:choose>
+ <!--
<xsl:when test="count(a/@name)">
<xsl:attribute name="id">
<xsl:value-of select="$bridgeprefix"/>
<xsl:value-of select="a/@name"/>
</xsl:attribute>
</xsl:when>
+ -->
<xsl:when
test="preceding-sibling::* = preceding-sibling::a[@name != '']">
<xsl:attribute name="id">
@@ -113,18 +118,27 @@
<xsl:attribute name="url">
<xsl:value-of select="normalize-space(@href)"/>
</xsl:attribute>
- <xsl:apply-templates/>
+ <xsl:apply-templates />
</ulink>
</xsl:template>
<xsl:template match="a[contains(@href,'.htm')]" priority="1.5">
<ulink>
<xsl:attribute name="url">
- <xsl:value-of select="$root_url"/>
- <xsl:value-of select="normalize-space(@href)"/>
+ <xsl:choose>
+ <xsl:when test="contains(@href,'www.')">
+ <xsl:value-of select="normalize-space(@href)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$root_url"/>
+ <xsl:value-of select="normalize-space(@href)"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
<xsl:apply-templates/>
</ulink>
+
</xsl:template>
+
<xsl:template match="a[contains(@href,'ftp://')]" priority="1.5">
<ulink>
<xsl:attribute name="url">
@@ -142,6 +156,12 @@
</xsl:attribute>
</xref>
</xsl:template-->
+
+<!--
+ this currently breaks the generator if there are more than one definition of an anchor name
+ ie. http://activemq.apache.org/camel/book-pattern-appendix.html
+
+
<xsl:template match="a[@name != '']" priority="0.6">
<anchor>
<xsl:attribute name="id">
@@ -152,6 +172,7 @@
<xsl:apply-templates/>
</anchor>
</xsl:template>
+-->
<xsl:template match="a[@href != '']">
<xref>
<xsl:attribute name="linkend">
@@ -206,21 +227,24 @@
<!-- Images -->
<!-- Images and image maps -->
<xsl:template match="img">
- <xsl:variable name="tag_name">
- <xsl:choose>
- <xsl:when
- test="boolean(parent::p) and
+ <!-- let's not include confluence generated images -->
+ <xsl:if test="@class != 'rendericon'">
+ <xsl:variable name="tag_name">
+ <xsl:choose>
+ <xsl:when
+ test="boolean(parent::p) and
boolean(normalize-space(parent::p/text()))">
- <xsl:text>inlinemediaobject</xsl:text>
- </xsl:when>
- <xsl:otherwise>mediaobject</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:element name="{$tag_name}">
- <imageobject>
- <xsl:call-template name="process.image"/>
- </imageobject>
- </xsl:element>
+ <xsl:text>inlinemediaobject</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>mediaobject</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:element name="{$tag_name}">
+ <imageobject>
+ <xsl:call-template name="process.image"/>
+ </imageobject>
+ </xsl:element>
+ </xsl:if>
</xsl:template>
<xsl:template name="process.image">
<imagedata>
@@ -418,12 +442,20 @@
<xsl:call-template name="generate-colspecs">
<xsl:with-param name="count" select="$column_count"/>
</xsl:call-template>
+
+ <!--
+ the "id already exists" problem is a known bug in dbdoclet when generating pdf report
+ as a workaround the thead for the first tr has been replaced by a tbody
<thead>
<xsl:apply-templates select="tr[1]"/>
</thead>
<tbody>
<xsl:apply-templates select="tr[position() != 1]"/>
</tbody>
+ -->
+ <tbody>
+ <xsl:apply-templates select="tr"/>
+ </tbody>
</tgroup>
</informaltable>
</xsl:template>
@@ -448,6 +480,9 @@
<xsl:with-param name="count"
select="$column_count"/>
</xsl:call-template>
+ <!--
+ the "id already exists" problem is a known bug in dbdoclet when generating pdf report
+ as a workaround the thead for the first tr has been replaced by a tbody
<thead>
<xsl:apply-templates select="./tbody/tr[1]"/>
</thead>
@@ -455,6 +490,11 @@
<xsl:apply-templates
select="./tbody/tr[position() != 1]"/>
</tbody>
+ -->
+ <tbody>
+ <xsl:apply-templates
+ select="./tbody/tr"/>
+ </tbody>
</tgroup>
</informaltable>
</xsl:otherwise>
diff --git a/tooling/maven/maven-html-to-docbook/src/main/java/org/apache/camel/maven/GenerateDocBookMojo.java b/tooling/maven/maven-html-to-docbook/src/main/java/org/apache/camel/maven/GenerateDocBookMojo.java
index 7a4571a..d2352cd 100644
--- a/tooling/maven/maven-html-to-docbook/src/main/java/org/apache/camel/maven/GenerateDocBookMojo.java
+++ b/tooling/maven/maven-html-to-docbook/src/main/java/org/apache/camel/maven/GenerateDocBookMojo.java
@@ -95,9 +95,16 @@
/**
* Location of the output directory.
*
- * @parameter expression="${project.build.directory}/docbkx/source"
+ * @parameter expression="${project.build.directory}/docbkx/docbkx-source"
*/
private String outputPath;
+
+ /**
+ * Location of the output directory for wiki source.
+ *
+ * @parameter expression="${project.build.directory}/docbkx/wiki-source"
+ */
+ private String wikiOutputPath;
/**
* @parameter expression="${title}"
@@ -109,6 +116,12 @@
* @parameter expression="${subtitle}"
*/
private String subtitle;
+
+ /**
+ * @parameter expression="${mainFilename}" default-value="manual"
+ * @required
+ */
+ private String mainFilename;
/**
* @parameter expression="${version}" default-value="${project.version}"
@@ -123,27 +136,27 @@
/**
* Location of image files.
*
- * @parameter expression="${project.build.directory}/docbkx/images"
+ * @parameter expression="${project.build.directory}/site/book/images"
*
*/
private String imageLocation;
private String chapterId;
- private String chapterTitle;
public void execute() throws MojoExecutionException {
File outputDir = new File(outputPath);
+ File wikiOutputDir = new File(wikiOutputPath);
File imageDir = new File(imageLocation);
if (!outputDir.exists()) {
outputDir.mkdirs();
imageDir.mkdirs();
+ wikiOutputDir.mkdirs();
}
this.createMainXML();
for (int i = 0; i < resources.length; ++i) {
this.setChapterId( removeExtension(resources[i]));
- this.setChapterTitle( removeExtension(resources[i]));
process(resources[i]);
}
@@ -159,7 +172,9 @@
public void process(String resource) {
Tidy tidy = new Tidy();
- ByteArrayOutputStream out;
+ ByteArrayOutputStream out = null;
+ BufferedOutputStream output = null;
+ BufferedOutputStream wikiOutput = null;
tidy.setXmlOut(true);
try {
@@ -184,14 +199,13 @@
// These attributes will be used by xsl to
Element element = (Element) node;
element.setAttribute("chapterId", chapterId);
- element.setAttribute("chapterTitle", chapterTitle);
element.setAttribute("baseURL", baseURL);
- element.setAttribute("imageLocation", "..\\images\\");
+ element.setAttribute("imageLocation", "../images/");
DOMSource source = new DOMSource(node);
- BufferedOutputStream output = new BufferedOutputStream(
+ output = new BufferedOutputStream(
new FileOutputStream(outputPath + File.separator
+ removeExtension(resource) + ".xml"));
StreamResult result = new StreamResult(output);
@@ -201,6 +215,14 @@
.newTransformer(new StreamSource(xslFile));
transformer.transform(source, result);
+ // generate the wiki source for debugging
+ wikiOutput = new BufferedOutputStream(
+ new FileOutputStream(wikiOutputPath + File.separator
+ + removeExtension(resource) + ".html"));
+ result = new StreamResult(wikiOutput);
+ transformer = tFactory.newTransformer();
+ transformer.transform(source, result);
+
break;
}
@@ -208,6 +230,14 @@
} catch (Exception e) {
e.printStackTrace();
+ }finally {
+ try {
+ if(output != null)
+ output.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
}
@@ -219,7 +249,7 @@
try {
PrintWriter out = new PrintWriter(new FileWriter(outputPath
- + File.separator + title + ".xml"));
+ + File.separator + mainFilename + ".xml"));
out
.println("<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.4//EN\" \"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd\" ");
@@ -370,14 +400,7 @@
this.chapterId = chapterId;
}
- public String getChapterTitle() {
- return chapterTitle;
- }
- public void setChapterTitle(String chapterTitle) {
- this.chapterTitle = chapterTitle;
- }
-
public String removeExtension(String resource) {
int index = resource.indexOf('.');
return resource.substring(0, index);
diff --git a/tooling/pom.xml b/tooling/pom.xml
index 2014ada..883f747 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -33,6 +33,7 @@
<modules>
<module>archetypes</module>
+ <module>camel-book</module>
<module>maven</module>
</modules>