Author: jstrachan
Date: Fri Apr 27 08:38:08 2007
New Revision: 533145

URL: http://svn.apache.org/viewvc?view=rev&rev=533145
Log:
added a mail component using spring + JavaMail

Added:
    activemq/camel/trunk/camel-mail/
    activemq/camel/trunk/camel-mail/pom.xml   (with props)
    activemq/camel/trunk/camel-mail/src/
    activemq/camel/trunk/camel-mail/src/main/
    activemq/camel/trunk/camel-mail/src/main/java/
    activemq/camel/trunk/camel-mail/src/main/java/org/
    activemq/camel/trunk/camel-mail/src/main/java/org/apache/
    activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/
    activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/JavaMailConnection.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderAccessException.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderNamesAccessException.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/RuntimeMailException.java
   (with props)
    
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/package.html
   (with props)
    activemq/camel/trunk/camel-mail/src/main/resources/
    activemq/camel/trunk/camel-mail/src/main/resources/META-INF/
    activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/
    activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/imap
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/nntp
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/pop
    
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/smtp
    activemq/camel/trunk/camel-mail/src/test/
    activemq/camel/trunk/camel-mail/src/test/java/
    activemq/camel/trunk/camel-mail/src/test/java/org/
    activemq/camel/trunk/camel-mail/src/test/java/org/apache/
    activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/
    activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/
    
activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/
    
activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
   (with props)
    activemq/camel/trunk/camel-mail/src/test/resources/
    activemq/camel/trunk/camel-mail/src/test/resources/log4j.properties   (with 
props)

