Coverage Report - org.mule.config.spring.factories.SimpleServiceFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleServiceFactoryBean
0%
0/28
0%
0/4
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.config.spring.factories;
 8  
 
 9  
 import org.mule.api.component.Component;
 10  
 import org.mule.api.endpoint.EndpointBuilder;
 11  
 import org.mule.api.processor.MessageProcessor;
 12  
 import org.mule.api.transformer.Transformer;
 13  
 import org.mule.config.spring.util.SpringBeanLookup;
 14  
 import org.mule.construct.SimpleService;
 15  
 import org.mule.construct.SimpleService.Type;
 16  
 import org.mule.construct.builder.AbstractFlowConstructBuilder;
 17  
 import org.mule.construct.builder.SimpleServiceBuilder;
 18  
 import org.springframework.beans.BeansException;
 19  
 import org.springframework.context.ApplicationContext;
 20  
 
 21  
 /**
 22  
  * Builds SimpleService instances by using the SimpleServiceBuilder.
 23  
  */
 24  0
 public class SimpleServiceFactoryBean extends AbstractFlowConstructFactoryBean
 25  
 {
 26  0
     final SimpleServiceBuilder simpleServiceBuilder = new SimpleServiceBuilder();
 27  
 
 28  
     private SpringBeanLookup springBeanLookup;
 29  
 
 30  
     public Class<?> getObjectType()
 31  
     {
 32  0
         return SimpleService.class;
 33  
     }
 34  
 
 35  
     @Override
 36  
     protected AbstractFlowConstructBuilder<SimpleServiceBuilder, SimpleService> getFlowConstructBuilder()
 37  
     {
 38  0
         return simpleServiceBuilder;
 39  
     }
 40  
 
 41  
     @Override
 42  
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
 43  
     {
 44  0
         super.setApplicationContext(applicationContext);
 45  
 
 46  0
         if (springBeanLookup != null)
 47  
         {
 48  0
             springBeanLookup.setApplicationContext(applicationContext);
 49  
         }
 50  0
     }
 51  
 
 52  
     public void setEndpointBuilder(EndpointBuilder endpointBuilder)
 53  
     {
 54  0
         simpleServiceBuilder.inboundEndpoint(endpointBuilder);
 55  0
     }
 56  
 
 57  
     public void setAddress(String address)
 58  
     {
 59  0
         simpleServiceBuilder.inboundAddress(address);
 60  0
     }
 61  
 
 62  
     public void setTransformers(Transformer... transformers)
 63  
     {
 64  0
         simpleServiceBuilder.inboundTransformers(transformers);
 65  0
     }
 66  
 
 67  
     public void setResponseTransformers(Transformer... responseTransformers)
 68  
     {
 69  0
         simpleServiceBuilder.inboundResponseTransformers(responseTransformers);
 70  0
     }
 71  
 
 72  
     public void setComponentClass(Class<?> componentClass)
 73  
     {
 74  0
         simpleServiceBuilder.component(componentClass);
 75  0
     }
 76  
 
 77  
     public void setComponentBeanName(String componentBeanName)
 78  
     {
 79  0
         springBeanLookup = new SpringBeanLookup();
 80  0
         springBeanLookup.setBean(componentBeanName);
 81  0
         simpleServiceBuilder.component(springBeanLookup);
 82  0
     }
 83  
     
 84  
     public void setType(Type type) {
 85  0
         simpleServiceBuilder.type(type);
 86  0
     }
 87  
 
 88  
     public void setMessageProcessor(MessageProcessor component)
 89  
     {
 90  0
         if (component instanceof Component)
 91  
         {
 92  0
             simpleServiceBuilder.component((Component) component);
 93  
         }
 94  
         else
 95  
         {
 96  0
             throw new IllegalArgumentException("Single Component message processor is required");
 97  
         }
 98  0
     }
 99  
 }