Coverage Report - org.mule.construct.builder.AbstractFlowConstructBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFlowConstructBuilder
0%
0/20
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 org.mule.api.MuleContext;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.exception.MessagingExceptionHandler;
 12  
 import org.mule.api.source.MessageSource;
 13  
 import org.mule.construct.AbstractFlowConstruct;
 14  
 
 15  
 @SuppressWarnings("unchecked")
 16  0
 public abstract class AbstractFlowConstructBuilder<T extends AbstractFlowConstructBuilder, F extends AbstractFlowConstruct>
 17  
 {
 18  
     protected String name;
 19  
     protected String initialState;
 20  
     protected MessageSource messageSource;
 21  
     protected MessagingExceptionHandler exceptionListener;
 22  
 
 23  
     public T name(String name)
 24  
     {
 25  0
         this.name = name;
 26  0
         return (T) this;
 27  
     }
 28  
 
 29  
     public T messageSource(MessageSource messageSource)
 30  
     {
 31  0
         this.messageSource = messageSource;
 32  0
         return (T) this;
 33  
     }
 34  
 
 35  
     public T exceptionStrategy(MessagingExceptionHandler exceptionListener)
 36  
     {
 37  0
         this.exceptionListener = exceptionListener;
 38  0
         return (T) this;
 39  
     }
 40  
 
 41  
     public T initialState(String initialState)
 42  
     {
 43  0
         this.initialState = initialState;
 44  0
         return (T) this;
 45  
     }
 46  
 
 47  
     public F build(MuleContext muleContext) throws MuleException
 48  
     {
 49  0
         final F flowConstruct = buildFlowConstruct(muleContext);
 50  0
         addExceptionListener(flowConstruct);
 51  0
         if(initialState!=null)
 52  
         {
 53  0
             flowConstruct.setInitialState(initialState);
 54  
         }
 55  0
         return flowConstruct;
 56  
     }
 57  
 
 58  
     public F buildAndRegister(MuleContext muleContext) throws MuleException
 59  
     {
 60  0
         final F flowConstruct = build(muleContext);
 61  0
         muleContext.getRegistry().registerObject(flowConstruct.getName(), flowConstruct);
 62  0
         return flowConstruct;
 63  
     }
 64  
 
 65  
     protected abstract F buildFlowConstruct(MuleContext muleContext) throws MuleException;
 66  
 
 67  
     protected void addExceptionListener(AbstractFlowConstruct flowConstruct)
 68  
     {
 69  0
         if (exceptionListener != null)
 70  
         {
 71  0
             flowConstruct.setExceptionListener(exceptionListener);
 72  
         }
 73  0
     }
 74  
 }