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