Coverage Report - org.apache.camel.component.mail.MailComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
MailComponent
45% 
N/A 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.component.mail;
 19  
 
 20  
 import org.apache.camel.CamelContext;
 21  
 import org.apache.camel.Endpoint;
 22  
 import org.apache.camel.impl.DefaultComponent;
 23  
 import org.apache.camel.util.IntrospectionSupport;
 24  
 
 25  
 import java.util.Map;
 26  
 import java.net.URI;
 27  
 import java.net.URL;
 28  
 
 29  
 /**
 30  
  * @version $Revision:520964 $
 31  
  */
 32  
 public class MailComponent extends DefaultComponent<MailExchange> {
 33  
     public static final String QUEUE_PREFIX = "queue:";
 34  
     public static final String TOPIC_PREFIX = "topic:";
 35  
     private MailConfiguration configuration;
 36  
 
 37  
     /**
 38  
      * Static builder method
 39  
      */
 40  
     public static MailComponent mailComponent() {
 41  0
         return new MailComponent();
 42  
     }
 43  
 
 44  
     /**
 45  
      * Static builder method
 46  
      */
 47  
     public static MailComponent mailComponent(MailConfiguration configuration) {
 48  0
         return new MailComponent(configuration);
 49  
     }
 50  
 
 51  8
     public MailComponent() {
 52  8
         this.configuration = new MailConfiguration();
 53  8
     }
 54  
 
 55  0
     public MailComponent(MailConfiguration configuration) {
 56  0
         this.configuration = configuration;
 57  0
     }
 58  
 
 59  
     public MailComponent(CamelContext context) {
 60  0
         super(context);
 61  0
         this.configuration = new MailConfiguration();
 62  0
     }
 63  
 
 64  
     @Override
 65  
     protected Endpoint<MailExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
 66  
 
 67  12
         MailConfiguration config = getConfiguration().copy();
 68  12
         config.configure(new URI(uri));
 69  
 
 70  
         // lets make sure we copy the configuration as each endpoint can customize its own version
 71  12
         MailEndpoint endpoint = new MailEndpoint(uri, this, config);
 72  
 
 73  12
         IntrospectionSupport.setProperties(endpoint.getConfiguration(), parameters);
 74  12
         return endpoint;
 75  
     }
 76  
 
 77  
     public MailConfiguration getConfiguration() {
 78  12
         return configuration;
 79  
     }
 80  
 
 81  
     /**
 82  
      * Sets the Mail configuration
 83  
      *
 84  
      * @param configuration the configuration to use by default for endpoints
 85  
      */
 86  
     public void setConfiguration(MailConfiguration configuration) {
 87  0
         this.configuration = configuration;
 88  0
     }
 89  
 
 90  
     /**
 91  
      * A strategy method allowing the URI destination to be translated into the actual Mail destination name
 92  
      * (say by looking up in JNDI or something)
 93  
      */
 94  
     protected String convertPathToActualDestination(String path) {
 95  0
         return path;
 96  
     }
 97  
 }