Added: activemq/camel/trunk/camel-mail/pom.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/pom.xml?view=auto&rev=533145
==============================================================================
--- activemq/camel/trunk/camel-mail/pom.xml (added)
+++ activemq/camel/trunk/camel-mail/pom.xml Fri Apr 27 08:38:08 2007
@@ -0,0 +1,72 @@
+<?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-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-mail</artifactId>
+  <name>Camel :: Mail</name>
+  <description>Camel Mail support</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.mail</groupId>
+      <artifactId>mail</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: activemq/camel/trunk/camel-mail/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/JavaMailConnection.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/JavaMailConnection.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/JavaMailConnection.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/JavaMailConnection.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,55 @@
+/**
+ *
+ * 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.mail;
+
+import org.springframework.mail.MailAuthenticationException;
+import org.springframework.mail.MailException;
+import org.springframework.mail.MailSendException;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+
+import javax.mail.AuthenticationFailedException;
+import javax.mail.MessagingException;
+import javax.mail.Transport;
+
+/**
+ * An extension of Spring's [EMAIL PROTECTED] JavaMailSenderImpl} to provide 
helper methods for listening for new mail
+ *
+ * @version $Revision: 1.1 $
+ */
+public class JavaMailConnection extends JavaMailSenderImpl {
+
+    /**
+     * Create a new [EMAIL PROTECTED] Transport} which can then be used to 
consume new messages
+     *
+     * @throws MailAuthenticationException in case of authentication failure
+     * @throws MailSendException           in case of failure when sending a 
message
+     */
+    public Transport createTransport() throws MailException {
+        try {
+            Transport transport = getTransport(getSession());
+            transport.connect(getHost(), getPort(), getUsername(), 
getPassword());
+            return transport;
+        }
+        catch (AuthenticationFailedException ex) {
+            throw new MailAuthenticationException(ex);
+        }
+        catch (MessagingException ex) {
+            throw new MailSendException("Mail server connection failed", ex);
+        }
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/JavaMailConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,80 @@
+/**
+ *
+ * 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.mail;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A Strategy used to convert between a Camel [EMAIL PROTECTED] and [EMAIL 
PROTECTED] to and from a
+ * Mail [EMAIL PROTECTED] MimeMessage}
+ *
+ * @version $Revision: 521240 $
+ */
+public class MailBinding {
+    public void populateMailMessage(MimeMessage mimeMessage, MailExchange 
exchange) {
+        try {
+            appendMailHeaders(mimeMessage, exchange.getIn());
+            mimeMessage.setContent(exchange.getIn().getBody(), "body");
+        }
+        catch (Exception e) {
+            throw new RuntimeMailException("Failed to populate body due to: " 
+ e + ". Exchange: " + exchange, e);
+        }
+    }
+
+    /**
+     * Extracts the body from the Mail message
+     *
+     * @param exchange
+     * @param message
+     */
+    public Object extractBodyFromMail(MailExchange exchange, Message message) {
+        try {
+            return message.getContent();
+        }
+        catch (Exception e) {
+            throw new RuntimeMailException("Failed to extract body due to: " + 
e + ". Message: " + message, e);
+        }
+    }
+
+    /**
+     * Appends the Mail headers from the Camel [EMAIL PROTECTED] MailMessage}
+     */
+    protected void appendMailHeaders(MimeMessage mimeMessage, MailMessage 
camelMessage) throws MessagingException {
+        Set<Map.Entry<String, Object>> entries = 
camelMessage.getHeaders().entrySet();
+        for (Map.Entry<String, Object> entry : entries) {
+            String headerName = entry.getKey();
+            Object headerValue = entry.getValue();
+            if (headerValue != null) {
+                if (shouldOutputHeader(camelMessage, headerName, headerValue)) 
{
+                    mimeMessage.setHeader(headerName, headerValue.toString());
+                }
+            }
+        }
+    }
+
+    /**
+     * Strategy to allow filtering of headers which are put on the Mail message
+     */
+    protected boolean shouldOutputHeader(MailMessage camelMessage, String 
headerName, Object headerValue) {
+        return true;
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,98 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.IntrospectionSupport;
+
+import java.util.Map;
+import java.net.URI;
+import java.net.URL;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class MailComponent extends DefaultComponent<MailExchange> {
+    public static final String QUEUE_PREFIX = "queue:";
+    public static final String TOPIC_PREFIX = "topic:";
+    private MailConfiguration configuration;
+
+    /**
+     * Static builder method
+     */
+    public static MailComponent mailComponent() {
+        return new MailComponent();
+    }
+
+    /**
+     * Static builder method
+     */
+    public static MailComponent mailComponent(MailConfiguration configuration) 
{
+        return new MailComponent(configuration);
+    }
+
+    public MailComponent() {
+        this.configuration = new MailConfiguration();
+    }
+
+    public MailComponent(MailConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    public MailComponent(CamelContext context) {
+        super(context);
+        this.configuration = new MailConfiguration();
+    }
+
+    @Override
+    protected Endpoint<MailExchange> createEndpoint(String uri, String 
remaining, Map parameters) throws Exception {
+
+        MailConfiguration config = getConfiguration().copy();
+        config.configure(new URI(uri));
+        //config.configure(new URL(uri));
+
+        // lets make sure we copy the configuration as each endpoint can 
customize its own version
+        MailEndpoint endpoint = new MailEndpoint(uri, this, config);
+
+        IntrospectionSupport.setProperties(endpoint.getConfiguration(), 
parameters);
+        return endpoint;
+    }
+
+    public MailConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    /**
+     * Sets the Mail configuration
+     *
+     * @param configuration the configuration to use by default for endpoints
+     */
+    public void setConfiguration(MailConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+    /**
+     * A strategy method allowing the URI destination to be translated into 
the actual Mail destination name
+     * (say by looking up in JNDI or something)
+     */
+    protected String convertPathToActualDestination(String path) {
+        return path;
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,172 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.RuntimeCamelException;
+
+import javax.mail.Session;
+import java.net.URI;
+import java.util.Properties;
+
+/**
+ * Represents the configuration data for communicating over email
+ *
+ * @version $Revision: 532790 $
+ */
+public class MailConfiguration implements Cloneable {
+    private String defaultEncoding;
+    private String host;
+    private Properties javaMailProperties;
+    private String password;
+    private String protocol;
+    private Session session;
+    private String username;
+    private int port = -1;
+
+    public MailConfiguration() {
+    }
+
+    /**
+     * Returns a copy of this configuration
+     */
+    public MailConfiguration copy() {
+        try {
+            return (MailConfiguration) clone();
+        }
+        catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
+
+    public void configure(URI uri) {
+        String value = uri.getHost();
+        if (value != null) {
+            setHost(value);
+        }
+
+        String scheme = uri.getScheme();
+        if (scheme != null) {
+            setProtocol(scheme);
+        }
+        String userInfo = uri.getUserInfo();
+        if (userInfo != null) {
+            setUsername(userInfo);
+        }
+        int port = uri.getPort();
+        if (port >= 0) {
+            setPort(port);
+        }
+    }
+
+    public JavaMailConnection createJavaMailConnection(MailEndpoint 
mailEndpoint) {
+        JavaMailConnection answer = new JavaMailConnection();
+        if (defaultEncoding != null) {
+            answer.setDefaultEncoding(defaultEncoding);
+        }
+        //answer.setDefaultFileTypeMap(fileTypeMap);
+        if (host != null) {
+            answer.setHost(host);
+        }
+        if (javaMailProperties != null) {
+            answer.setJavaMailProperties(javaMailProperties);
+        }
+        if (port >= 0) {
+            answer.setPort(port);
+        }
+        if (password != null) {
+            answer.setPassword(password);
+        }
+        if (protocol != null) {
+            answer.setProtocol(protocol);
+        }
+        if (session != null) {
+            answer.setSession(session);
+        }
+        if (username != null) {
+            answer.setUsername(username);
+        }
+        return answer;
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public String getDefaultEncoding() {
+        return defaultEncoding;
+    }
+
+    public void setDefaultEncoding(String defaultEncoding) {
+        this.defaultEncoding = defaultEncoding;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public Properties getJavaMailProperties() {
+        return javaMailProperties;
+    }
+
+    public void setJavaMailProperties(Properties javaMailProperties) {
+        this.javaMailProperties = javaMailProperties;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public void setSession(Session session) {
+        this.session = session;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,68 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+
+import javax.mail.Message;
+import javax.mail.Transport;
+import javax.mail.event.TransportEvent;
+import javax.mail.event.TransportListener;
+
+/**
+ * A [EMAIL PROTECTED] Consumer} which consumes messages from JavaMail using a 
[EMAIL PROTECTED] Transport} and dispatches them
+ * to the [EMAIL PROTECTED] Processor}
+ *
+ * @version $Revision: 523430 $
+ */
+public class MailConsumer extends DefaultConsumer<MailExchange> implements 
TransportListener {
+    private final MailEndpoint endpoint;
+    private final Transport transport;
+
+    public MailConsumer(MailEndpoint endpoint, Processor<MailExchange> 
processor, Transport transport) {
+        super(endpoint, processor);
+        this.endpoint = endpoint;
+        this.transport = transport;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        transport.addTransportListener(this);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        transport.close();
+        super.doStop();
+    }
+
+    public void messageDelivered(TransportEvent transportEvent) {
+        Message message = transportEvent.getMessage();
+        MailExchange exchange = endpoint.createExchange(message);
+        getProcessor().process(exchange);
+    }
+
+    public void messageNotDelivered(TransportEvent transportEvent) {
+    }
+
+    public void messagePartiallyDelivered(TransportEvent transportEvent) {
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,103 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.springframework.mail.javamail.JavaMailSender;
+
+import javax.mail.Message;
+import javax.mail.Transport;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class MailEndpoint extends DefaultEndpoint<MailExchange> {
+    private MailBinding binding;
+    private MailConfiguration configuration;
+
+    public MailEndpoint(String uri, MailComponent component,  
MailConfiguration configuration) {
+        super(uri, component);
+        this.configuration = configuration;
+    }
+
+    public Producer<MailExchange> createProducer() throws Exception {
+        JavaMailSender sender = configuration.createJavaMailConnection(this);
+        return createProducer(sender);
+    }
+
+    /**
+     * Creates a producer using the given sender
+     */
+    public Producer<MailExchange> createProducer(JavaMailSender sender) throws 
Exception {
+        return startService(new MailProducer(this, sender));
+    }
+
+    public Consumer<MailExchange> createConsumer(Processor<MailExchange> 
processor) throws Exception {
+        JavaMailConnection connection = 
configuration.createJavaMailConnection(this);
+        return createConsumer(processor, connection.createTransport());
+    }
+
+    /**
+     * Creates a consumer using the given processor and transport
+     *
+     * @param processor the processor to use to process the messages
+     * @param transport the JavaMail transport to use for inbound messages
+     * @return a newly created consumer
+     * @throws Exception if the consumer cannot be created
+     */
+    public Consumer<MailExchange> createConsumer(Processor<MailExchange> 
processor, Transport transport) throws Exception {
+        return startService(new MailConsumer(this, processor, transport));
+    }
+
+    public MailExchange createExchange() {
+        return new MailExchange(getContext(), getBinding());
+    }
+
+    public MailExchange createExchange(Message message) {
+        return new MailExchange(getContext(), getBinding(), message);
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public MailBinding getBinding() {
+        if (binding == null) {
+            binding = new MailBinding();
+        }
+        return binding;
+    }
+
+    /**
+     * Sets the binding used to convert from a Camel message to and from a 
Mail message
+     *
+     * @param binding the binding to use
+     */
+    public void setBinding(MailBinding binding) {
+        this.binding = binding;
+    }
+
+       public boolean isSingleton() {
+               return false;
+       }
+
+    public MailConfiguration getConfiguration() {
+        return configuration;
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,83 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+
+import javax.mail.Message;
+
+/**
+ * Represents an [EMAIL PROTECTED] Exchange} for working with Mail
+ *
+ * @version $Revision:520964 $
+ */
+public class MailExchange extends DefaultExchange {
+    private MailBinding binding;
+
+    public MailExchange(CamelContext context, MailBinding binding) {
+        super(context);
+        this.binding = binding;
+    }
+
+    public MailExchange(CamelContext context, MailBinding binding, Message 
message) {
+        this(context, binding);
+        setIn(new MailMessage(message));
+    }
+
+    @Override
+    public MailMessage getIn() {
+        return (MailMessage) super.getIn();
+    }
+
+    @Override
+    public MailMessage getOut() {
+        return (MailMessage) super.getOut();
+    }
+
+    @Override
+    public MailMessage getFault() {
+        return (MailMessage) super.getFault();
+    }
+
+    public MailBinding getBinding() {
+        return binding;
+    }
+
+    @Override
+    public Exchange newInstance() {
+        return new MailExchange(getContext(), binding);
+    }
+
+    // Expose Email APIs
+    //-------------------------------------------------------------------------
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+
+    @Override
+    protected MailMessage createInMessage() {
+        return new MailMessage();
+    }
+
+    @Override
+    protected MailMessage createOutMessage() {
+        return new MailMessage();
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailExchange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,120 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.impl.DefaultMessage;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import java.util.Enumeration;
+import java.util.Map;
+
+/**
+ * Represents a [EMAIL PROTECTED] org.apache.camel.Message} for working with 
Mail
+ *
+ * @version $Revision:520964 $
+ */
+public class MailMessage extends DefaultMessage {
+    private Message mailMessage;
+
+    public MailMessage() {
+    }
+
+    public MailMessage(Message message) {
+        this.mailMessage = message;
+    }
+
+    @Override
+    public String toString() {
+        if (mailMessage != null) {
+            return "MailMessage: " + mailMessage;
+        }
+        else {
+            return "MailMessage: " + getBody();}
+    }
+
+    @Override
+    public MailExchange getExchange() {
+        return (MailExchange) super.getExchange();
+    }
+
+    /**
+     * Returns the underlying Mail message
+     *
+     * @return the underlying Mail message
+     */
+    public Message getMessage() {
+        return mailMessage;
+    }
+
+    public void setMessage(Message mailMessage) {
+        this.mailMessage = mailMessage;
+    }
+
+    public Object getHeader(String name) {
+        Object answer = null;
+        if (mailMessage != null) {
+            try {
+                answer = mailMessage.getHeader(name);
+            }
+            catch (MessagingException e) {
+                throw new MessageHeaderAccessException(name, e);
+            }
+        }
+        if (answer == null) {
+            answer = super.getHeader(name);
+        }
+        return answer;
+    }
+
+    @Override
+    public MailMessage newInstance() {
+        return new MailMessage();
+    }
+
+    @Override
+    protected Object createBody() {
+        if (mailMessage != null) {
+            return 
getExchange().getBinding().extractBodyFromMail(getExchange(), mailMessage);
+        }
+        return null;
+    }
+
+    @Override
+    protected void populateInitialHeaders(Map<String, Object> map) {
+        if (mailMessage != null) {
+            Enumeration names;
+            try {
+                names = mailMessage.getAllHeaders();
+            }
+            catch (MessagingException e) {
+                throw new MessageHeaderNamesAccessException(e);
+            }
+            while (names.hasMoreElements()) {
+                String name = names.nextElement().toString();
+                try {
+                    Object value = mailMessage.getHeader(name);
+                    map.put(name, value);
+                }
+                catch (MessagingException e) {
+                    throw new MessageHeaderAccessException(name, e);
+                }
+            }
+        }
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,50 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessagePreparator;
+
+import javax.mail.internet.MimeMessage;
+
+/**
+ * @version $Revision: 525547 $
+ */
+public class MailProducer extends DefaultProducer<MailExchange> {
+    private static final transient Log log = 
LogFactory.getLog(MailProducer.class);
+    private final MailEndpoint endpoint;
+    private final JavaMailSender sender;
+
+    public MailProducer(MailEndpoint endpoint, JavaMailSender sender) {
+        super(endpoint);
+        this.endpoint = endpoint;
+        this.sender = sender;
+    }
+
+
+    public void process(final MailExchange exchange) {
+        sender.send(new MimeMessagePreparator() {
+            public void prepare(MimeMessage mimeMessage) throws Exception {
+                endpoint.getBinding().populateMailMessage(mimeMessage, 
exchange);
+            }
+        });
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MailProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderAccessException.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderAccessException.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderAccessException.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderAccessException.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,37 @@
+/**
+ *
+ * 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.mail;
+
+import javax.mail.MessagingException;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class MessageHeaderAccessException extends RuntimeMailException {
+    private static final long serialVersionUID = -3996286386119163309L;
+    private String propertyName;
+
+    public MessageHeaderAccessException(String propertyName, 
MessagingException e) {
+        super("Error accessing header: " + propertyName, e);
+        this.propertyName = propertyName;
+    }
+
+    public String getPropertyName() {
+        return propertyName;
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderAccessException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderNamesAccessException.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderNamesAccessException.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderNamesAccessException.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderNamesAccessException.java
 Fri Apr 27 08:38:08 2007
@@ -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.mail;
+
+import javax.mail.MessagingException;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class MessageHeaderNamesAccessException extends RuntimeMailException {
+    private static final long serialVersionUID = -6744171518099741324L;
+
+    public MessageHeaderNamesAccessException(MessagingException e) {
+        super("Failed to acess the Mail message property names", e);
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/MessageHeaderNamesAccessException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/RuntimeMailException.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/RuntimeMailException.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/RuntimeMailException.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/RuntimeMailException.java
 Fri Apr 27 08:38:08 2007
@@ -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.
+ */
+package org.apache.camel.component.mail;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class RuntimeMailException extends RuntimeException {
+    private static final long serialVersionUID = -2141493732308871761L;
+
+    public RuntimeMailException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/RuntimeMailException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/package.html
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/package.html?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/package.html
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/package.html
 Fri Apr 27 08:38:08 2007
@@ -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/email.html";>Email 
Component</a>
+
+</body>
+</html>

Propchange: 
activemq/camel/trunk/camel-mail/src/main/java/org/apache/camel/component/mail/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/imap
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/imap?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/imap
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/imap
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.mail.MailComponent

Added: 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/nntp
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/nntp?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/nntp
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/nntp
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.mail.MailComponent

Added: 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/pop
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/pop?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/pop
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/pop
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.mail.MailComponent

Added: 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/smtp
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/smtp?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/smtp
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/main/resources/META-INF/services/org/apache/camel/component/smtp
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.mail.MailComponent

Added: 
activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java?view=auto&rev=533145
==============================================================================
--- 
activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
 (added)
+++ 
activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
 Fri Apr 27 08:38:08 2007
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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.mail;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class MailComponentTest extends ContextTestSupport {
+
+    public void testMailEndpointsAreConfiguredProperlyWhenUsingSmtp() throws 
Exception {
+        MailEndpoint endpoint = resolveMandatoryEndpoint("smtp://[EMAIL 
PROTECTED]:30/subject");
+        MailConfiguration config = endpoint.getConfiguration();
+        assertEquals("getProtocol()", "smtp", config.getProtocol());
+        assertEquals("getHost()", "myhost", config.getHost());
+        assertEquals("getPort()", 30, config.getPort());
+        assertEquals("getUsername()", "james", config.getUsername());
+    }
+
+    public void testMailEndpointsAreConfiguredProperlyWhenUsingImap() throws 
Exception {
+        MailEndpoint endpoint = resolveMandatoryEndpoint("imap://[EMAIL 
PROTECTED]:30/subject");
+        MailConfiguration config = endpoint.getConfiguration();
+        assertEquals("getProtocol()", "imap", config.getProtocol());
+        assertEquals("getHost()", "myhost", config.getHost());
+        assertEquals("getPort()", 30, config.getPort());
+        assertEquals("getUsername()", "james", config.getUsername());
+    }
+
+    public void testMailEndpointsAreConfiguredProperlyWhenUsingPop() throws 
Exception {
+        MailEndpoint endpoint = resolveMandatoryEndpoint("pop://[EMAIL 
PROTECTED]:30/subject");
+        MailConfiguration config = endpoint.getConfiguration();
+        assertEquals("getProtocol()", "pop", config.getProtocol());
+        assertEquals("getHost()", "myhost", config.getHost());
+        assertEquals("getPort()", 30, config.getPort());
+        assertEquals("getUsername()", "james", config.getUsername());
+    }
+
+    @Override
+    protected MailEndpoint resolveMandatoryEndpoint(String uri) {
+        Endpoint endpoint = super.resolveMandatoryEndpoint(uri);
+        return assertIsInstanceOf(MailEndpoint.class, endpoint);
+    }
+}

Propchange: 
activemq/camel/trunk/camel-mail/src/test/java/org/apache/camel/component/mail/MailComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-mail/src/test/resources/log4j.properties
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-mail/src/test/resources/log4j.properties?view=auto&rev=533145
==============================================================================
--- activemq/camel/trunk/camel-mail/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-mail/src/test/resources/log4j.properties Fri Apr 
27 08:38:08 2007
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## 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.activemq=DEBUG
+#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

Propchange: activemq/camel/trunk/camel-mail/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to