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    
022    import org.apache.camel.Consumer;
023    import org.apache.camel.Processor;
024    import org.apache.camel.Producer;
025    import org.apache.camel.component.gae.bind.OutboundBinding;
026    import org.apache.camel.component.gae.bind.OutboundBindingSupport;
027    import org.apache.camel.impl.DefaultEndpoint;
028    
029    /**
030     * Represents a <a href="http://camel.apache.org/todo.html">Google App Engine Mail endpoint</a>.
031     */
032    public class GMailEndpoint extends DefaultEndpoint implements OutboundBindingSupport<GMailEndpoint, Message, Void> {
033    
034        private OutboundBinding<GMailEndpoint, Message, Void> outboundBinding;
035        
036        private MailService mailService;
037        
038        private String sender;
039        
040        private String subject;
041        
042        private String to;
043        
044        private String cc;
045        
046        private String bcc;
047        
048        public GMailEndpoint(String endpointUri, String sender) {
049            super(endpointUri);
050            this.sender = sender;
051        }
052        
053        public OutboundBinding<GMailEndpoint, Message, Void> getOutboundBinding() {
054            return outboundBinding;
055        }
056    
057        public void setOutboundBinding(OutboundBinding<GMailEndpoint, Message, Void> outboundBinding) {
058            this.outboundBinding = outboundBinding;
059        }
060        
061        public String getSender() {
062            return sender;
063        }
064        
065        public MailService getMailService() {
066            return mailService;
067        }
068    
069        public void setMailService(MailService mailService) {
070            this.mailService = mailService;
071        }
072    
073        public String getSubject() {
074            return subject;
075        }
076    
077        public void setSubject(String subject) {
078            this.subject = subject;
079        }
080    
081        public String getTo() {
082            return to;
083        }
084    
085        public void setTo(String to) {
086            this.to = to;
087        }
088    
089        public String getCc() {
090            return cc;
091        }
092    
093        public void setCc(String cc) {
094            this.cc = cc;
095        }
096    
097        public String getBcc() {
098            return bcc;
099        }
100    
101        public void setBcc(String bcc) {
102            this.bcc = bcc;
103        }
104    
105        public Consumer createConsumer(Processor processor) throws Exception {
106            throw new UnsupportedOperationException("consumption from gmail endpoint not supported");
107        }
108    
109        public Producer createProducer() throws Exception {
110            return new GMailProducer(this);
111        }
112    
113        public boolean isSingleton() {
114            return true;
115        }
116    
117    }