001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.component.gae.mail;
018    
019    import com.google.appengine.api.mail.MailService;
020    import com.google.appengine.api.mail.MailService.Message;
021    import com.google.appengine.api.mail.MailServiceFactory;
022    
023    import org.apache.camel.Component;
024    import org.apache.camel.Consumer;
025    import org.apache.camel.Processor;
026    import org.apache.camel.Producer;
027    import org.apache.camel.component.gae.bind.OutboundBinding;
028    import org.apache.camel.component.gae.bind.OutboundBindingSupport;
029    import org.apache.camel.impl.DefaultEndpoint;
030    
031    /**
032     * Represents a <a href="http://camel.apache.org/gmail.html">Google App Engine Mail endpoint</a>.
033     */
034    public class GMailEndpoint extends DefaultEndpoint implements OutboundBindingSupport<GMailEndpoint, Message, Void> {
035    
036        private OutboundBinding<GMailEndpoint, Message, Void> outboundBinding;
037        
038        private MailService mailService;
039        
040        private String sender;
041        
042        private String subject;
043        
044        private String to;
045        
046        private String cc;
047        
048        private String bcc;
049        
050        public GMailEndpoint(String endpointUri, Component component, String sender) {
051            super(endpointUri, component);
052            this.sender = sender;
053            this.mailService = MailServiceFactory.getMailService();
054        }
055        
056        public OutboundBinding<GMailEndpoint, Message, Void> getOutboundBinding() {
057            return outboundBinding;
058        }
059    
060        public void setOutboundBinding(OutboundBinding<GMailEndpoint, Message, Void> outboundBinding) {
061            this.outboundBinding = outboundBinding;
062        }
063        
064        public MailService getMailService() {
065            return mailService;
066        }
067    
068        public String getSender() {
069            return sender;
070        }
071        
072        public String getSubject() {
073            return subject;
074        }
075    
076        public void setSubject(String subject) {
077            this.subject = subject;
078        }
079    
080        public String getTo() {
081            return to;
082        }
083    
084        public void setTo(String to) {
085            this.to = to;
086        }
087    
088        public String getCc() {
089            return cc;
090        }
091    
092        public void setCc(String cc) {
093            this.cc = cc;
094        }
095    
096        public String getBcc() {
097            return bcc;
098        }
099    
100        public void setBcc(String bcc) {
101            this.bcc = bcc;
102        }
103    
104        public Consumer createConsumer(Processor processor) throws Exception {
105            throw new UnsupportedOperationException("consumption from gmail endpoint not supported");
106        }
107    
108        public Producer createProducer() throws Exception {
109            return new GMailProducer(this);
110        }
111    
112        public boolean isSingleton() {
113            return true;
114        }
115    
116    }