Coverage Report - org.mule.construct.builder.AbstractFlowConstructBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractFlowConstructBuilder
0%
0/16
0%
0/2
0
 
 1  
 /*
 2  
  * $Id$
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.construct.builder;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.exception.MessagingExceptionHandler;
 16  
 import org.mule.api.source.MessageSource;
 17  
 import org.mule.construct.AbstractFlowConstruct;
 18  
 
 19  
 @SuppressWarnings("unchecked")
 20  0
 public abstract class AbstractFlowConstructBuilder<T extends AbstractFlowConstructBuilder, F extends AbstractFlowConstruct>
 21  
 {
 22  
     protected String name;
 23  
     protected MessageSource messageSource;
 24  
     protected MessagingExceptionHandler exceptionListener;
 25  
 
 26  
     public T name(String name)
 27  
     {
 28  0
         this.name = name;
 29  0
         return (T) this;
 30  
     }
 31  
 
 32  
     public T messageSource(MessageSource messageSource)
 33  
     {
 34  0
         this.messageSource = messageSource;
 35  0
         return (T) this;
 36  
     }
 37  
 
 38  
     public T exceptionStrategy(MessagingExceptionHandler exceptionListener)
 39  
     {
 40  0
         this.exceptionListener = exceptionListener;
 41  0
         return (T) this;
 42  
     }
 43  
 
 44  
     public F build(MuleContext muleContext) throws MuleException
 45  
     {
 46  0
         final F flowConstruct = buildFlowConstruct(muleContext);
 47  0
         addExceptionListener(flowConstruct);
 48  0
         return flowConstruct;
 49  
     }
 50  
 
 51  
     public F buildAndRegister(MuleContext muleContext) throws MuleException
 52  
     {
 53  0
         final F flowConstruct = build(muleContext);
 54  0
         muleContext.getRegistry().registerObject(flowConstruct.getName(), flowConstruct);
 55  0
         return flowConstruct;
 56  
     }
 57  
 
 58  
     protected abstract F buildFlowConstruct(MuleContext muleContext) throws MuleException;
 59  
 
 60  
     protected void addExceptionListener(AbstractFlowConstruct flowConstruct)
 61  
     {
 62  0
         if (exceptionListener != null)
 63  
         {
 64  0
             flowConstruct.setExceptionListener(exceptionListener);
 65  
         }
 66  0
     }
 67  
 }