Coverage Report - org.apache.camel.spring.EndpointFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
EndpointFactoryBean
65% 
100% 
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.spring;
 19  
 
 20  
 import org.apache.camel.CamelContext;
 21  
 import org.apache.camel.Endpoint;
 22  
 import static org.apache.camel.util.ObjectHelper.notNull;
 23  
 import org.springframework.beans.factory.FactoryBean;
 24  
 
 25  
 /**
 26  
  * A {@link FactoryBean} which instantiates {@link Endpoint} objects
 27  
  *
 28  
  * @version $Revision: 1.1 $
 29  
  */
 30  11
 public class EndpointFactoryBean implements FactoryBean {
 31  
     private CamelContext context;
 32  
     private String uri;
 33  
     private Endpoint endpoint;
 34  
     private boolean singleton;
 35  
 
 36  
     public Object getObject() throws Exception {
 37  15
         if (endpoint == null) {
 38  11
             endpoint = createEndpoint();
 39  
         }
 40  15
         return endpoint;
 41  
     }
 42  
 
 43  
     public Class getObjectType() {
 44  7
         return Endpoint.class;
 45  
     }
 46  
 
 47  
     public boolean isSingleton() {
 48  26
         return singleton;
 49  
     }
 50  
 
 51  
     public CamelContext getContext() {
 52  0
         return context;
 53  
     }
 54  
 
 55  
     /**
 56  
      * Sets the context to use to resolve endpoints
 57  
      *
 58  
      * @param context the context used to resolve endpoints
 59  
      */
 60  
     public void setContext(CamelContext context) {
 61  11
         this.context = context;
 62  11
     }
 63  
 
 64  
     public Endpoint getEndpoint() {
 65  0
         return endpoint;
 66  
     }
 67  
 
 68  
     public void setEndpoint(Endpoint endpoint) {
 69  0
         this.endpoint = endpoint;
 70  0
     }
 71  
 
 72  
     public void setSingleton(boolean singleton) {
 73  0
         this.singleton = singleton;
 74  0
     }
 75  
 
 76  
     public String getUri() {
 77  0
         return uri;
 78  
     }
 79  
 
 80  
     /**
 81  
      * Sets the URI to use to resolve the endpoint
 82  
      *
 83  
      * @param uri the URI used to set the endpoint
 84  
      */
 85  
     public void setUri(String uri) {
 86  11
         this.uri = uri;
 87  11
     }
 88  
 
 89  
     protected Endpoint createEndpoint() {
 90  11
         notNull(context, "context");
 91  11
         notNull(uri, "uri");
 92  11
         return context.getEndpoint(uri);
 93  
     }
 94  
 
 95  
 }