Coverage Report - org.mule.transport.quartz.config.ScheduleConfigBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ScheduleConfigBuilder
0%
0/23
N/A
1.111
 
 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.transport.quartz.config;
 8  
 
 9  
 import org.mule.MessageExchangePattern;
 10  
 import org.mule.api.MuleContext;
 11  
 import org.mule.api.MuleException;
 12  
 import org.mule.api.NamedObject;
 13  
 import org.mule.api.endpoint.EndpointBuilder;
 14  
 import org.mule.api.endpoint.InboundEndpoint;
 15  
 import org.mule.transport.quartz.QuartzConnector;
 16  
 
 17  
 import org.quartz.Scheduler;
 18  
 
 19  
 /**
 20  
  * TODO
 21  
  */
 22  
 public class ScheduleConfigBuilder implements NamedObject
 23  
 {
 24  
     private EndpointBuilder endpointBuilder;
 25  
     private QuartzConnector connector;
 26  
     private String scheduleId;
 27  
 
 28  
     public ScheduleConfigBuilder(String scheduleId, MuleContext muleContext) throws MuleException
 29  
     {
 30  0
         super();
 31  0
         this.scheduleId = scheduleId;
 32  
 
 33  0
         endpointBuilder = muleContext.getEndpointFactory().getEndpointBuilder("quartz://" + scheduleId);
 34  0
         endpointBuilder.setMuleContext(muleContext);
 35  0
         endpointBuilder.setName(scheduleId);
 36  
 
 37  0
         connector = new QuartzConnector(muleContext);
 38  0
         connector.setName(scheduleId);
 39  
 
 40  0
         endpointBuilder.setConnector(connector);
 41  0
         endpointBuilder.setExchangePattern(MessageExchangePattern.ONE_WAY);
 42  0
     }
 43  
 
 44  
     public ScheduleConfigBuilder addSchedulerFactoryProperty(String key, String value)
 45  
     {
 46  0
         connector.getFactoryProperties().put(key, value);
 47  0
         return this;
 48  
     }
 49  
 
 50  
     public ScheduleConfigBuilder setScheduler(Scheduler scheduler)
 51  
     {
 52  0
         connector.setQuartzScheduler(scheduler);
 53  0
         return this;
 54  
     }
 55  
 
 56  
     public ScheduleConfigBuilder setCron(String cron)
 57  
     {
 58  0
         endpointBuilder.setProperty(QuartzConnector.PROPERTY_CRON_EXPRESSION, cron);
 59  0
         return this;
 60  
     }
 61  
 
 62  
     public ScheduleConfigBuilder setInterval(long interval)
 63  
     {
 64  0
         endpointBuilder.setProperty(QuartzConnector.PROPERTY_REPEAT_INTERVAL, interval);
 65  0
         return this;
 66  
     }
 67  
 
 68  
     public ScheduleConfigBuilder setStartDelay(long delay)
 69  
     {
 70  0
         endpointBuilder.setProperty(QuartzConnector.PROPERTY_START_DELAY, delay);
 71  0
         return this;
 72  
     }
 73  
 
 74  
     public InboundEndpoint buildScheduler() throws MuleException
 75  
     {
 76  0
         return endpointBuilder.buildInboundEndpoint();
 77  
     }
 78  
 
 79  
     public void setName(String name)
 80  
     {
 81  0
         throw new UnsupportedOperationException("setName");
 82  
     }
 83  
 
 84  
     public String getName()
 85  
     {
 86  0
         return scheduleId + ".builder";
 87  
     }
 88  
 }