Coverage Report - org.mule.construct.builder.SimpleServiceBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleServiceBuilder
0%
0/21
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.construct.builder;
 8  
 
 9  
 import java.util.Arrays;
 10  
 
 11  
 import org.mule.MessageExchangePattern;
 12  
 import org.mule.api.MuleContext;
 13  
 import org.mule.api.MuleException;
 14  
 import org.mule.api.component.Component;
 15  
 import org.mule.api.component.JavaComponent;
 16  
 import org.mule.api.lifecycle.Callable;
 17  
 import org.mule.api.model.EntryPointResolverSet;
 18  
 import org.mule.api.object.ObjectFactory;
 19  
 import org.mule.api.processor.MessageProcessor;
 20  
 import org.mule.api.transformer.Transformer;
 21  
 import org.mule.component.DefaultJavaComponent;
 22  
 import org.mule.component.SimpleCallableJavaComponent;
 23  
 import org.mule.construct.SimpleService;
 24  
 import org.mule.construct.SimpleService.Type;
 25  
 import org.mule.model.resolvers.LegacyEntryPointResolverSet;
 26  
 import org.mule.object.PrototypeObjectFactory;
 27  
 import org.mule.object.SingletonObjectFactory;
 28  
 
 29  
 /**
 30  
  * Fluent API for the creation of a SimpleService.
 31  
  */
 32  0
 public class SimpleServiceBuilder extends
 33  
     AbstractFlowConstructWithSingleInboundEndpointBuilder<SimpleServiceBuilder, SimpleService>
 34  
 {
 35  0
     protected Type type = SimpleService.Type.DIRECT;
 36  
     protected Component component;
 37  
 
 38  
     @Override
 39  
     protected MessageExchangePattern getInboundMessageExchangePattern()
 40  
     {
 41  0
         return MessageExchangePattern.REQUEST_RESPONSE;
 42  
     }
 43  
 
 44  
     public SimpleServiceBuilder inboundTransformers(Transformer... transformers)
 45  
     {
 46  0
         this.inboundTransformers = Arrays.asList((MessageProcessor[]) transformers);
 47  0
         return this;
 48  
     }
 49  
 
 50  
     public SimpleServiceBuilder inboundResponseTransformers(Transformer... responseTransformers)
 51  
     {
 52  0
         this.inboundResponseTransformers = Arrays.asList((MessageProcessor[]) responseTransformers);
 53  0
         return this;
 54  
     }
 55  
 
 56  
     public SimpleServiceBuilder component(Class<?> componentClass)
 57  
     {
 58  0
         return component(new PrototypeObjectFactory(componentClass));
 59  
     }
 60  
 
 61  
     public SimpleServiceBuilder component(ObjectFactory objectFactory)
 62  
     {
 63  0
         return component(new DefaultJavaComponent(objectFactory));
 64  
     }
 65  
 
 66  
     public SimpleServiceBuilder component(Callable callable)
 67  
     {
 68  0
         return component(new SimpleCallableJavaComponent(callable));
 69  
     }
 70  
 
 71  
     public SimpleServiceBuilder component(Object o)
 72  
     {
 73  0
         return component(new SingletonObjectFactory(o));
 74  
     }
 75  
 
 76  
     public SimpleServiceBuilder type(Type type)
 77  
     {
 78  0
         this.type = type;
 79  0
         return this;
 80  
     }
 81  
 
 82  
     public SimpleServiceBuilder component(Component component)
 83  
     {
 84  0
         if (component instanceof JavaComponent)
 85  
         {
 86  0
             final JavaComponent javaComponent = (JavaComponent) component;
 87  
 
 88  0
             if (javaComponent.getEntryPointResolverSet() == null)
 89  
             {
 90  0
                 javaComponent.setEntryPointResolverSet(createEntryPointResolverSet());
 91  
             }
 92  
         }
 93  
 
 94  0
         this.component = component;
 95  0
         return this;
 96  
     }
 97  
 
 98  
     @Override
 99  
     protected SimpleService buildFlowConstruct(MuleContext muleContext) throws MuleException
 100  
     {
 101  0
         return new SimpleService(name, muleContext, getOrBuildInboundEndpoint(muleContext), component, type);
 102  
     }
 103  
 
 104  
     protected EntryPointResolverSet createEntryPointResolverSet()
 105  
     {
 106  0
         return new LegacyEntryPointResolverSet();
 107  
     }
 108  
 }